Skip to content

Commit f9a65b0

Browse files
committed
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into add-pserver-util
2 parents f3c61cb + 495649a commit f9a65b0

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

demo/recommendation/evaluate.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/python
2+
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
import sys
16+
import re
17+
import math
18+
19+
20+
def get_best_pass(log_filename):
21+
with open(log_filename, 'r') as f:
22+
text = f.read()
23+
pattern = re.compile('Test.*? cost=([0-9]+\.[0-9]+).*?pass-([0-9]+)',
24+
re.S)
25+
results = re.findall(pattern, text)
26+
sorted_results = sorted(results, key=lambda result: float(result[0]))
27+
return sorted_results[0]
28+
29+
30+
log_filename = sys.argv[1]
31+
log = get_best_pass(log_filename)
32+
predict_error = math.sqrt(float(log[0])) / 2
33+
print 'Best pass is %s, error is %s, which means predict get error as %f' % (
34+
log[1], log[0], predict_error)
35+
36+
evaluate_pass = "output/pass-%s" % log[1]
37+
print "evaluating from pass %s" % evaluate_pass

paddle/utils/ThreadLocal.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ unsigned int* ThreadLocalRand::getSeed() {
3737
p = new unsigned int(defaultSeed_ - 1);
3838
} else {
3939
p = new unsigned int(defaultSeed_ + getTID());
40-
LOG(INFO) << "thread use undeterministic rand seed:" << *p;
40+
VLOG(3) << "thread use undeterministic rand seed:" << *p;
4141
}
4242
seed_.set(p);
4343
}

paddle/utils/Util.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ void registerInitFunction(std::function<void()> func, int priority) {
125125

126126
void runInitFunctions() {
127127
std::call_once(g_onceFlag, []() {
128-
LOG(INFO) << "Calling runInitFunctions";
128+
VLOG(3) << "Calling runInitFunctions";
129129
if (g_initFuncs) {
130130
std::sort(g_initFuncs->begin(),
131131
g_initFuncs->end(),
@@ -139,7 +139,7 @@ void runInitFunctions() {
139139
g_initFuncs = nullptr;
140140
}
141141
g_initialized = true;
142-
LOG(INFO) << "Call runInitFunctions done.";
142+
VLOG(3) << "Call runInitFunctions done.";
143143
});
144144
}
145145

@@ -231,7 +231,7 @@ std::string join(const std::string& part1, const std::string& part2) {
231231
} // namespace path
232232

233233
void copyFileToPath(const std::string& file, const std::string& dir) {
234-
LOG(INFO) << "copy " << file << " to " << dir;
234+
VLOG(3) << "copy " << file << " to " << dir;
235235
std::string fileName = path::basename(file);
236236
std::string dst = path::join(dir, fileName);
237237
std::ifstream source(file, std::ios_base::binary);

0 commit comments

Comments
 (0)