Skip to content

Commit 246f613

Browse files
committed
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into format
2 parents b6aa7bd + c12c041 commit 246f613

File tree

71 files changed

+1262
-469
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1262
-469
lines changed

benchmark/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ paddle/rnn/imdb.pkl
77
caffe/image/logs
88
tensorflow/image/logs
99
tensorflow/rnn/logs
10+
fluid/models/*.pyc
11+
fluid/logs
12+
fluid/nohup.out

benchmark/fluid/fluid_benchmark.py

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ def parse_args():
4040
parser.add_argument(
4141
'--batch_size', type=int, default=32, help='The minibatch size.')
4242
parser.add_argument(
43-
'--learning_rate',
44-
type=float,
45-
default=0.001,
46-
help='The minibatch size.')
43+
'--learning_rate', type=float, default=0.001, help='The learning rate.')
4744
# TODO(wuyi): add "--use_fake_data" option back.
4845
parser.add_argument(
4946
'--skip_batch_num',
@@ -88,8 +85,8 @@ def parse_args():
8885
help='If set, use nvprof for CUDA.')
8986
parser.add_argument(
9087
'--no_test',
91-
action='store_false',
92-
help='If set, test the testset during training.')
88+
action='store_true',
89+
help='If set, do not test the testset during training.')
9390
parser.add_argument(
9491
'--memory_optimize',
9592
action='store_true',
@@ -231,13 +228,10 @@ def train(avg_loss, infer_prog, optimizer, train_reader, test_reader, batch_acc,
231228
train_losses.append(loss)
232229
print("Pass: %d, Iter: %d, Loss: %f\n" %
233230
(pass_id, iters, np.mean(train_losses)))
234-
train_elapsed = time.time() - start_time
235-
examples_per_sec = num_samples / train_elapsed
236-
print('\nTotal examples: %d, total time: %.5f, %.5f examples/sec\n' %
237-
(num_samples, train_elapsed, examples_per_sec))
238-
print("Pass: %d, Loss: %f" % (pass_id, np.mean(train_losses)))
231+
print_train_time(start_time, time.time(), num_samples)
232+
print("Pass: %d, Loss: %f" % (pass_id, np.mean(train_losses))),
239233
# evaluation
240-
if not args.no_test and batch_acc != None:
234+
if not args.no_test and batch_acc:
241235
pass_test_acc = test(exe, infer_prog, test_reader, feeder,
242236
batch_acc)
243237
print(", Test Accuracy: %f" % pass_test_acc)
@@ -315,11 +309,8 @@ def train_parallel(avg_loss, infer_prog, optimizer, train_reader, test_reader,
315309
if batch_id % 1 == 0:
316310
print("Pass %d, batch %d, loss %s" %
317311
(pass_id, batch_id, np.array(loss)))
318-
train_elapsed = time.time() - start_time
319-
examples_per_sec = num_samples / train_elapsed
320-
print('\nTotal examples: %d, total time: %.5f, %.5f examples/sed\n' %
321-
(num_samples, train_elapsed, examples_per_sec))
322-
if not args.no_test and batch_acc != None:
312+
print_train_time(start_time, time.time(), num_samples)
313+
if not args.no_test and batch_acc:
323314
test_acc = test(startup_exe, infer_prog, test_reader, feeder,
324315
batch_acc)
325316
print("Pass: %d, Test Accuracy: %f\n" % (pass_id, test_acc))
@@ -329,20 +320,27 @@ def train_parallel(avg_loss, infer_prog, optimizer, train_reader, test_reader,
329320
def print_arguments(args):
330321
vars(args)['use_nvprof'] = (vars(args)['use_nvprof'] and
331322
vars(args)['device'] == 'GPU')
332-
print('----------- resnet Configuration Arguments -----------')
323+
print('----------- Configuration Arguments -----------')
333324
for arg, value in sorted(vars(args).iteritems()):
334325
print('%s: %s' % (arg, value))
335326
print('------------------------------------------------')
336327

337328

329+
def print_train_time(start_time, end_time, num_samples):
330+
train_elapsed = end_time - start_time
331+
examples_per_sec = num_samples / train_elapsed
332+
print('\nTotal examples: %d, total time: %.5f, %.5f examples/sed\n' %
333+
(num_samples, train_elapsed, examples_per_sec))
334+
335+
338336
def main():
339337
args = parse_args()
340338
print_arguments(args)
341339

342340
# the unique trainer id, starting from 0, needed by trainer
343341
# only
344342
nccl_id_var, num_trainers, trainer_id = (
345-
None, 1, int(os.getenv("PADDLE_TRAINER_ID", "-1")))
343+
None, 1, int(os.getenv("PADDLE_TRAINER_ID", "0")))
346344

347345
if args.use_cprof:
348346
pr = cProfile.Profile()

benchmark/fluid/run.sh

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# This script benchmarking the PaddlePaddle Fluid on
33
# single thread single GPU.
44

5+
mkdir -p logs
56
#export FLAGS_fraction_of_gpu_memory_to_use=0.0
67
export CUDNN_PATH=/paddle/cudnn_v5
78

@@ -35,6 +36,7 @@ nohup stdbuf -oL nvidia-smi \
3536
--format=csv \
3637
--filename=mem.log \
3738
-l 1 &
39+
3840
# mnist
3941
# mnist gpu mnist 128
4042
FLAGS_benchmark=true stdbuf -oL python fluid_benchmark.py \
@@ -43,7 +45,7 @@ FLAGS_benchmark=true stdbuf -oL python fluid_benchmark.py \
4345
--batch_size=128 \
4446
--skip_batch_num=5 \
4547
--iterations=500 \
46-
2>&1 | tee -a mnist_gpu_128.log
48+
2>&1 | tee -a logs/mnist_gpu_128.log
4749

4850
# vgg16
4951
# gpu cifar10 128
@@ -53,7 +55,7 @@ FLAGS_benchmark=true stdbuf -oL python fluid_benchmark.py \
5355
--batch_size=128 \
5456
--skip_batch_num=5 \
5557
--iterations=30 \
56-
2>&1 | tee -a vgg16_gpu_128.log
58+
2>&1 | tee -a logs/vgg16_gpu_128.log
5759

5860
# flowers gpu 128
5961
FLAGS_benchmark=true stdbuf -oL python fluid_benchmark.py \
@@ -63,28 +65,28 @@ FLAGS_benchmark=true stdbuf -oL python fluid_benchmark.py \
6365
--data_set=flowers \
6466
--skip_batch_num=5 \
6567
--iterations=30 \
66-
2>&1 | tee -a vgg16_gpu_flowers_32.log
68+
2>&1 | tee -a logs/vgg16_gpu_flowers_32.log
6769

6870
# resnet50
6971
# resnet50 gpu cifar10 128
7072
FLAGS_benchmark=true stdbuf -oL python fluid_benchmark.py \
71-
--model=resnet50 \
73+
--model=resnet \
7274
--device=GPU \
7375
--batch_size=128 \
7476
--data_set=cifar10 \
7577
--skip_batch_num=5 \
7678
--iterations=30 \
77-
2>&1 | tee -a resnet50_gpu_128.log
79+
2>&1 | tee -a logs/resnet50_gpu_128.log
7880

7981
# resnet50 gpu flowers 64
8082
FLAGS_benchmark=true stdbuf -oL python fluid_benchmark.py \
81-
--model=resnet50 \
83+
--model=resnet \
8284
--device=GPU \
8385
--batch_size=64 \
8486
--data_set=flowers \
8587
--skip_batch_num=5 \
8688
--iterations=30 \
87-
2>&1 | tee -a resnet50_gpu_flowers_64.log
89+
2>&1 | tee -a logs/resnet50_gpu_flowers_64.log
8890

8991
# lstm
9092
# lstm gpu imdb 32 # tensorflow only support batch=32
@@ -94,7 +96,7 @@ FLAGS_benchmark=true stdbuf -oL python fluid_benchmark.py \
9496
--batch_size=32 \
9597
--skip_batch_num=5 \
9698
--iterations=30 \
97-
2>&1 | tee -a lstm_gpu_32.log
99+
2>&1 | tee -a logs/lstm_gpu_32.log
98100

99101
# seq2seq
100102
# seq2seq gpu wmb 128
@@ -104,4 +106,4 @@ FLAGS_benchmark=true stdbuf -oL python fluid_benchmark.py \
104106
--batch_size=128 \
105107
--skip_batch_num=5 \
106108
--iterations=30 \
107-
2>&1 | tee -a lstm_gpu_128.log
109+
2>&1 | tee -a logs/lstm_gpu_128.log

cmake/external/grpc.cmake

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,19 @@ ELSE()
3333
SET(BUILD_CMD make HAS_SYSTEM_PROTOBUF=false -s -j ${NUM_OF_PROCESSOR} static grpc_cpp_plugin)
3434
ENDIF()
3535

36+
# FIXME(wuyi): do not build zlib cares protobuf twice, find a way to build grpc with them
3637
ExternalProject_Add(
3738
extern_grpc
3839
DEPENDS protobuf zlib
39-
URL "http://paddlepaddledeps.bj.bcebos.com/grpc.tar.xz"
40+
# NOTE(wuyi):
41+
# this package is generated by following steps:
42+
# 1. git clone -b v1.8.x https://github.com/grpc/grpc.git
43+
# 2. submodule update --init
44+
# 3. keep only zlib, cares, protobuf, boringssl under "third_party",
45+
# checkout and clean other dirs under third_party
46+
# 4. remove .git, and package the directory.
47+
URL "http://paddlepaddledeps.bj.bcebos.com/grpc-v1.8.x.tar.gz"
48+
URL_MD5 "c9c58ee7d0e8929a63155af6a2ecdbd0"
4049
PREFIX ${GRPC_SOURCES_DIR}
4150
UPDATE_COMMAND ""
4251
CONFIGURE_COMMAND ""
@@ -49,7 +58,6 @@ ExternalProject_Add(
4958
INSTALL_COMMAND make prefix=${GRPC_INSTALL_DIR} install
5059
)
5160

52-
# FIXME(typhoonzero): hack to get static lib path, try a better way like merge them.
5361
ADD_LIBRARY(grpc++_unsecure STATIC IMPORTED GLOBAL)
5462
SET_PROPERTY(TARGET grpc++_unsecure PROPERTY IMPORTED_LOCATION
5563
"${GRPC_INSTALL_DIR}/lib/libgrpc++_unsecure.a")

doc/fluid/api/io.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,21 @@ get_inference_program
5959
.. autofunction:: paddle.fluid.io.get_inference_program
6060
:noindex:
6161

62+
save_checkpoint
63+
---------------
64+
65+
.. autofunction:: paddle.fluid.io.save_checkpoint
66+
:noindex:
67+
68+
load_checkpoint
69+
---------------
70+
71+
.. autofunction:: paddle.fluid.io.load_checkpoint
72+
:noindex:
73+
74+
clean_checkpoint
75+
----------------
76+
77+
.. autofunction:: paddle.fluid.io.clean_checkpoint
78+
:noindex:
79+

doc/fluid/api/layers.rst

Lines changed: 48 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@ Print
181181
.. autofunction:: paddle.fluid.layers.Print
182182
:noindex:
183183

184+
is_empty
185+
--------
186+
187+
.. autofunction:: paddle.fluid.layers.is_empty
188+
:noindex:
189+
184190
device
185191
======
186192

@@ -255,6 +261,19 @@ double_buffer
255261
.. autofunction:: paddle.fluid.layers.double_buffer
256262
:noindex:
257263

264+
random_data_generator
265+
---------------------
266+
267+
.. autofunction:: paddle.fluid.layers.random_data_generator
268+
:noindex:
269+
270+
Preprocessor
271+
------------
272+
273+
.. autoclass:: paddle.fluid.layers.Preprocessor
274+
:members:
275+
:noindex:
276+
258277
nn
259278
==
260279

@@ -594,6 +613,29 @@ roi_pool
594613
.. autofunction:: paddle.fluid.layers.roi_pool
595614
:noindex:
596615

616+
dice_loss
617+
---------
618+
619+
.. autofunction:: paddle.fluid.layers.dice_loss
620+
:noindex:
621+
622+
resize_bilinear
623+
---------------
624+
625+
.. autofunction:: paddle.fluid.layers.resize_bilinear
626+
:noindex:
627+
628+
gather
629+
------
630+
631+
.. autofunction:: paddle.fluid.layers.gather
632+
:noindex:
633+
634+
random_crop
635+
-----------
636+
637+
.. autofunction:: paddle.fluid.layers.random_crop
638+
:noindex:
597639

598640
ops
599641
===
@@ -742,6 +784,12 @@ sum
742784
.. autofunction:: paddle.fluid.layers.sum
743785
:noindex:
744786

787+
shape
788+
-----
789+
790+
.. autofunction:: paddle.fluid.layers.shape
791+
:noindex:
792+
745793
sigmoid
746794
-------
747795

@@ -991,27 +1039,3 @@ zeros
9911039
.. autofunction:: paddle.fluid.layers.zeros
9921040
:noindex:
9931041

994-
topk
995-
----
996-
997-
.. autofunction:: paddle.fluid.layers.topk
998-
:noindex:
999-
1000-
dice_loss
1001-
----
1002-
1003-
.. autofunction:: paddle.fluid.layers.dice_loss
1004-
:noindex:
1005-
1006-
resize_bilinear
1007-
____
1008-
1009-
.. autofunction:: paddle.fluid.layers.resize_bilinear
1010-
:noindex:
1011-
1012-
gather
1013-
____
1014-
1015-
.. autofunction:: paddle.fluid.layers.gather
1016-
:noindex:
1017-

doc/fluid/api/optimizer.rst

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -47,28 +47,6 @@ DecayedAdagrad
4747
:members:
4848
:noindex:
4949

50-
Adadelta
51-
-----------------
52-
53-
.. autoclass:: paddle.fluid.optimizer.Adadelta
54-
:members:
55-
:noindex:
56-
57-
RMSProp
58-
-----------------
59-
60-
.. autoclass:: paddle.fluid.optimizer.RMSProp
61-
:members:
62-
:noindex:
63-
64-
ModelAverage
65-
-----------------
66-
67-
.. autoclass:: paddle.fluid.optimizer.ModelAverage
68-
:members:
69-
:noindex:
70-
71-
7250
SGDOptimizer
7351
------------
7452

@@ -111,25 +89,31 @@ DecayedAdagradOptimizer
11189
:members:
11290
:noindex:
11391

92+
RMSPropOptimizer
93+
----------------
11494

115-
AdadeltaOptimizer
116-
-----------------
117-
118-
.. autoclass:: paddle.fluid.optimizer.AdadeltaOptimizer
95+
.. autoclass:: paddle.fluid.optimizer.RMSPropOptimizer
11996
:members:
12097
:noindex:
12198

99+
Adadelta
100+
--------
122101

123-
RMSPropOptimizer
124-
-----------------
102+
.. autoclass:: paddle.fluid.optimizer.Adadelta
103+
:members:
104+
:noindex:
125105

126-
.. autoclass:: paddle.fluid.optimizer.RMSPropOptimizer
106+
ModelAverage
107+
------------
108+
109+
.. autoclass:: paddle.fluid.optimizer.ModelAverage
127110
:members:
128111
:noindex:
129-
112+
130113
Optimizer
131114
---------
132115

133116
.. autoclass:: paddle.fluid.optimizer.Optimizer
134117
:members:
135118
:noindex:
119+

0 commit comments

Comments
 (0)