Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #12 from PaddlePaddle/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
zhengya01 committed Apr 3, 2019
2 parents 46e1140 + 54699e8 commit 57f14fe
Show file tree
Hide file tree
Showing 19 changed files with 22 additions and 19 deletions.
1 change: 1 addition & 0 deletions ce_models/mnist/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -1 +1 @@
[1394]
[1342]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[767.2907104492188]
[2310.2907104492188]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[10352]
[8732]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[92.87747192382812]
[193.87747192382812]
8 changes: 5 additions & 3 deletions ce_models/resnet50/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import paddle
import paddle.fluid as fluid
import paddle.fluid.compiler as compiler
import paddle.fluid.core as core
import paddle.fluid.profiler as profiler

Expand Down Expand Up @@ -213,12 +214,11 @@ def run_benchmark(model, args):
input=predict, label=label, total=batch_size_tensor)

inference_program = fluid.default_main_program().clone(for_test=True)
inference_program = compiler.CompiledProgram(inference_program).with_data_parallel()

optimizer = fluid.optimizer.Momentum(learning_rate=0.01, momentum=0.9)
opts = optimizer.minimize(avg_cost)

fluid.memory_optimize(fluid.default_main_program())

train_reader = paddle.batch(
paddle.reader.shuffle(
paddle.dataset.cifar.train10()
Expand Down Expand Up @@ -249,6 +249,8 @@ def test(exe):
place = core.CPUPlace() if args.device == 'CPU' else core.CUDAPlace(0)
exe = fluid.Executor(place)
exe.run(fluid.default_startup_program())
compiled_prog = compiler.CompiledProgram(fluid.default_main_program()).with_data_parallel(
loss_name=avg_cost.name)
accuracy = fluid.average.WeightedAverage()
if args.use_fake_data:
data = train_reader().next()
Expand Down Expand Up @@ -285,7 +287,7 @@ def test(exe):
label = np.array(map(lambda x: x[1], data)).astype('int64')
label = label.reshape([-1, 1])
loss, acc, weight = exe.run(
fluid.default_main_program(),
compiled_prog,
feed={'data': image,
'label': label},
fetch_list=[avg_cost, batch_acc, batch_size_tensor])
Expand Down
3 changes: 2 additions & 1 deletion ce_models/resnet50_net_CPU/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ def get_parallel_executor(args, avg_cost, train_program, test_program):
build_strategy.reduce_strategy = fluid.BuildStrategy.ReduceStrategy.Reduce \
if args.reduce_strategy == "Reduce" \
else fluid.BuildStrategy.ReduceStrategy.AllReduce

if args.reduce_strategy == "Reduce":
build_strategy.fuse_broadcast_ops = True
train_exe = fluid.ParallelExecutor(
loss_name=avg_cost.name,
main_program=train_program,
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[730.0634155273438]
[1487.0634155273438]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[10547]
[8902]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[68.13056182861328]
[105.13056182861328]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[4.80402100086]
[23.6]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[3.33657252789]
[20.1766821543]

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
[0.0014293382]
[0.00131]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[0.0012988691]
[0.0012868968]

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
[0.232039]
[0.204901]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[3.1024718]
[3.0848286]
1 change: 1 addition & 0 deletions test_models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

0 comments on commit 57f14fe

Please sign in to comment.