Skip to content

Commit 625b153

Browse files
committed
optimize code
1 parent 3648165 commit 625b153

File tree

1 file changed

+4
-4
lines changed
  • python/paddle/v2/framework/tests

1 file changed

+4
-4
lines changed

python/paddle/v2/framework/tests/mnist.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
optimize_net = core.Net.create()
1818

1919

20-
def atom_id():
20+
def atomic_id():
2121
id = 0
2222
while True:
2323
yield id
2424
id += 1
2525

2626

27-
uniq_id = atom_id().next
27+
uniq_id = atomic_id().next
2828

2929

3030
def data_layer(name, dims):
@@ -164,7 +164,7 @@ def set_cost(cost):
164164
cost_grad.set(numpy.ones(cost_shape).astype("float32"), place)
165165

166166

167-
def mean_cost(cost):
167+
def get_cost_mean(cost):
168168
cost_data = numpy.array(scope.find_var(cost).get_tensor())
169169
return cost_data.sum() / len(cost_data)
170170

@@ -217,7 +217,7 @@ def test(cost_name):
217217

218218
forward_net.infer_shape(scope)
219219
forward_net.run(scope, dev_ctx)
220-
cost.append(mean_cost(cost_name))
220+
cost.append(get_cost_mean(cost_name))
221221
error.append(error_rate(predict, "label"))
222222
print("cost=" + str(sum(cost) / float(len(cost))) + " error_rate=" + str(
223223
sum(error) / float(len(error))))

0 commit comments

Comments
 (0)