diff --git a/.gitignore b/.gitignore index 35bed0accdaa274f5966ca5b4b7180106325449b..1c9730a5ad57cd70613c0692529bcb1ccf056d59 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,6 @@ build/ .pydevproject Makefile .test_env/ + +*~ +bazel-* diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 942669c41ff154c91e88c937739b0f604f21d545..b9902a863d864b28f0fad0fefe64248e356010e4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,8 @@ - repo: https://github.com/reyoung/mirrors-yapf.git sha: v0.13.2 hooks: - - id: yapf + - id: yapf + files: (.*\.(py|bzl)|BUILD|.*\.BUILD|WORKSPACE)$ # Bazel BUILD files follow Python syntax. - repo: https://github.com/pre-commit/pre-commit-hooks sha: 7539d8bd1a00a3c1bfd34cdb606d3a6372e83469 hooks: diff --git a/.travis.yml b/.travis.yml index 6215060e336c7cff9689951c918dc7ec02b2a2fb..7de4ec7fc511832998cd0dc053645e52136042b8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,10 +8,13 @@ os: env: - JOB=DOCS - JOB=BUILD_AND_TEST + - JOB=PRE_COMMIT matrix: exclude: - os: osx - env: JOB=DOCS # Only generate documentation in linux + env: JOB=DOCS # Only generate documentation in linux. + - os: osx + env: JOB=PRE_COMMIT # Only check pre-commit hook in linux addons: apt: @@ -39,18 +42,23 @@ addons: - lcov - graphviz - swig + - clang-format-3.8 before_install: - | if [ ${JOB} == "BUILD_AND_TEST" ]; then - if ! git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qvE '(\.md$)|(\.rst$)|(\.jpg$)|(\.png$)' - then - echo "Only markdown docs were updated, stopping build process." - exit + local change_list=`git diff --name-only $TRAVIS_COMMIT_RANGE` + if [ $? -eq 0 ]; then # if git diff return no zero, then rerun unit test. + if ! echo ${change_list} | grep -qvE '(\.md$)|(\.rst$)|(\.jpg$)|(\.png$)' + then + echo "Only markdown docs were updated, stopping build process." + exit + fi fi fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo paddle/scripts/travis/before_install.linux.sh; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then paddle/scripts/travis/before_install.osx.sh; fi - - pip install wheel protobuf sphinx breathe recommonmark virtualenv numpy sphinx_rtd_theme + - if [[ "$JOB" == "PRE_COMMIT" ]]; then sudo ln -s /usr/bin/clang-format-3.8 /usr/bin/clang-format; fi + - pip install wheel protobuf sphinx recommonmark virtualenv numpy sphinx_rtd_theme pre-commit script: - paddle/scripts/travis/main.sh notifications: diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c40e3c6f7d1170443abe2a93c07f75527b18b49..0a44e56719baa433a5c45df2082fa86296b3da1c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,7 +69,7 @@ include(coveralls) find_package(Git REQUIRED) # version.cmake will get the current PADDLE_VERSION include(version) -add_definitions(-DPADDLE_VERSION=\"${PADDLE_VERSION}\") +add_definitions(-DPADDLE_VERSION=${PADDLE_VERSION}) if(NOT WITH_GPU) add_definitions(-DPADDLE_ONLY_CPU) diff --git a/LICENSE b/LICENSE index 2ff3140db0d7025369cb8fe3036ec0679eb6a023..e77bd090ee4f1ae549089f7de660a58364f42170 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2016 Baidu, Inc. All Rights Reserved +Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved Apache License Version 2.0, January 2004 @@ -188,7 +188,7 @@ Copyright (c) 2016 Baidu, Inc. All Rights Reserved same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright (c) 2016 Baidu, Inc. All Rights Reserve. + Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/WORKSPACE b/WORKSPACE new file mode 100644 index 0000000000000000000000000000000000000000..0b8299905abb844bfbd8b27f47b8fafded31ef7a --- /dev/null +++ b/WORKSPACE @@ -0,0 +1,15 @@ +# External dependency to Google protobuf. +http_archive( + name="protobuf", + url="http://github.com/google/protobuf/archive/v3.1.0.tar.gz", + sha256="0a0ae63cbffc274efb573bdde9a253e3f32e458c41261df51c5dbc5ad541e8f7", + strip_prefix="protobuf-3.1.0", ) + +# External dependency to gtest 1.7.0. This method comes from +# https://www.bazel.io/versions/master/docs/tutorial/cpp.html. +new_http_archive( + name="gtest", + url="https://github.com/google/googletest/archive/release-1.7.0.zip", + sha256="b58cb7547a28b2c718d1e38aee18a3659c9e3ff52440297e965f5edffe34b6d0", + build_file="third_party/gtest.BUILD", + strip_prefix="googletest-release-1.7.0", ) diff --git a/benchmark/tensorflow/rnn/run_multi.sh b/benchmark/tensorflow/rnn/run_multi.sh index f7f52e01e38d304bb3bf8185c53bd0da26014d3a..c2d7dd597e6da54cd5c4cda311fbbd18486b4647 100755 --- a/benchmark/tensorflow/rnn/run_multi.sh +++ b/benchmark/tensorflow/rnn/run_multi.sh @@ -25,4 +25,3 @@ test 4 2 256 512 test 4 2 512 128 test 4 2 512 256 test 4 2 512 512 - diff --git a/cmake/check_packages.cmake b/cmake/check_packages.cmake index 3bc0c1fd18448e3c2f0799295ac77d57cdc1bee7..06887455418797f7162a5970669a0483e42a2db8 100644 --- a/cmake/check_packages.cmake +++ b/cmake/check_packages.cmake @@ -30,7 +30,6 @@ if(WITH_DOC) find_package(Sphinx REQUIRED) find_package(Doxygen REQUIRED) find_python_module(recommonmark REQUIRED) - find_python_module(breathe REQUIRED) endif() if(WITH_SWIG_PY) diff --git a/demo/gan/README.md b/demo/gan/README.md index fdc970a07b488c3a4146c9baa76a133a456fc9ab..1908b534b0c1f63904d5503399b961d74ce0037c 100644 --- a/demo/gan/README.md +++ b/demo/gan/README.md @@ -10,4 +10,4 @@ Then you can run the command below. The flag -d specifies the training data (cif $python gan_trainer.py -d cifar --use_gpu 1 The generated images will be stored in ./cifar_samples/ -The corresponding models will be stored in ./cifar_params/ \ No newline at end of file +The corresponding models will be stored in ./cifar_params/ diff --git a/demo/gan/data/download_cifar.sh b/demo/gan/data/download_cifar.sh index ea3be594cd08f829e94f2c692a44947baa62b759..ae24ef2b7f2012fb719037d4868bdf0e7f9ce71d 100755 --- a/demo/gan/data/download_cifar.sh +++ b/demo/gan/data/download_cifar.sh @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,4 +15,3 @@ set -e wget https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz tar zxf cifar-10-python.tar.gz rm cifar-10-python.tar.gz - diff --git a/demo/gan/data/get_mnist_data.sh b/demo/gan/data/get_mnist_data.sh index d21bf7067135f1f8be486ef0f13fc3ec94ffc4ed..a77c81bf5af9ddb6634ff89460797ca543c5e517 100644 --- a/demo/gan/data/get_mnist_data.sh +++ b/demo/gan/data/get_mnist_data.sh @@ -15,5 +15,3 @@ do gunzip ${fname}.gz fi done - - diff --git a/demo/gan/gan_conf.py b/demo/gan/gan_conf.py index 05eee3a9b9ce455eb3a5d47d3165ee7f42f1002e..86ac2dffe5f4490a88e12d1fa5e8cd9fa61a69f4 100644 --- a/demo/gan/gan_conf.py +++ b/demo/gan/gan_conf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,10 +14,9 @@ from paddle.trainer_config_helpers import * mode = get_config_arg("mode", str, "generator") -assert mode in set(["generator", - "discriminator", - "generator_training", - "discriminator_training"]) +assert mode in set([ + "generator", "discriminator", "generator_training", "discriminator_training" +]) is_generator_training = mode == "generator_training" is_discriminator_training = mode == "discriminator_training" @@ -38,8 +37,8 @@ sample_dim = 2 settings( batch_size=128, learning_rate=1e-4, - learning_method=AdamOptimizer(beta1=0.5) -) + learning_method=AdamOptimizer(beta1=0.5)) + def discriminator(sample): """ @@ -50,70 +49,87 @@ def discriminator(sample): of the sample is from real data. """ param_attr = ParamAttr(is_static=is_generator_training) - bias_attr = ParamAttr(is_static=is_generator_training, - initial_mean=1.0, - initial_std=0) - - hidden = fc_layer(input=sample, name="dis_hidden", size=hidden_dim, - bias_attr=bias_attr, - param_attr=param_attr, - act=ReluActivation()) - - hidden2 = fc_layer(input=hidden, name="dis_hidden2", size=hidden_dim, - bias_attr=bias_attr, - param_attr=param_attr, - act=LinearActivation()) - - hidden_bn = batch_norm_layer(hidden2, - act=ReluActivation(), - name="dis_hidden_bn", - bias_attr=bias_attr, - param_attr=ParamAttr(is_static=is_generator_training, - initial_mean=1.0, - initial_std=0.02), - use_global_stats=False) - - return fc_layer(input=hidden_bn, name="dis_prob", size=2, - bias_attr=bias_attr, - param_attr=param_attr, - act=SoftmaxActivation()) + bias_attr = ParamAttr( + is_static=is_generator_training, initial_mean=1.0, initial_std=0) + + hidden = fc_layer( + input=sample, + name="dis_hidden", + size=hidden_dim, + bias_attr=bias_attr, + param_attr=param_attr, + act=ReluActivation()) + + hidden2 = fc_layer( + input=hidden, + name="dis_hidden2", + size=hidden_dim, + bias_attr=bias_attr, + param_attr=param_attr, + act=LinearActivation()) + + hidden_bn = batch_norm_layer( + hidden2, + act=ReluActivation(), + name="dis_hidden_bn", + bias_attr=bias_attr, + param_attr=ParamAttr( + is_static=is_generator_training, initial_mean=1.0, + initial_std=0.02), + use_global_stats=False) + + return fc_layer( + input=hidden_bn, + name="dis_prob", + size=2, + bias_attr=bias_attr, + param_attr=param_attr, + act=SoftmaxActivation()) + def generator(noise): """ generator generates a sample given noise """ param_attr = ParamAttr(is_static=is_discriminator_training) - bias_attr = ParamAttr(is_static=is_discriminator_training, - initial_mean=1.0, - initial_std=0) - - hidden = fc_layer(input=noise, - name="gen_layer_hidden", - size=hidden_dim, - bias_attr=bias_attr, - param_attr=param_attr, - act=ReluActivation()) - - hidden2 = fc_layer(input=hidden, name="gen_hidden2", size=hidden_dim, - bias_attr=bias_attr, - param_attr=param_attr, - act=LinearActivation()) - - hidden_bn = batch_norm_layer(hidden2, - act=ReluActivation(), - name="gen_layer_hidden_bn", - bias_attr=bias_attr, - param_attr=ParamAttr(is_static=is_discriminator_training, - initial_mean=1.0, - initial_std=0.02), - use_global_stats=False) - - return fc_layer(input=hidden_bn, - name="gen_layer1", - size=sample_dim, - bias_attr=bias_attr, - param_attr=param_attr, - act=LinearActivation()) + bias_attr = ParamAttr( + is_static=is_discriminator_training, initial_mean=1.0, initial_std=0) + + hidden = fc_layer( + input=noise, + name="gen_layer_hidden", + size=hidden_dim, + bias_attr=bias_attr, + param_attr=param_attr, + act=ReluActivation()) + + hidden2 = fc_layer( + input=hidden, + name="gen_hidden2", + size=hidden_dim, + bias_attr=bias_attr, + param_attr=param_attr, + act=LinearActivation()) + + hidden_bn = batch_norm_layer( + hidden2, + act=ReluActivation(), + name="gen_layer_hidden_bn", + bias_attr=bias_attr, + param_attr=ParamAttr( + is_static=is_discriminator_training, + initial_mean=1.0, + initial_std=0.02), + use_global_stats=False) + + return fc_layer( + input=hidden_bn, + name="gen_layer1", + size=sample_dim, + bias_attr=bias_attr, + param_attr=param_attr, + act=LinearActivation()) + if is_generator_training: noise = data_layer(name="noise", size=noise_dim) @@ -126,7 +142,8 @@ if is_generator_training or is_discriminator_training: label = data_layer(name="label", size=1) prob = discriminator(sample) cost = cross_entropy(input=prob, label=label) - classification_error_evaluator(input=prob, label=label, name=mode+'_error') + classification_error_evaluator( + input=prob, label=label, name=mode + '_error') outputs(cost) if is_generator: diff --git a/demo/gan/gan_conf_image.py b/demo/gan/gan_conf_image.py index dc5910e9f02d7aac59207fdaa0222d01ac3bf609..f89a4e706c3b7eeaa7858f54f8fa04a5e038b66e 100644 --- a/demo/gan/gan_conf_image.py +++ b/demo/gan/gan_conf_image.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,10 +15,9 @@ from paddle.trainer_config_helpers import * mode = get_config_arg("mode", str, "generator") dataSource = get_config_arg("data", str, "mnist") -assert mode in set(["generator", - "discriminator", - "generator_training", - "discriminator_training"]) +assert mode in set([ + "generator", "discriminator", "generator_training", "discriminator_training" +]) is_generator_training = mode == "generator_training" is_discriminator_training = mode == "discriminator_training" @@ -36,24 +35,33 @@ noise_dim = 100 gf_dim = 64 df_dim = 64 if dataSource == "mnist": - sample_dim = 28 # image dim - c_dim = 1 # image color + sample_dim = 28 # image dim + c_dim = 1 # image color else: sample_dim = 32 c_dim = 3 -s2, s4 = int(sample_dim/2), int(sample_dim/4), -s8, s16 = int(sample_dim/8), int(sample_dim/16) +s2, s4 = int(sample_dim / 2), int(sample_dim / 4), +s8, s16 = int(sample_dim / 8), int(sample_dim / 16) settings( batch_size=128, learning_rate=2e-4, - learning_method=AdamOptimizer(beta1=0.5) -) + learning_method=AdamOptimizer(beta1=0.5)) -def conv_bn(input, channels, imgSize, num_filters, output_x, stride, name, - param_attr, bias_attr, param_attr_bn, bn, trans=False, - act=ReluActivation()): - + +def conv_bn(input, + channels, + imgSize, + num_filters, + output_x, + stride, + name, + param_attr, + bias_attr, + param_attr_bn, + bn, + trans=False, + act=ReluActivation()): """ conv_bn is a utility function that constructs a convolution/deconv layer with an optional batch_norm layer @@ -63,10 +71,10 @@ def conv_bn(input, channels, imgSize, num_filters, output_x, stride, name, :param trans: whether to use conv (False) or deconv (True) :type trans: bool """ - + # calculate the filter_size and padding size based on the given # imgSize and ouput size - tmp = imgSize - (output_x - 1) * stride + tmp = imgSize - (output_x - 1) * stride if tmp <= 1 or tmp > 5: raise ValueError("conv input-output dimension does not fit") elif tmp <= 3: @@ -76,111 +84,134 @@ def conv_bn(input, channels, imgSize, num_filters, output_x, stride, name, filter_size = tmp padding = 0 - print (imgSize, output_x, stride, filter_size, padding) - + print(imgSize, output_x, stride, filter_size, padding) + if trans: nameApx = "_conv" else: nameApx = "_convt" - + if bn: - conv = img_conv_layer(input, filter_size=filter_size, - num_filters=num_filters, - name=name + nameApx, num_channels=channels, - act=LinearActivation(), groups=1, stride=stride, - padding=padding, bias_attr=bias_attr, - param_attr=param_attr, shared_biases=True, layer_attr=None, - filter_size_y=None, stride_y=None, padding_y=None, - trans=trans) - - conv_bn = batch_norm_layer(conv, - act=act, - name=name + nameApx + "_bn", - bias_attr=bias_attr, - param_attr=param_attr_bn, - use_global_stats=False) - + conv = img_conv_layer( + input, + filter_size=filter_size, + num_filters=num_filters, + name=name + nameApx, + num_channels=channels, + act=LinearActivation(), + groups=1, + stride=stride, + padding=padding, + bias_attr=bias_attr, + param_attr=param_attr, + shared_biases=True, + layer_attr=None, + filter_size_y=None, + stride_y=None, + padding_y=None, + trans=trans) + + conv_bn = batch_norm_layer( + conv, + act=act, + name=name + nameApx + "_bn", + bias_attr=bias_attr, + param_attr=param_attr_bn, + use_global_stats=False) + return conv_bn else: - conv = img_conv_layer(input, filter_size=filter_size, - num_filters=num_filters, - name=name + nameApx, num_channels=channels, - act=act, groups=1, stride=stride, - padding=padding, bias_attr=bias_attr, - param_attr=param_attr, shared_biases=True, layer_attr=None, - filter_size_y=None, stride_y=None, padding_y=None, - trans=trans) + conv = img_conv_layer( + input, + filter_size=filter_size, + num_filters=num_filters, + name=name + nameApx, + num_channels=channels, + act=act, + groups=1, + stride=stride, + padding=padding, + bias_attr=bias_attr, + param_attr=param_attr, + shared_biases=True, + layer_attr=None, + filter_size_y=None, + stride_y=None, + padding_y=None, + trans=trans) return conv - + + def generator(noise): """ generator generates a sample given noise """ - param_attr = ParamAttr(is_static=is_discriminator_training, - initial_mean=0.0, - initial_std=0.02) - bias_attr = ParamAttr(is_static=is_discriminator_training, - initial_mean=0.0, - initial_std=0.0) - - param_attr_bn=ParamAttr(is_static=is_discriminator_training, - initial_mean=1.0, - initial_std=0.02) - - h1 = fc_layer(input=noise, - name="gen_layer_h1", - size=s8 * s8 * gf_dim * 4, - bias_attr=bias_attr, - param_attr=param_attr, - act=LinearActivation()) - - h1_bn = batch_norm_layer(h1, - act=ReluActivation(), - name="gen_layer_h1_bn", - bias_attr=bias_attr, - param_attr=param_attr_bn, - use_global_stats=False) - - h2_bn = conv_bn(h1_bn, - channels=gf_dim*4, - output_x=s8, - num_filters=gf_dim*2, - imgSize=s4, - stride=2, - name="gen_layer_h2", - param_attr=param_attr, - bias_attr=bias_attr, - param_attr_bn=param_attr_bn, - bn=True, - trans=True) - - h3_bn = conv_bn(h2_bn, - channels=gf_dim*2, - output_x=s4, - num_filters=gf_dim, - imgSize=s2, - stride=2, - name="gen_layer_h3", - param_attr=param_attr, - bias_attr=bias_attr, - param_attr_bn=param_attr_bn, - bn=True, - trans=True) - - - return conv_bn(h3_bn, - channels=gf_dim, - output_x=s2, - num_filters=c_dim, - imgSize=sample_dim, - stride=2, - name="gen_layer_h4", - param_attr=param_attr, - bias_attr=bias_attr, - param_attr_bn=param_attr_bn, - bn=False, - trans=True, - act=TanhActivation()) + param_attr = ParamAttr( + is_static=is_discriminator_training, initial_mean=0.0, initial_std=0.02) + bias_attr = ParamAttr( + is_static=is_discriminator_training, initial_mean=0.0, initial_std=0.0) + + param_attr_bn = ParamAttr( + is_static=is_discriminator_training, initial_mean=1.0, initial_std=0.02) + + h1 = fc_layer( + input=noise, + name="gen_layer_h1", + size=s8 * s8 * gf_dim * 4, + bias_attr=bias_attr, + param_attr=param_attr, + act=LinearActivation()) + + h1_bn = batch_norm_layer( + h1, + act=ReluActivation(), + name="gen_layer_h1_bn", + bias_attr=bias_attr, + param_attr=param_attr_bn, + use_global_stats=False) + + h2_bn = conv_bn( + h1_bn, + channels=gf_dim * 4, + output_x=s8, + num_filters=gf_dim * 2, + imgSize=s4, + stride=2, + name="gen_layer_h2", + param_attr=param_attr, + bias_attr=bias_attr, + param_attr_bn=param_attr_bn, + bn=True, + trans=True) + + h3_bn = conv_bn( + h2_bn, + channels=gf_dim * 2, + output_x=s4, + num_filters=gf_dim, + imgSize=s2, + stride=2, + name="gen_layer_h3", + param_attr=param_attr, + bias_attr=bias_attr, + param_attr_bn=param_attr_bn, + bn=True, + trans=True) + + return conv_bn( + h3_bn, + channels=gf_dim, + output_x=s2, + num_filters=c_dim, + imgSize=sample_dim, + stride=2, + name="gen_layer_h4", + param_attr=param_attr, + bias_attr=bias_attr, + param_attr_bn=param_attr_bn, + bn=False, + trans=True, + act=TanhActivation()) def discriminator(sample): @@ -191,58 +222,60 @@ def discriminator(sample): of the sample is from generator and dimension 1 is the probabblity of the sample is from real data. """ - param_attr = ParamAttr(is_static=is_generator_training, - initial_mean=0.0, - initial_std=0.02) - bias_attr = ParamAttr(is_static=is_generator_training, - initial_mean=0.0, - initial_std=0.0) - - param_attr_bn=ParamAttr(is_static=is_generator_training, - initial_mean=1.0, - initial_std=0.02) - - h0 = conv_bn(sample, - channels=c_dim, - imgSize=sample_dim, - num_filters=df_dim, - output_x=s2, - stride=2, - name="dis_h0", - param_attr=param_attr, - bias_attr=bias_attr, - param_attr_bn=param_attr_bn, - bn=False) - - h1_bn = conv_bn(h0, - channels=df_dim, - imgSize=s2, - num_filters=df_dim*2, - output_x=s4, - stride=2, - name="dis_h1", - param_attr=param_attr, - bias_attr=bias_attr, - param_attr_bn=param_attr_bn, - bn=True) - - h2_bn = conv_bn(h1_bn, - channels=df_dim*2, - imgSize=s4, - num_filters=df_dim*4, - output_x=s8, - stride=2, - name="dis_h2", - param_attr=param_attr, - bias_attr=bias_attr, - param_attr_bn=param_attr_bn, - bn=True) - - return fc_layer(input=h2_bn, name="dis_prob", size=2, - bias_attr=bias_attr, - param_attr=param_attr, - act=SoftmaxActivation()) + param_attr = ParamAttr( + is_static=is_generator_training, initial_mean=0.0, initial_std=0.02) + bias_attr = ParamAttr( + is_static=is_generator_training, initial_mean=0.0, initial_std=0.0) + + param_attr_bn = ParamAttr( + is_static=is_generator_training, initial_mean=1.0, initial_std=0.02) + + h0 = conv_bn( + sample, + channels=c_dim, + imgSize=sample_dim, + num_filters=df_dim, + output_x=s2, + stride=2, + name="dis_h0", + param_attr=param_attr, + bias_attr=bias_attr, + param_attr_bn=param_attr_bn, + bn=False) + + h1_bn = conv_bn( + h0, + channels=df_dim, + imgSize=s2, + num_filters=df_dim * 2, + output_x=s4, + stride=2, + name="dis_h1", + param_attr=param_attr, + bias_attr=bias_attr, + param_attr_bn=param_attr_bn, + bn=True) + + h2_bn = conv_bn( + h1_bn, + channels=df_dim * 2, + imgSize=s4, + num_filters=df_dim * 4, + output_x=s8, + stride=2, + name="dis_h2", + param_attr=param_attr, + bias_attr=bias_attr, + param_attr_bn=param_attr_bn, + bn=True) + return fc_layer( + input=h2_bn, + name="dis_prob", + size=2, + bias_attr=bias_attr, + param_attr=param_attr, + act=SoftmaxActivation()) if is_generator_training: @@ -250,13 +283,14 @@ if is_generator_training: sample = generator(noise) if is_discriminator_training: - sample = data_layer(name="sample", size=sample_dim * sample_dim*c_dim) + sample = data_layer(name="sample", size=sample_dim * sample_dim * c_dim) if is_generator_training or is_discriminator_training: label = data_layer(name="label", size=1) prob = discriminator(sample) cost = cross_entropy(input=prob, label=label) - classification_error_evaluator(input=prob, label=label, name=mode+'_error') + classification_error_evaluator( + input=prob, label=label, name=mode + '_error') outputs(cost) if is_generator: diff --git a/demo/gan/gan_trainer.py b/demo/gan/gan_trainer.py index 72699952b961cb5bf6ac14dd65eee1aeab5e2a7c..4a26c230f7a21cc6dd4a3cdb52e32730b1ce73ca 100644 --- a/demo/gan/gan_trainer.py +++ b/demo/gan/gan_trainer.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ import argparse import random import numpy import cPickle -import sys,os +import sys, os from PIL import Image from paddle.trainer.config_parser import parse_config @@ -24,6 +24,7 @@ from paddle.trainer.config_parser import logger import py_paddle.swig_paddle as api import matplotlib.pyplot as plt + def plot2DScatter(data, outputfile): ''' Plot the data as a 2D scatter plot and save to outputfile @@ -41,9 +42,11 @@ def plot2DScatter(data, outputfile): plt.scatter(x, y) plt.savefig(outputfile, bbox_inches='tight') + def CHECK_EQ(a, b): assert a == b, "a=%s, b=%s" % (a, b) + def copy_shared_parameters(src, dst): ''' copy the parameters from src to dst @@ -52,11 +55,9 @@ def copy_shared_parameters(src, dst): :param dst: the destination of the parameters :type dst: GradientMachine ''' - src_params = [src.getParameter(i) - for i in xrange(src.getParameterSize())] + src_params = [src.getParameter(i) for i in xrange(src.getParameterSize())] src_params = dict([(p.getName(), p) for p in src_params]) - for i in xrange(dst.getParameterSize()): dst_param = dst.getParameter(i) src_param = src_params.get(dst_param.getName(), None) @@ -67,15 +68,17 @@ def copy_shared_parameters(src, dst): CHECK_EQ(len(src_value), len(dst_value)) dst_value.copyFrom(src_value) dst_param.setValueUpdated() - + + def print_parameters(src): - src_params = [src.getParameter(i) - for i in xrange(src.getParameterSize())] + src_params = [src.getParameter(i) for i in xrange(src.getParameterSize())] print "***************" for p in src_params: print "Name is %s" % p.getName() - print "value is %s \n" % p.getBuf(api.PARAMETER_VALUE).copyToNumpyArray() + print "value is %s \n" % p.getBuf(api.PARAMETER_VALUE).copyToNumpyArray( + ) + def load_mnist_data(imageFile): f = open(imageFile, "rb") @@ -86,33 +89,36 @@ def load_mnist_data(imageFile): n = 60000 else: n = 10000 - - data = numpy.fromfile(f, 'ubyte', count=n*28*28).reshape((n, 28*28)) + + data = numpy.fromfile(f, 'ubyte', count=n * 28 * 28).reshape((n, 28 * 28)) data = data / 255.0 * 2.0 - 1.0 f.close() return data.astype('float32') + def load_cifar_data(cifar_path): batch_size = 10000 - data = numpy.zeros((5*batch_size, 32*32*3), dtype = "float32") + data = numpy.zeros((5 * batch_size, 32 * 32 * 3), dtype="float32") for i in range(1, 6): file = cifar_path + "/data_batch_" + str(i) fo = open(file, 'rb') dict = cPickle.load(fo) fo.close() - data[(i - 1)*batch_size:(i*batch_size), :] = dict["data"] - + data[(i - 1) * batch_size:(i * batch_size), :] = dict["data"] + data = data / 255.0 * 2.0 - 1.0 return data + # synthesize 2-D uniform data def load_uniform_data(): data = numpy.random.rand(1000000, 2).astype('float32') return data + def merge(images, size): - if images.shape[1] == 28*28: + if images.shape[1] == 28 * 28: h, w, c = 28, 28, 1 else: h, w, c = 32, 32, 3 @@ -124,6 +130,7 @@ def merge(images, size): ((images[idx, :].reshape((h, w, c), order="F").transpose(1, 0, 2) + 1.0) / 2.0 * 255.0) return img.astype('uint8') + def save_images(images, path): merged_img = merge(images, [8, 8]) if merged_img.shape[2] == 1: @@ -131,14 +138,17 @@ def save_images(images, path): else: im = Image.fromarray(merged_img, mode="RGB") im.save(path) - + + def get_real_samples(batch_size, data_np): - return data_np[numpy.random.choice(data_np.shape[0], batch_size, - replace=False),:] - + return data_np[numpy.random.choice( + data_np.shape[0], batch_size, replace=False), :] + + def get_noise(batch_size, noise_dim): return numpy.random.normal(size=(batch_size, noise_dim)).astype('float32') + def get_fake_samples(generator_machine, batch_size, noise): gen_inputs = api.Arguments.createArguments(1) gen_inputs.setSlotValue(0, api.Matrix.createDenseFromNumpy(noise)) @@ -147,12 +157,14 @@ def get_fake_samples(generator_machine, batch_size, noise): fake_samples = gen_outputs.getSlotValue(0).copyToNumpyMat() return fake_samples + def get_training_loss(training_machine, inputs): outputs = api.Arguments.createArguments(0) training_machine.forward(inputs, outputs, api.PASS_TEST) loss = outputs.getSlotValue(0).copyToNumpyMat() return numpy.mean(loss) + def prepare_discriminator_data_batch_pos(batch_size, data_np): real_samples = get_real_samples(batch_size, data_np) labels = numpy.ones(batch_size, dtype='int32') @@ -161,6 +173,7 @@ def prepare_discriminator_data_batch_pos(batch_size, data_np): inputs.setSlotIds(1, api.IVector.createVectorFromNumpy(labels)) return inputs + def prepare_discriminator_data_batch_neg(generator_machine, batch_size, noise): fake_samples = get_fake_samples(generator_machine, batch_size, noise) labels = numpy.zeros(batch_size, dtype='int32') @@ -169,6 +182,7 @@ def prepare_discriminator_data_batch_neg(generator_machine, batch_size, noise): inputs.setSlotIds(1, api.IVector.createVectorFromNumpy(labels)) return inputs + def prepare_generator_data_batch(batch_size, noise): label = numpy.ones(batch_size, dtype='int32') inputs = api.Arguments.createArguments(2) @@ -193,10 +207,9 @@ def get_layer_size(model_conf, layer_name): def main(): parser = argparse.ArgumentParser() parser.add_argument("-d", "--data_source", help="mnist or cifar or uniform") - parser.add_argument("--use_gpu", default="1", - help="1 means use gpu for training") - parser.add_argument("--gpu_id", default="0", - help="the gpu_id parameter") + parser.add_argument( + "--use_gpu", default="1", help="1 means use gpu for training") + parser.add_argument("--gpu_id", default="0", help="the gpu_id parameter") args = parser.parse_args() data_source = args.data_source use_gpu = args.use_gpu @@ -208,30 +221,32 @@ def main(): if not os.path.exists("./%s_params/" % data_source): os.makedirs("./%s_params/" % data_source) - - api.initPaddle('--use_gpu=' + use_gpu, '--dot_period=10', '--log_period=100', - '--gpu_id=' + args.gpu_id, '--save_dir=' + "./%s_params/" % data_source) - + + api.initPaddle('--use_gpu=' + use_gpu, '--dot_period=10', + '--log_period=100', '--gpu_id=' + args.gpu_id, + '--save_dir=' + "./%s_params/" % data_source) + if data_source == "uniform": conf = "gan_conf.py" num_iter = 10000 else: conf = "gan_conf_image.py" num_iter = 1000 - + gen_conf = parse_config(conf, "mode=generator_training,data=" + data_source) - dis_conf = parse_config(conf, "mode=discriminator_training,data=" + data_source) + dis_conf = parse_config(conf, + "mode=discriminator_training,data=" + data_source) generator_conf = parse_config(conf, "mode=generator,data=" + data_source) batch_size = dis_conf.opt_config.batch_size noise_dim = get_layer_size(gen_conf.model_config, "noise") - + if data_source == "mnist": data_np = load_mnist_data("./data/mnist_data/train-images-idx3-ubyte") elif data_source == "cifar": data_np = load_cifar_data("./data/cifar-10-batches-py/") else: data_np = load_uniform_data() - + # this creates a gradient machine for discriminator dis_training_machine = api.GradientMachine.createFromConfigProto( dis_conf.model_config) @@ -244,26 +259,24 @@ def main(): logger.info(str(generator_conf.model_config)) generator_machine = api.GradientMachine.createFromConfigProto( generator_conf.model_config) - - dis_trainer = api.Trainer.create( - dis_conf, dis_training_machine) - gen_trainer = api.Trainer.create( - gen_conf, gen_training_machine) - + dis_trainer = api.Trainer.create(dis_conf, dis_training_machine) + + gen_trainer = api.Trainer.create(gen_conf, gen_training_machine) + dis_trainer.startTrain() gen_trainer.startTrain() - + # Sync parameters between networks (GradientMachine) at the beginning copy_shared_parameters(gen_training_machine, dis_training_machine) copy_shared_parameters(gen_training_machine, generator_machine) - + # constrain that either discriminator or generator can not be trained # consecutively more than MAX_strike times curr_train = "dis" curr_strike = 0 MAX_strike = 5 - + for train_pass in xrange(100): dis_trainer.startTrainPass() gen_trainer.startTrainPass() @@ -272,23 +285,25 @@ def main(): noise = get_noise(batch_size, noise_dim) data_batch_dis_pos = prepare_discriminator_data_batch_pos( batch_size, data_np) - dis_loss_pos = get_training_loss(dis_training_machine, data_batch_dis_pos) - + dis_loss_pos = get_training_loss(dis_training_machine, + data_batch_dis_pos) + data_batch_dis_neg = prepare_discriminator_data_batch_neg( generator_machine, batch_size, noise) - dis_loss_neg = get_training_loss(dis_training_machine, data_batch_dis_neg) - + dis_loss_neg = get_training_loss(dis_training_machine, + data_batch_dis_neg) + dis_loss = (dis_loss_pos + dis_loss_neg) / 2.0 - + # Do forward pass in generator to get the gen_loss - data_batch_gen = prepare_generator_data_batch( - batch_size, noise) + data_batch_gen = prepare_generator_data_batch(batch_size, noise) gen_loss = get_training_loss(gen_training_machine, data_batch_gen) - + if i % 100 == 0: - print "d_pos_loss is %s d_neg_loss is %s" % (dis_loss_pos, dis_loss_neg) + print "d_pos_loss is %s d_neg_loss is %s" % (dis_loss_pos, + dis_loss_neg) print "d_loss is %s g_loss is %s" % (dis_loss, gen_loss) - + # Decide which network to train based on the training history # And the relative size of the loss if (not (curr_train == "dis" and curr_strike == MAX_strike)) and \ @@ -297,11 +312,12 @@ def main(): curr_strike += 1 else: curr_train = "dis" - curr_strike = 1 + curr_strike = 1 dis_trainer.trainOneDataBatch(batch_size, data_batch_dis_neg) - dis_trainer.trainOneDataBatch(batch_size, data_batch_dis_pos) - copy_shared_parameters(dis_training_machine, gen_training_machine) - + dis_trainer.trainOneDataBatch(batch_size, data_batch_dis_pos) + copy_shared_parameters(dis_training_machine, + gen_training_machine) + else: if curr_train == "gen": curr_strike += 1 @@ -311,19 +327,23 @@ def main(): gen_trainer.trainOneDataBatch(batch_size, data_batch_gen) # TODO: add API for paddle to allow true parameter sharing between different GradientMachines # so that we do not need to copy shared parameters. - copy_shared_parameters(gen_training_machine, dis_training_machine) + copy_shared_parameters(gen_training_machine, + dis_training_machine) copy_shared_parameters(gen_training_machine, generator_machine) - + dis_trainer.finishTrainPass() gen_trainer.finishTrainPass() # At the end of each pass, save the generated samples/images fake_samples = get_fake_samples(generator_machine, batch_size, noise) if data_source == "uniform": - plot2DScatter(fake_samples, "./%s_samples/train_pass%s.png" % (data_source, train_pass)) + plot2DScatter(fake_samples, "./%s_samples/train_pass%s.png" % + (data_source, train_pass)) else: - save_images(fake_samples, "./%s_samples/train_pass%s.png" % (data_source, train_pass)) + save_images(fake_samples, "./%s_samples/train_pass%s.png" % + (data_source, train_pass)) dis_trainer.finishTrain() gen_trainer.finishTrain() + if __name__ == '__main__': main() diff --git a/demo/image_classification/data/download_cifar.sh b/demo/image_classification/data/download_cifar.sh index ca9b0b5c9052548d73037e0434bf47d0c8347787..52e82d0d9812c88e5c85cffc0585e3425b862809 100755 --- a/demo/image_classification/data/download_cifar.sh +++ b/demo/image_classification/data/download_cifar.sh @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/image_classification/data/process_cifar.py b/demo/image_classification/data/process_cifar.py index b235010e4ece377beffaaa1b9247a77d7a96b712..db6666189e5b8008a6b66fb64afcdf98980e72bb 100644 --- a/demo/image_classification/data/process_cifar.py +++ b/demo/image_classification/data/process_cifar.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/image_classification/image_provider.py b/demo/image_classification/image_provider.py index 28bf1bb02c1f08b2e8ec9acd38f0a8594b05ab66..87eed5eebd7680e578c822083efb8b9eab16b266 100644 --- a/demo/image_classification/image_provider.py +++ b/demo/image_classification/image_provider.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/image_classification/image_util.py b/demo/image_classification/image_util.py index b5c6431c06f77cef5c31ca844a8427eebaea2fce..f09605394a19e09d92e555eeefb0b5646625b618 100644 --- a/demo/image_classification/image_util.py +++ b/demo/image_classification/image_util.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/image_classification/predict.sh b/demo/image_classification/predict.sh index 35ffae6c8cdc90bc9d71b35e05a5717ff7ba4970..9d5785c9a1a4dac12f7940fa708b1a79c6ec8a93 100755 --- a/demo/image_classification/predict.sh +++ b/demo/image_classification/predict.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/image_classification/prediction.py b/demo/image_classification/prediction.py index 6a47bd5851c99635dd7d3f1d5df67dd081ca4584..9a86aafcb2fa4d4354d1dd9443c1b73ddcda980b 100755 --- a/demo/image_classification/prediction.py +++ b/demo/image_classification/prediction.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/image_classification/preprocess.py b/demo/image_classification/preprocess.py index 10b9c1691b5e51273c73a975545cd36f3822e901..2947ad239c36f9a02ed67ccf5906380cb70e37ce 100755 --- a/demo/image_classification/preprocess.py +++ b/demo/image_classification/preprocess.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/image_classification/preprocess.sh b/demo/image_classification/preprocess.sh index e3e86ff10675c0622867af2eb0d26c87f4bc2db5..c7396c6393599ef3f2c55089eb05f2435b2b4b82 100755 --- a/demo/image_classification/preprocess.sh +++ b/demo/image_classification/preprocess.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/image_classification/train.sh b/demo/image_classification/train.sh index db0a057bf35b4ad04a08a1e3f1fad3bd6a486350..6fc11caf1c75192242482c2e85f8167eb9fba4ec 100755 --- a/demo/image_classification/train.sh +++ b/demo/image_classification/train.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/image_classification/vgg_16_cifar.py b/demo/image_classification/vgg_16_cifar.py index 58ceff5fc2f46cac9997b6d8af2b0db0c43e0c75..8ee4a64c15f885023a6e19812885b4f76bb12af9 100755 --- a/demo/image_classification/vgg_16_cifar.py +++ b/demo/image_classification/vgg_16_cifar.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/introduction/dataprovider.py b/demo/introduction/dataprovider.py index 8515022e18dc6bbf055e6db3121568acf1df1c55..03c920cc34b397643e97ad41cf06458245c7ca7b 100644 --- a/demo/introduction/dataprovider.py +++ b/demo/introduction/dataprovider.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/introduction/evaluate_model.py b/demo/introduction/evaluate_model.py index ca4a1872731abde90e72cb167929b3d9e2e1ebf4..eeda43c5c86f3e49f758bf55b16a68387e64238c 100755 --- a/demo/introduction/evaluate_model.py +++ b/demo/introduction/evaluate_model.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: UTF-8 -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/introduction/train.sh b/demo/introduction/train.sh index 06db8edd105ada071597ed1aa5e42f7de547174d..b7bbb90ddd287e3e312a490b53924ae76fb20d2c 100755 --- a/demo/introduction/train.sh +++ b/demo/introduction/train.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/introduction/trainer_config.py b/demo/introduction/trainer_config.py index 7c838c1a8f5b3cb6ac732197c85cd7c728eb013f..41cebcf6e146e55efb89c2ceea429fa003ff206e 100644 --- a/demo/introduction/trainer_config.py +++ b/demo/introduction/trainer_config.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/mnist/data/generate_list.py b/demo/mnist/data/generate_list.py index d880721f94c68bbbc1740f82872462efdb368fa2..49981cc7a93308bc96ad5097eba749440e958525 100644 --- a/demo/mnist/data/generate_list.py +++ b/demo/mnist/data/generate_list.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/mnist/train.sh b/demo/mnist/train.sh index 084b32ac390b847379fd0e5e6a5fd33714730ec4..da90cd749a02976633d0f0d6e4352d8a85c7cdef 100755 --- a/demo/mnist/train.sh +++ b/demo/mnist/train.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/mnist/vgg_16_mnist.py b/demo/mnist/vgg_16_mnist.py index f9e89bc588abacd98a8f5fc82a00fae6bb2de10e..a819b391c690fb473801eb2e7ba3161cc31b5b4b 100644 --- a/demo/mnist/vgg_16_mnist.py +++ b/demo/mnist/vgg_16_mnist.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/model_zoo/embedding/extract_para.py b/demo/model_zoo/embedding/extract_para.py index 47e06fae9caa9c3d9e0d6eb2e3f6633a776c5b1d..570b90c1f772c8f6abfc6cda02560fd3471ef0b6 100755 --- a/demo/model_zoo/embedding/extract_para.py +++ b/demo/model_zoo/embedding/extract_para.py @@ -1,5 +1,5 @@ #!/bin/env python -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/model_zoo/embedding/paraconvert.py b/demo/model_zoo/embedding/paraconvert.py index 54155eff8e26b16ff5303d8d279e81b4bf8a90f4..ce7a70efc43d7f85708f1e12bb94739f3588370c 100755 --- a/demo/model_zoo/embedding/paraconvert.py +++ b/demo/model_zoo/embedding/paraconvert.py @@ -1,5 +1,5 @@ #!/bin/env python -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/model_zoo/embedding/pre_DictAndModel.sh b/demo/model_zoo/embedding/pre_DictAndModel.sh index 6d647f5dd9368eaf81c19386511c7d231e4799e3..f97ef2610734449c88fdfca6216b1cab57472b84 100755 --- a/demo/model_zoo/embedding/pre_DictAndModel.sh +++ b/demo/model_zoo/embedding/pre_DictAndModel.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/model_zoo/resnet/classify.py b/demo/model_zoo/resnet/classify.py index 7855126edcfec20de251e5bc08c08c7aab8f7a8e..4631816c43ef48839df1863a0a86c3ab00924d3f 100755 --- a/demo/model_zoo/resnet/classify.py +++ b/demo/model_zoo/resnet/classify.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/model_zoo/resnet/example/__init__.py b/demo/model_zoo/resnet/example/__init__.py index c90af2ee000d46a032984ee23559e7e99b49ddad..f662d6826321eb840739382558f76327d27b5847 100644 --- a/demo/model_zoo/resnet/example/__init__.py +++ b/demo/model_zoo/resnet/example/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/model_zoo/resnet/example/image_list_provider.py b/demo/model_zoo/resnet/example/image_list_provider.py index 9e415f76a53326c5809b7a8c508701c519ab443b..2cd8eb8bf850f41282ed5db2885dc0b7218c79f7 100644 --- a/demo/model_zoo/resnet/example/image_list_provider.py +++ b/demo/model_zoo/resnet/example/image_list_provider.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/model_zoo/resnet/extract_fea_c++.sh b/demo/model_zoo/resnet/extract_fea_c++.sh index c7f9aea9a57df5f9021d6cb3743967dcc9aa3e5f..5447aa92dfb5facd3433eb4a1893e96e3c786c73 100755 --- a/demo/model_zoo/resnet/extract_fea_c++.sh +++ b/demo/model_zoo/resnet/extract_fea_c++.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/model_zoo/resnet/extract_fea_py.sh b/demo/model_zoo/resnet/extract_fea_py.sh index a70cef9a87e9337a4dacd4a98fb1e2cf53004221..2e87152f7f8598f487870291271cdee646105044 100755 --- a/demo/model_zoo/resnet/extract_fea_py.sh +++ b/demo/model_zoo/resnet/extract_fea_py.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/model_zoo/resnet/get_model.sh b/demo/model_zoo/resnet/get_model.sh index 133d08fca431540f2ed5cd6e63b51d9ce3a1b344..b33d8178ab7859fc0b0d514fb19bec2c28a77c3d 100755 --- a/demo/model_zoo/resnet/get_model.sh +++ b/demo/model_zoo/resnet/get_model.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/model_zoo/resnet/load_feature.py b/demo/model_zoo/resnet/load_feature.py index b0948b75fd0ac9a3fa89070aed04d523ce286f4e..5d3d0c0d30ef710c37c98e93a51b2f813d636b59 100644 --- a/demo/model_zoo/resnet/load_feature.py +++ b/demo/model_zoo/resnet/load_feature.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/model_zoo/resnet/net_diagram.sh b/demo/model_zoo/resnet/net_diagram.sh index a21ab4345bfb31e5586cb07625b44e34ec1f7ec6..1b06ffa44eec8a0f312420c35699d3902f9a6400 100755 --- a/demo/model_zoo/resnet/net_diagram.sh +++ b/demo/model_zoo/resnet/net_diagram.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/model_zoo/resnet/predict.sh b/demo/model_zoo/resnet/predict.sh index 55cf16e34a759c3538ef4216fcb7e724ffd83b9f..2b67b17c48c60cc8a7b7c46a1c80a3f2bf281870 100755 --- a/demo/model_zoo/resnet/predict.sh +++ b/demo/model_zoo/resnet/predict.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/model_zoo/resnet/resnet.py b/demo/model_zoo/resnet/resnet.py index 015b74cd484596039b9fcf010576ca340d044db7..6fdd97fefc62392c93ecffae0fc918e8dc4b18c5 100644 --- a/demo/model_zoo/resnet/resnet.py +++ b/demo/model_zoo/resnet/resnet.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/quick_start/api_train.py b/demo/quick_start/api_train.py index 66cbb856484d231613a0026be129a7bc3a7cfdf5..5699789daa4051661b0a72c69f4668f2d8bb9cb2 100644 --- a/demo/quick_start/api_train.py +++ b/demo/quick_start/api_train.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/quick_start/api_train.sh b/demo/quick_start/api_train.sh index 40e9d0a09aaa6b672d6b3997c67c07a5e8a8c3d8..9b2a4e2f224b1677c458ede66a6a3bac09d8ad61 100755 --- a/demo/quick_start/api_train.sh +++ b/demo/quick_start/api_train.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/quick_start/data/get_data.sh b/demo/quick_start/data/get_data.sh index 952de3f3c8f52a7a6f84412f9b38f16ac2503ac2..a09a18f919e5a84f1f7c889a43f0a5fbf4a60a77 100755 --- a/demo/quick_start/data/get_data.sh +++ b/demo/quick_start/data/get_data.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/quick_start/data/proc_from_raw_data/get_data.sh b/demo/quick_start/data/proc_from_raw_data/get_data.sh index cd85e26842dfccea78e4f26bdfee938887021f03..d976eaebfaa600778e0ab6bb0adbd7159f1cce2f 100755 --- a/demo/quick_start/data/proc_from_raw_data/get_data.sh +++ b/demo/quick_start/data/proc_from_raw_data/get_data.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/quick_start/data/proc_from_raw_data/preprocess.py b/demo/quick_start/data/proc_from_raw_data/preprocess.py index 56c2c5f16ceb63ff88fa51ed78c2e77ea5b64592..72bd95f21d8bde8b3d1962ea10ecf6fc7d0ea478 100755 --- a/demo/quick_start/data/proc_from_raw_data/preprocess.py +++ b/demo/quick_start/data/proc_from_raw_data/preprocess.py @@ -1,6 +1,6 @@ # -*- coding: UTF-8 -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/quick_start/dataprovider_bow.py b/demo/quick_start/dataprovider_bow.py index a5156a2d40cc04c02e50d676045ae6da8937ba01..8e651d77bf3fd3bbd990ef314456ec14bd77cfeb 100644 --- a/demo/quick_start/dataprovider_bow.py +++ b/demo/quick_start/dataprovider_bow.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/quick_start/dataprovider_emb.py b/demo/quick_start/dataprovider_emb.py index 286f3f5c82081f1a6e02a26023969790792a78a3..b010253a8a764ede4ff0416231ac6aa2fd8f94e3 100755 --- a/demo/quick_start/dataprovider_emb.py +++ b/demo/quick_start/dataprovider_emb.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/quick_start/predict.sh b/demo/quick_start/predict.sh index b1e5e44f0b644547d6573ef635084b555237bea6..f02e5038e92790c7f1ddcd84a09c6d9a02f84ac4 100755 --- a/demo/quick_start/predict.sh +++ b/demo/quick_start/predict.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/quick_start/train.sh b/demo/quick_start/train.sh index b3c471608c3248bfc714d5e44dd927f25dd23ea0..e3595fce7519297058e1eeb66487692267ddcfcc 100755 --- a/demo/quick_start/train.sh +++ b/demo/quick_start/train.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/quick_start/trainer_config.bidi-lstm.py b/demo/quick_start/trainer_config.bidi-lstm.py index 51deaf31f94681b6b61f98f798cef14a65ec92cb..ca1d1f8d099b5a3f5276c108855c5e890e7214fe 100644 --- a/demo/quick_start/trainer_config.bidi-lstm.py +++ b/demo/quick_start/trainer_config.bidi-lstm.py @@ -1,6 +1,6 @@ # edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/quick_start/trainer_config.cnn.py b/demo/quick_start/trainer_config.cnn.py index 388efa75f903e0c7c803c99cd50d73a004133a67..f8c3d511f323ed9ec96be0a1951014c6db639003 100644 --- a/demo/quick_start/trainer_config.cnn.py +++ b/demo/quick_start/trainer_config.cnn.py @@ -1,6 +1,6 @@ # edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/quick_start/trainer_config.db-lstm.py b/demo/quick_start/trainer_config.db-lstm.py index 02bc898d881efbd3bfaed95d45cd9e70ed046746..fba802b4600b33cfbfd0820cce1f47e4d0f948ae 100644 --- a/demo/quick_start/trainer_config.db-lstm.py +++ b/demo/quick_start/trainer_config.db-lstm.py @@ -1,6 +1,6 @@ # edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/quick_start/trainer_config.emb.py b/demo/quick_start/trainer_config.emb.py index 8fd18a7aac704e62b137845edb46cce5bc373285..7410397ef656e363b232787995d3a869cd11b655 100644 --- a/demo/quick_start/trainer_config.emb.py +++ b/demo/quick_start/trainer_config.emb.py @@ -1,6 +1,6 @@ # edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/quick_start/trainer_config.lr.py b/demo/quick_start/trainer_config.lr.py index b9c9441baac28a8a8f6078065b75664819d6cd04..e5105aa89532d71c80c8ec77ca98ac6a8e9c8c58 100644 --- a/demo/quick_start/trainer_config.lr.py +++ b/demo/quick_start/trainer_config.lr.py @@ -1,6 +1,6 @@ # edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/quick_start/trainer_config.lstm.py b/demo/quick_start/trainer_config.lstm.py index 8821e02d9bd4a0d06b8afa99df8e0fac3e2fcefe..43b4ddac2dca5f6b9aa28f055e843abf12e92312 100644 --- a/demo/quick_start/trainer_config.lstm.py +++ b/demo/quick_start/trainer_config.lstm.py @@ -1,6 +1,6 @@ # edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/quick_start/trainer_config.resnet-lstm.py b/demo/quick_start/trainer_config.resnet-lstm.py index 91e1581c386eb880d481b7352c4d21f3a5ef5c9a..89a837abb7cdeaaa249160123e1f2001d23d7aa1 100644 --- a/demo/quick_start/trainer_config.resnet-lstm.py +++ b/demo/quick_start/trainer_config.resnet-lstm.py @@ -1,6 +1,6 @@ # edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,7 +13,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - """ This configuration is a demonstration of how to implement the stacked LSTM with residual connections, i.e. an LSTM layer takes the sum of the hidden states @@ -46,11 +45,12 @@ is_predict = get_config_arg('is_predict', bool, False) trn = 'data/train.list' if not is_predict else None tst = 'data/test.list' if not is_predict else 'data/pred.list' process = 'process' if not is_predict else 'process_predict' -define_py_data_sources2(train_list=trn, - test_list=tst, - module="dataprovider_emb", - obj=process, - args={"dictionary": word_dict}) +define_py_data_sources2( + train_list=trn, + test_list=tst, + module="dataprovider_emb", + obj=process, + args={"dictionary": word_dict}) batch_size = 128 if not is_predict else 1 settings( @@ -58,10 +58,9 @@ settings( learning_rate=2e-3, learning_method=AdamOptimizer(), regularization=L2Regularization(8e-4), - gradient_clipping_threshold=25 -) + gradient_clipping_threshold=25) -bias_attr = ParamAttr(initial_std=0.,l2_rate=0.) +bias_attr = ParamAttr(initial_std=0., l2_rate=0.) data = data_layer(name="word", size=len(word_dict)) emb = embedding_layer(input=data, size=128) @@ -73,17 +72,15 @@ for i in range(3): # The input to the current layer is the sum of the hidden state # and input of the previous layer. current_input = addto_layer(input=[previous_input, previous_hidden_state]) - hidden_state = simple_lstm(input=current_input, size=128, - lstm_cell_attr=ExtraAttr(drop_rate=0.1)) + hidden_state = simple_lstm( + input=current_input, size=128, lstm_cell_attr=ExtraAttr(drop_rate=0.1)) previous_input, previous_hidden_state = current_input, hidden_state lstm = previous_hidden_state lstm_last = pooling_layer(input=lstm, pooling_type=MaxPooling()) -output = fc_layer(input=lstm_last, size=2, - bias_attr=bias_attr, - act=SoftmaxActivation()) - +output = fc_layer( + input=lstm_last, size=2, bias_attr=bias_attr, act=SoftmaxActivation()) if is_predict: maxid = maxid_layer(output) diff --git a/demo/recommendation/common_utils.py b/demo/recommendation/common_utils.py index 613e36b496e47edbc0eabd8f15a0abdcb50f6424..d4fbdad1d7ac53b35d9478c65ab61c2d28845261 100755 --- a/demo/recommendation/common_utils.py +++ b/demo/recommendation/common_utils.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/recommendation/data/config_generator.py b/demo/recommendation/data/config_generator.py index fa605458300f81da6772d88cfbad413e4dcf97fe..4ca496a252dffc62ed62bb8f2a5ee1661a940580 100644 --- a/demo/recommendation/data/config_generator.py +++ b/demo/recommendation/data/config_generator.py @@ -1,5 +1,5 @@ #!/bin/env python2 -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/recommendation/data/meta_generator.py b/demo/recommendation/data/meta_generator.py index 593c863670d5eb5d684adf643ff745f3914b656b..38e4679d266c331a751114cd13f0e3453016cf26 100644 --- a/demo/recommendation/data/meta_generator.py +++ b/demo/recommendation/data/meta_generator.py @@ -1,5 +1,5 @@ #!/bin/env python2 -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/recommendation/data/ml_data.sh b/demo/recommendation/data/ml_data.sh index 408a8723e086d3c374c915623c85bffe0d939151..2268d876389e0bdf5ead405e74d278d276626f82 100755 --- a/demo/recommendation/data/ml_data.sh +++ b/demo/recommendation/data/ml_data.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/recommendation/data/split.py b/demo/recommendation/data/split.py index 8dd0cbd32af6074439e98dac024c5fed76cd52b2..be6869c22f04be1db0f8e9c35c73c851e4c490b0 100644 --- a/demo/recommendation/data/split.py +++ b/demo/recommendation/data/split.py @@ -1,5 +1,5 @@ #!/bin/env python2 -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/recommendation/dataprovider.py b/demo/recommendation/dataprovider.py index ff3932be03f1e4a1fc1d0bdb189ab7fe1fbbeca0..80c62d75612e544c5197f878a83284f8e08d1a99 100755 --- a/demo/recommendation/dataprovider.py +++ b/demo/recommendation/dataprovider.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/recommendation/evaluate.sh b/demo/recommendation/evaluate.sh index 38c1562c6370ddcda60ecdbbc2acf8d32635a4f4..02b2857de028bc9c05d7ddd67012043b671b2764 100755 --- a/demo/recommendation/evaluate.sh +++ b/demo/recommendation/evaluate.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/recommendation/prediction.py b/demo/recommendation/prediction.py index e2a202cfd1a476046d7e1d1896b87d72c4906ff2..191120188ef5dbddf4c42a1356a9fa46e16c5ca1 100755 --- a/demo/recommendation/prediction.py +++ b/demo/recommendation/prediction.py @@ -1,5 +1,5 @@ #!/bin/env python2 -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/recommendation/preprocess.sh b/demo/recommendation/preprocess.sh index e181d0be45558955935234c6ccb9eee1b3ce442f..e121e470193fa1e73c000fe612d6858e28f9261f 100755 --- a/demo/recommendation/preprocess.sh +++ b/demo/recommendation/preprocess.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/recommendation/run.sh b/demo/recommendation/run.sh index 846b59cec9fc50bcfc8f76c5e220c32fb2e66ddb..e341d1cc7a3267bef9db916719b2e4b1981e31bc 100755 --- a/demo/recommendation/run.sh +++ b/demo/recommendation/run.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/recommendation/trainer_config.py b/demo/recommendation/trainer_config.py index cec340b0b65a841029a1c0538d9881bb38f026ff..aabcd335253faf69c940024ac8098a54da030463 100755 --- a/demo/recommendation/trainer_config.py +++ b/demo/recommendation/trainer_config.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/semantic_role_labeling/data/extract_dict_feature.py b/demo/semantic_role_labeling/data/extract_dict_feature.py index daca5f01cf2b3bd231bf530f17ec760272ce93e0..a02a49a86ed31f44058c192525a2acd979c5de0b 100644 --- a/demo/semantic_role_labeling/data/extract_dict_feature.py +++ b/demo/semantic_role_labeling/data/extract_dict_feature.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ def extract_dict_features(pair_file, feature_file): ctx_n1 = sentence_list[verb_index - 1] else: ctx_n1 = 'bos' - + if verb_index > 1: mark[verb_index - 2] = 1 ctx_n2 = sentence_list[verb_index - 2] @@ -48,7 +48,7 @@ def extract_dict_features(pair_file, feature_file): ctx_p1 = sentence_list[verb_index + 1] else: ctx_p1 = 'eos' - + if verb_index < len(labels_list) - 3: mark[verb_index + 2] = 1 ctx_p2 = sentence_list[verb_index + 2] @@ -69,7 +69,6 @@ def extract_dict_features(pair_file, feature_file): feature_out.write(feature_str + '\n') - if __name__ == '__main__': usage = '-p pair_file -f feature_file' diff --git a/demo/semantic_role_labeling/data/extract_pairs.py b/demo/semantic_role_labeling/data/extract_pairs.py index 86ab00ce41723169de035a841d9e129a1b9e82a3..94a8488c16734eb1882d54f7ec36f4b9308c09d4 100644 --- a/demo/semantic_role_labeling/data/extract_pairs.py +++ b/demo/semantic_role_labeling/data/extract_pairs.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -66,8 +66,8 @@ def transform_labels(sentences, labels): else: verb_list = [] for x in labels[i][0]: - if x !='-': - verb_list.append(x) + if x != '-': + verb_list.append(x) for j in xrange(1, len(labels[i])): label_list = labels[i][j] @@ -93,7 +93,7 @@ def transform_labels(sentences, labels): is_in_bracket = True else: print 'error:', ll - sen_lab_pair.append((sentences[i], verb_list[j-1], label_seq)) + sen_lab_pair.append((sentences[i], verb_list[j - 1], label_seq)) return sen_lab_pair @@ -103,7 +103,7 @@ def write_file(sen_lab_pair, output_file): sentence = x[0] label_seq = ' '.join(x[2]) assert len(sentence.split()) == len(x[2]) - fout.write(sentence + '\t' + x[1]+'\t' +label_seq + '\n') + fout.write(sentence + '\t' + x[1] + '\t' + label_seq + '\n') if __name__ == '__main__': diff --git a/demo/semantic_role_labeling/data/get_data.sh b/demo/semantic_role_labeling/data/get_data.sh index 99487e0d9a8c31d884c4a338386ad0ff8e5d9dc7..a0ef26a13b9a03392cb8b6207d6d21b7761e38e8 100644 --- a/demo/semantic_role_labeling/data/get_data.sh +++ b/demo/semantic_role_labeling/data/get_data.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/semantic_role_labeling/dataprovider.py b/demo/semantic_role_labeling/dataprovider.py index 2c8e13462730a2e980fa1c3fe342ef0e062ab5d7..042cd4e7a9e256cd597ac34eed423040f1d7ccd5 100644 --- a/demo/semantic_role_labeling/dataprovider.py +++ b/demo/semantic_role_labeling/dataprovider.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ def hook(settings, word_dict, label_dict, predicate_dict, **kwargs): settings.word_dict = word_dict settings.label_dict = label_dict settings.predicate_dict = predicate_dict - + #all inputs are integral and sequential type settings.slots = [ integer_value_sequence(len(word_dict)), @@ -29,25 +29,28 @@ def hook(settings, word_dict, label_dict, predicate_dict, **kwargs): integer_value_sequence(len(word_dict)), integer_value_sequence(len(word_dict)), integer_value_sequence(len(word_dict)), - integer_value_sequence(len(word_dict)), - integer_value_sequence(len(predicate_dict)), - integer_value_sequence(2), + integer_value_sequence(len(word_dict)), + integer_value_sequence(len(predicate_dict)), integer_value_sequence(2), integer_value_sequence(len(label_dict)) ] def get_batch_size(yeild_data): return len(yeild_data[0]) - -@provider(init_hook=hook, should_shuffle=True, calc_batch_size=get_batch_size, - can_over_batch_size=False, cache=CacheType.CACHE_PASS_IN_MEM) + +@provider( + init_hook=hook, + should_shuffle=True, + calc_batch_size=get_batch_size, + can_over_batch_size=False, + cache=CacheType.CACHE_PASS_IN_MEM) def process(settings, file_name): with open(file_name, 'r') as fdata: for line in fdata: sentence, predicate, ctx_n2, ctx_n1, ctx_0, ctx_p1, ctx_p2, mark, label = \ line.strip().split('\t') - + words = sentence.split() sen_len = len(words) word_slot = [settings.word_dict.get(w, UNK_IDX) for w in words] diff --git a/demo/semantic_role_labeling/db_lstm.py b/demo/semantic_role_labeling/db_lstm.py index 54ceff0e724220cc9ea96b9e0ec6844947a8343e..04e2a559b19bd4b9aec0242eb43edf6ab1e7624e 100644 --- a/demo/semantic_role_labeling/db_lstm.py +++ b/demo/semantic_role_labeling/db_lstm.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ from paddle.trainer_config_helpers import * #file paths word_dict_file = './data/wordDict.txt' label_dict_file = './data/targetDict.txt' -predicate_file= './data/verbDict.txt' +predicate_file = './data/verbDict.txt' train_list_file = './data/train.list' test_list_file = './data/test.list' @@ -47,7 +47,6 @@ if not is_predict: w = line.strip() predicate_dict[w] = i - if is_test: train_list_file = None @@ -57,9 +56,11 @@ if not is_predict: test_list=test_list_file, module='dataprovider', obj='process', - args={'word_dict': word_dict, - 'label_dict': label_dict, - 'predicate_dict': predicate_dict }) + args={ + 'word_dict': word_dict, + 'label_dict': label_dict, + 'predicate_dict': predicate_dict + }) word_dict_len = len(word_dict) label_dict_len = len(label_dict) @@ -77,24 +78,16 @@ mark_dim = 5 hidden_dim = 512 depth = 8 - - ########################### Optimizer ####################################### - settings( batch_size=150, learning_method=MomentumOptimizer(momentum=0), learning_rate=2e-2, regularization=L2Regularization(8e-4), is_async=False, - model_average=ModelAverage(average_window=0.5, - max_average_window=10000), - -) - - - + model_average=ModelAverage( + average_window=0.5, max_average_window=10000), ) ####################################### network ############################## #8 features and 1 target @@ -108,22 +101,28 @@ ctx_p1 = data_layer(name='ctx_p1_data', size=word_dict_len) ctx_p2 = data_layer(name='ctx_p2_data', size=word_dict_len) mark = data_layer(name='mark_data', size=mark_dict_len) - if not is_predict: target = data_layer(name='target', size=label_dict_len) - -default_std=1/math.sqrt(hidden_dim)/3.0 +default_std = 1 / math.sqrt(hidden_dim) / 3.0 emb_para = ParameterAttribute(name='emb', initial_std=0., learning_rate=0.) std_0 = ParameterAttribute(initial_std=0.) -std_default = ParameterAttribute(initial_std=default_std) - -predicate_embedding = embedding_layer(size=word_dim, input=predicate, param_attr=ParameterAttribute(name='vemb',initial_std=default_std)) -mark_embedding = embedding_layer(name='word_ctx-in_embedding', size=mark_dim, input=mark, param_attr=std_0) - -word_input=[word, ctx_n2, ctx_n1, ctx_0, ctx_p1, ctx_p2] -emb_layers = [embedding_layer(size=word_dim, input=x, param_attr=emb_para) for x in word_input] +std_default = ParameterAttribute(initial_std=default_std) + +predicate_embedding = embedding_layer( + size=word_dim, + input=predicate, + param_attr=ParameterAttribute( + name='vemb', initial_std=default_std)) +mark_embedding = embedding_layer( + name='word_ctx-in_embedding', size=mark_dim, input=mark, param_attr=std_0) + +word_input = [word, ctx_n2, ctx_n1, ctx_0, ctx_p1, ctx_p2] +emb_layers = [ + embedding_layer( + size=word_dim, input=x, param_attr=emb_para) for x in word_input +] emb_layers.append(predicate_embedding) emb_layers.append(mark_embedding) @@ -131,84 +130,89 @@ hidden_0 = mixed_layer( name='hidden0', size=hidden_dim, bias_attr=std_default, - input=[ full_matrix_projection(input=emb, param_attr=std_default ) for emb in emb_layers ]) - + input=[ + full_matrix_projection( + input=emb, param_attr=std_default) for emb in emb_layers + ]) mix_hidden_lr = 1e-3 lstm_para_attr = ParameterAttribute(initial_std=0.0, learning_rate=1.0) -hidden_para_attr = ParameterAttribute(initial_std=default_std, learning_rate=mix_hidden_lr) - -lstm_0 = lstmemory(name='lstm0', - input=hidden_0, - act=ReluActivation(), - gate_act=SigmoidActivation(), - state_act=SigmoidActivation(), - bias_attr=std_0, - param_attr=lstm_para_attr) +hidden_para_attr = ParameterAttribute( + initial_std=default_std, learning_rate=mix_hidden_lr) + +lstm_0 = lstmemory( + name='lstm0', + input=hidden_0, + act=ReluActivation(), + gate_act=SigmoidActivation(), + state_act=SigmoidActivation(), + bias_attr=std_0, + param_attr=lstm_para_attr) #stack L-LSTM and R-LSTM with direct edges input_tmp = [hidden_0, lstm_0] - for i in range(1, depth): - mix_hidden = mixed_layer(name='hidden'+str(i), - size=hidden_dim, - bias_attr=std_default, - input=[full_matrix_projection(input=input_tmp[0], param_attr=hidden_para_attr), - full_matrix_projection(input=input_tmp[1], param_attr=lstm_para_attr) - ] - ) - - lstm = lstmemory(name='lstm'+str(i), - input=mix_hidden, - act=ReluActivation(), - gate_act=SigmoidActivation(), - state_act=SigmoidActivation(), - reverse=((i % 2)==1), - bias_attr=std_0, - param_attr=lstm_para_attr) + mix_hidden = mixed_layer( + name='hidden' + str(i), + size=hidden_dim, + bias_attr=std_default, + input=[ + full_matrix_projection( + input=input_tmp[0], param_attr=hidden_para_attr), + full_matrix_projection( + input=input_tmp[1], param_attr=lstm_para_attr) + ]) + + lstm = lstmemory( + name='lstm' + str(i), + input=mix_hidden, + act=ReluActivation(), + gate_act=SigmoidActivation(), + state_act=SigmoidActivation(), + reverse=((i % 2) == 1), + bias_attr=std_0, + param_attr=lstm_para_attr) input_tmp = [mix_hidden, lstm] -feature_out = mixed_layer(name='output', - size=label_dict_len, - bias_attr=std_default, - input=[full_matrix_projection(input=input_tmp[0], param_attr=hidden_para_attr), - full_matrix_projection(input=input_tmp[1], param_attr=lstm_para_attr) - ], - ) - - +feature_out = mixed_layer( + name='output', + size=label_dict_len, + bias_attr=std_default, + input=[ + full_matrix_projection( + input=input_tmp[0], param_attr=hidden_para_attr), + full_matrix_projection( + input=input_tmp[1], param_attr=lstm_para_attr) + ], ) if not is_predict: - crf_l = crf_layer( name = 'crf', - size = label_dict_len, - input = feature_out, - label = target, - param_attr=ParameterAttribute(name='crfw',initial_std=default_std, learning_rate=mix_hidden_lr) - - ) - - - crf_dec_l = crf_decoding_layer(name = 'crf_dec_l', - size = label_dict_len, - input = feature_out, - label = target, - param_attr=ParameterAttribute(name='crfw') - ) - + crf_l = crf_layer( + name='crf', + size=label_dict_len, + input=feature_out, + label=target, + param_attr=ParameterAttribute( + name='crfw', initial_std=default_std, learning_rate=mix_hidden_lr)) + + crf_dec_l = crf_decoding_layer( + name='crf_dec_l', + size=label_dict_len, + input=feature_out, + label=target, + param_attr=ParameterAttribute(name='crfw')) eval = sum_evaluator(input=crf_dec_l) - + outputs(crf_l) else: - crf_dec_l = crf_decoding_layer(name = 'crf_dec_l', - size = label_dict_len, - input = feature_out, - param_attr=ParameterAttribute(name='crfw') - ) + crf_dec_l = crf_decoding_layer( + name='crf_dec_l', + size=label_dict_len, + input=feature_out, + param_attr=ParameterAttribute(name='crfw')) outputs(crf_dec_l) - diff --git a/demo/semantic_role_labeling/predict.py b/demo/semantic_role_labeling/predict.py index a7f1e8f81f59f6fe95fd29593ef1a826e652e570..372fd090b6e8f08f5bb34697772c2e4976810595 100644 --- a/demo/semantic_role_labeling/predict.py +++ b/demo/semantic_role_labeling/predict.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -26,7 +26,8 @@ UNK_IDX = 0 class Prediction(): - def __init__(self, train_conf, dict_file, model_dir, label_file, predicate_dict_file): + def __init__(self, train_conf, dict_file, model_dir, label_file, + predicate_dict_file): """ train_conf: trainer configure. dict_file: word dictionary file name. @@ -35,7 +36,7 @@ class Prediction(): self.dict = {} self.labels = {} - self.predicate_dict={} + self.predicate_dict = {} self.labels_reverse = {} self.load_dict_label(dict_file, label_file, predicate_dict_file) @@ -44,25 +45,18 @@ class Prediction(): len_pred = len(self.predicate_dict) conf = parse_config( - train_conf, - 'dict_len=' + str(len_dict) + - ',label_len=' + str(len_label) + - ',pred_len=' + str(len_pred) + - ',is_predict=True') + train_conf, 'dict_len=' + str(len_dict) + ',label_len=' + + str(len_label) + ',pred_len=' + str(len_pred) + ',is_predict=True') self.network = swig_paddle.GradientMachine.createFromConfigProto( conf.model_config) self.network.loadParameters(model_dir) slots = [ - integer_value_sequence(len_dict), - integer_value_sequence(len_dict), - integer_value_sequence(len_dict), - integer_value_sequence(len_dict), - integer_value_sequence(len_dict), - integer_value_sequence(len_dict), - integer_value_sequence(len_pred), - integer_value_sequence(2) - ] + integer_value_sequence(len_dict), integer_value_sequence(len_dict), + integer_value_sequence(len_dict), integer_value_sequence(len_dict), + integer_value_sequence(len_dict), integer_value_sequence(len_dict), + integer_value_sequence(len_pred), integer_value_sequence(2) + ] self.converter = DataProviderConverter(slots) def load_dict_label(self, dict_file, label_file, predicate_dict_file): @@ -78,6 +72,7 @@ class Prediction(): for line_count, line in enumerate(open(predicate_dict_file, 'r')): self.predicate_dict[line.strip()] = line_count + def get_data(self, data_file): """ Get input data of paddle format. @@ -88,9 +83,10 @@ class Prediction(): ).split('\t') words = sentence.split() sen_len = len(words) - + word_slot = [self.dict.get(w, UNK_IDX) for w in words] - predicate_slot = [self.predicate_dict.get(predicate, UNK_IDX)] * sen_len + predicate_slot = [self.predicate_dict.get(predicate, UNK_IDX) + ] * sen_len ctx_n2_slot = [self.dict.get(ctx_n2, UNK_IDX)] * sen_len ctx_n1_slot = [self.dict.get(ctx_n1, UNK_IDX)] * sen_len ctx_0_slot = [self.dict.get(ctx_0, UNK_IDX)] * sen_len @@ -99,7 +95,7 @@ class Prediction(): marks = mark.split() mark_slot = [int(w) for w in marks] - + yield word_slot, ctx_n2_slot, ctx_n1_slot, \ ctx_0_slot, ctx_p1_slot, ctx_p2_slot, predicate_slot, mark_slot @@ -123,8 +119,9 @@ class Prediction(): def option_parser(): - usage = ("python predict.py -c config -w model_dir " - "-d word dictionary -l label_file -i input_file -p pred_dict_file") + usage = ( + "python predict.py -c config -w model_dir " + "-d word dictionary -l label_file -i input_file -p pred_dict_file") parser = OptionParser(usage="usage: %s [options]" % usage) parser.add_option( "-c", @@ -187,8 +184,9 @@ def main(): output_file = options.output_file swig_paddle.initPaddle("--use_gpu=0") - predict = Prediction(train_conf, dict_file, model_path, label_file, predict_dict_file) - predict.predict(data_file,output_file) + predict = Prediction(train_conf, dict_file, model_path, label_file, + predict_dict_file) + predict.predict(data_file, output_file) if __name__ == '__main__': diff --git a/demo/semantic_role_labeling/predict.sh b/demo/semantic_role_labeling/predict.sh index 88ab5898f7d41056f4fe549b3145760783b27bf9..873aad670d16803ce321ab60baabe9fe29ea64bf 100755 --- a/demo/semantic_role_labeling/predict.sh +++ b/demo/semantic_role_labeling/predict.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/semantic_role_labeling/test.sh b/demo/semantic_role_labeling/test.sh index f9e1bdcd4c752474329d36c4de3378f7d58e7b4b..11d9d6a19c1b17ad1b7540ee7a03017f85dd821e 100755 --- a/demo/semantic_role_labeling/test.sh +++ b/demo/semantic_role_labeling/test.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/semantic_role_labeling/train.sh b/demo/semantic_role_labeling/train.sh index 420768bb2b4ebed7b135a49c5eee5e5538426ae1..9354e72f46dc4dfc46138a04c330933d404c6cb8 100755 --- a/demo/semantic_role_labeling/train.sh +++ b/demo/semantic_role_labeling/train.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/sentiment/data/get_imdb.sh b/demo/sentiment/data/get_imdb.sh index 28fa86232d89964b3f1680080239cf8a4ebefa9a..7600af6fbb900ee845702f1297779c1f0ed9bf84 100755 --- a/demo/sentiment/data/get_imdb.sh +++ b/demo/sentiment/data/get_imdb.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/sentiment/dataprovider.py b/demo/sentiment/dataprovider.py index 53e3d1d20df92b8815347bd8937064871f326b3f..00f72cecacb454a0dd1184fa2098be4543007de7 100755 --- a/demo/sentiment/dataprovider.py +++ b/demo/sentiment/dataprovider.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/sentiment/predict.py b/demo/sentiment/predict.py index bc0f6f31264294034ed38309f7fda370865b2845..8ec490f64691924013200a3d0038d39aa834b038 100755 --- a/demo/sentiment/predict.py +++ b/demo/sentiment/predict.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os +import os, sys import numpy as np from optparse import OptionParser from py_paddle import swig_paddle, DataProviderConverter @@ -66,34 +66,24 @@ class SentimentPrediction(): for v in open(label_file, 'r'): self.label[int(v.split('\t')[1])] = v.split('\t')[0] - def get_data(self, data_file): + def get_index(self, data): """ - Get input data of paddle format. + transform word into integer index according to the dictionary. """ - with open(data_file, 'r') as fdata: - for line in fdata: - words = line.strip().split() - word_slot = [ - self.word_dict[w] for w in words if w in self.word_dict - ] - if not word_slot: - print "all words are not in dictionary: %s", line - continue - yield [word_slot] - - def predict(self, data_file): - """ - data_file: file name of input data. - """ - input = self.converter(self.get_data(data_file)) + words = data.strip().split() + word_slot = [self.word_dict[w] for w in words if w in self.word_dict] + return word_slot + + def batch_predict(self, data_batch): + input = self.converter(data_batch) output = self.network.forwardTest(input) prob = output[0]["value"] - lab = np.argsort(-prob) - if self.label is None: - print("%s: predicting label is %d" % (data_file, lab[0][0])) - else: - print("%s: predicting label is %s" % - (data_file, self.label[lab[0][0]])) + labs = np.argsort(-prob) + for idx, lab in enumerate(labs): + if self.label is None: + print("predicting label is %d" % (lab[0])) + else: + print("predicting label is %s" % (self.label[lab[0]])) def option_parser(): @@ -119,11 +109,13 @@ def option_parser(): default=None, help="dictionary file") parser.add_option( - "-i", - "--data", + "-c", + "--batch_size", + type="int", action="store", - dest="data", - help="data file to predict") + dest="batch_size", + default=1, + help="the batch size for prediction") parser.add_option( "-w", "--model", @@ -137,13 +129,21 @@ def option_parser(): def main(): options, args = option_parser() train_conf = options.train_conf - data = options.data + batch_size = options.batch_size dict_file = options.dict_file model_path = options.model_path label = options.label swig_paddle.initPaddle("--use_gpu=0") predict = SentimentPrediction(train_conf, dict_file, model_path, label) - predict.predict(data) + + batch = [] + for line in sys.stdin: + batch.append([predict.get_index(line)]) + if len(batch) == batch_size: + predict.batch_predict(batch) + batch = [] + if len(batch) > 0: + predict.batch_predict(batch) if __name__ == '__main__': diff --git a/demo/sentiment/predict.sh b/demo/sentiment/predict.sh index 053f23e491ab8d8af082e0b1ff1093be714a8268..c72a8e8641516543ef267fcb4b448630246d1e8d 100755 --- a/demo/sentiment/predict.sh +++ b/demo/sentiment/predict.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -19,9 +19,9 @@ set -e model=model_output/pass-00002/ config=trainer_config.py label=data/pre-imdb/labels.list -python predict.py \ - -n $config\ - -w $model \ - -b $label \ - -d ./data/pre-imdb/dict.txt \ - -i ./data/aclImdb/test/pos/10007_10.txt +cat ./data/aclImdb/test/pos/10007_10.txt | python predict.py \ + --tconf=$config\ + --model=$model \ + --label=$label \ + --dict=./data/pre-imdb/dict.txt \ + --batch_size=1 diff --git a/demo/sentiment/preprocess.py b/demo/sentiment/preprocess.py index 7146e95d751c4de649e204fab724085994dfa4d3..29b3682b747c66574590de5ea70574981cc536bb 100755 --- a/demo/sentiment/preprocess.py +++ b/demo/sentiment/preprocess.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/sentiment/preprocess.sh b/demo/sentiment/preprocess.sh index 5f5c78e222917ddd0f3b4b3387a5753288c0b3a8..19ec34d4f016365d18db01ddec559d26202b19c6 100755 --- a/demo/sentiment/preprocess.sh +++ b/demo/sentiment/preprocess.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/sentiment/sentiment_net.py b/demo/sentiment/sentiment_net.py index ff6a3624a404cb52d5d7ac0934fedba0d489dc22..a01577ca5ae025b7bec67c6d54c7dbd931dbee74 100644 --- a/demo/sentiment/sentiment_net.py +++ b/demo/sentiment/sentiment_net.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/sentiment/test.sh b/demo/sentiment/test.sh index c8b12a0e89dbddea56b4ee069ebf66f8d8630615..8af827c3388c8df88a872bd87d121a4f9631c3ff 100755 --- a/demo/sentiment/test.sh +++ b/demo/sentiment/test.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/sentiment/train.sh b/demo/sentiment/train.sh index f44a9a53f2db9a57a1f018b090a3cd74dae70e72..5ce8bf4b997d962b9b61593cec0954d76c4874bc 100755 --- a/demo/sentiment/train.sh +++ b/demo/sentiment/train.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/sentiment/trainer_config.py b/demo/sentiment/trainer_config.py index 114a9138ebfef054c7d3ba99b4a510a452f8f2cd..2defecd178262900c03c1eda60b351dc44629d1f 100644 --- a/demo/sentiment/trainer_config.py +++ b/demo/sentiment/trainer_config.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/seqToseq/data/paraphrase_data.sh b/demo/seqToseq/data/paraphrase_data.sh index 1b3f1d45e11fbd5e600e58f583e503a603e484ff..e6497c91286d44b5ef3b66c5f824e36a09728720 100755 --- a/demo/seqToseq/data/paraphrase_data.sh +++ b/demo/seqToseq/data/paraphrase_data.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/seqToseq/data/paraphrase_model.sh b/demo/seqToseq/data/paraphrase_model.sh index 041f69cf467b1322f9d261a9b6b533d98320957d..d0e7f214a38c4dad0fdf7c10ba3b76eb0ab40f06 100755 --- a/demo/seqToseq/data/paraphrase_model.sh +++ b/demo/seqToseq/data/paraphrase_model.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/seqToseq/data/wmt14_data.sh b/demo/seqToseq/data/wmt14_data.sh index 6c360b206011a7ad2eeab6bde7aef8ce35ec01e7..43f67168d2a876ba5401e0f8490a88adac9c5551 100755 --- a/demo/seqToseq/data/wmt14_data.sh +++ b/demo/seqToseq/data/wmt14_data.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/seqToseq/data/wmt14_model.sh b/demo/seqToseq/data/wmt14_model.sh index d6e7a732644dc188a165215ddf3f69e1514425eb..c4b55b90a3eb98f94e0eb3be028c6de1ef57326b 100755 --- a/demo/seqToseq/data/wmt14_model.sh +++ b/demo/seqToseq/data/wmt14_model.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/seqToseq/dataprovider.py b/demo/seqToseq/dataprovider.py index 127c3672c774d43d5b2afab3be79558842eb9e8f..c2b49804be582d7d0bc3ef6332741be03936eb24 100755 --- a/demo/seqToseq/dataprovider.py +++ b/demo/seqToseq/dataprovider.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/seqToseq/paraphrase/train.conf b/demo/seqToseq/paraphrase/train.conf index 748920e2c7253790f1f0b9635e7e604f598a0da3..be79c5e771c0e864fd1776cedb3ef37c997b6df6 100644 --- a/demo/seqToseq/paraphrase/train.conf +++ b/demo/seqToseq/paraphrase/train.conf @@ -1,5 +1,5 @@ #edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/seqToseq/paraphrase/train.sh b/demo/seqToseq/paraphrase/train.sh index 2aa7b84060b19869f73f9a64df125bd429395947..33a42f6eff2b0414c466d5f78c89989a6a517eb9 100755 --- a/demo/seqToseq/paraphrase/train.sh +++ b/demo/seqToseq/paraphrase/train.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/seqToseq/preprocess.py b/demo/seqToseq/preprocess.py index bd1c51b1514b790ec385d48f49197b3e0285e736..03f371331a0755e5939e457f4bdfb1770b8dad88 100755 --- a/demo/seqToseq/preprocess.py +++ b/demo/seqToseq/preprocess.py @@ -1,5 +1,5 @@ #!/bin/env python -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/seqToseq/seqToseq_net.py b/demo/seqToseq/seqToseq_net.py index fc9db05ba706ee6eff6eb0ce0885a645ebd76340..e523a34d5a95120d1f0a583be8bbdbff5678d1ab 100644 --- a/demo/seqToseq/seqToseq_net.py +++ b/demo/seqToseq/seqToseq_net.py @@ -1,6 +1,6 @@ # edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/seqToseq/translation/eval_bleu.sh b/demo/seqToseq/translation/eval_bleu.sh index ef0ede717a740f4dcbf38fe6bde504470779e81a..54c2ed237e93adb3456dbe62f75626d36c2d90bc 100755 --- a/demo/seqToseq/translation/eval_bleu.sh +++ b/demo/seqToseq/translation/eval_bleu.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/seqToseq/translation/gen.conf b/demo/seqToseq/translation/gen.conf index 63c5c2f9a6052c16211c80284617ab1dad0133d7..e9bea4e4559ff31ad83c4474e91de7e7acc77e9f 100644 --- a/demo/seqToseq/translation/gen.conf +++ b/demo/seqToseq/translation/gen.conf @@ -1,5 +1,5 @@ #edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/seqToseq/translation/gen.sh b/demo/seqToseq/translation/gen.sh index ad977c05ff98975c2ce667372e7b491af9243ecc..a700ae213473dfe7c5b77156de15775b8fe9a9f0 100755 --- a/demo/seqToseq/translation/gen.sh +++ b/demo/seqToseq/translation/gen.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/seqToseq/translation/moses_bleu.sh b/demo/seqToseq/translation/moses_bleu.sh index bfaba40b26905ce04934253ff8a0e7738018ecc2..2f230d7f4c736da003966fbdb277f6b8b1ec952c 100755 --- a/demo/seqToseq/translation/moses_bleu.sh +++ b/demo/seqToseq/translation/moses_bleu.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/seqToseq/translation/train.conf b/demo/seqToseq/translation/train.conf index cf1bde15c4a8aa2bf853f0006c3addcf71cf2e55..72b7ccdbb95dbda8f06674079db9a3257bb31622 100644 --- a/demo/seqToseq/translation/train.conf +++ b/demo/seqToseq/translation/train.conf @@ -1,5 +1,5 @@ #edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/seqToseq/translation/train.sh b/demo/seqToseq/translation/train.sh index 976b5ba3b054c49bd87fda87d2520bd6cc55116c..bdece693e5c407c89bc172c461bac7f9b20560d3 100755 --- a/demo/seqToseq/translation/train.sh +++ b/demo/seqToseq/translation/train.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/sequence_tagging/data/get_data.sh b/demo/sequence_tagging/data/get_data.sh index e579d6c46ce5ed96f442acc448b4cc61bf8394a3..0cdb394035e782b3a647f7f13e79d55b5d3dff48 100755 --- a/demo/sequence_tagging/data/get_data.sh +++ b/demo/sequence_tagging/data/get_data.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/sequence_tagging/dataprovider.py b/demo/sequence_tagging/dataprovider.py index 37dcb7aa17c0abd197ef2f3121bf8be6c54375c2..bb4b4465bc7e032c50c1d21263651e2578af67be 100644 --- a/demo/sequence_tagging/dataprovider.py +++ b/demo/sequence_tagging/dataprovider.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/sequence_tagging/linear_crf.py b/demo/sequence_tagging/linear_crf.py index 64895742e1b8c0a11cbedee0b88e61b5b63b007f..736b580bb87a3f2c12b369e231a10893fa95ce08 100644 --- a/demo/sequence_tagging/linear_crf.py +++ b/demo/sequence_tagging/linear_crf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/demo/sequence_tagging/rnn_crf.py b/demo/sequence_tagging/rnn_crf.py index 90d4bbdddfdb4e38b930d54a2bc865df9fac589c..ad1e7b68e78ae202575623e139ad3727b0b9d30c 100644 --- a/demo/sequence_tagging/rnn_crf.py +++ b/demo/sequence_tagging/rnn_crf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/doc/about/index.rst b/doc/about/index_en.rst similarity index 100% rename from doc/about/index.rst rename to doc/about/index_en.rst diff --git a/doc/api/data_provider/index.rst b/doc/api/data_provider/index_en.rst similarity index 89% rename from doc/api/data_provider/index.rst rename to doc/api/data_provider/index_en.rst index 5e7a49d63236ffa854e64c53921441bacebc13ae..96efbb1da959daec561009fdcc95d353b191dec8 100644 --- a/doc/api/data_provider/index.rst +++ b/doc/api/data_provider/index_en.rst @@ -32,11 +32,3 @@ Each line of train.list and test.list is an absolute or relative path (relative to the PaddePaddle program runtime) of data file. Fascinatingly more, each line can also be a HDFS file path or a SQL connection string. As long as the user assures how to access each file in DataProvider. - -Please refer to the following articles for more information about the detail -usages of DataProvider and how to implement a new DataProvider, - -.. toctree:: - - pydataprovider2.rst - write_new_dataprovider.rst diff --git a/doc/api/data_provider/pydataprovider2.rst b/doc/api/data_provider/pydataprovider2_en.rst similarity index 99% rename from doc/api/data_provider/pydataprovider2.rst rename to doc/api/data_provider/pydataprovider2_en.rst index b42cbca576e4b5d67d50d0156939a01faae4533d..083436e2710b4582e11741aaeaf5932d59869473 100644 --- a/doc/api/data_provider/pydataprovider2.rst +++ b/doc/api/data_provider/pydataprovider2_en.rst @@ -1,5 +1,7 @@ +.. _api_pydataprovider: + PyDataProvider2 -================= +=============== We highly recommand users to use PyDataProvider2 to provide training or testing data to PaddlePaddle. The user only needs to focus on how to read a single diff --git a/doc/api/index.rst b/doc/api/index.rst deleted file mode 100644 index ccee7a0f1f3e5290891dfa963ea24c7fdbd6275e..0000000000000000000000000000000000000000 --- a/doc/api/index.rst +++ /dev/null @@ -1,36 +0,0 @@ -API -==== - -DataProvider API ----------------- - -.. toctree:: - :maxdepth: 1 - - data_provider/index.rst - data_provider/pydataprovider2.rst - -Model Config API ----------------- - -.. toctree:: - :maxdepth: 1 - - trainer_config_helpers/index.rst - trainer_config_helpers/optimizers.rst - trainer_config_helpers/data_sources.rst - trainer_config_helpers/layers.rst - trainer_config_helpers/activations.rst - trainer_config_helpers/poolings.rst - trainer_config_helpers/networks.rst - trainer_config_helpers/evaluators.rst - trainer_config_helpers/attrs.rst - - -Applications API ----------------- - -.. toctree:: - :maxdepth: 1 - - predict/swig_py_paddle_en.rst \ No newline at end of file diff --git a/doc/api/index_en.rst b/doc/api/index_en.rst new file mode 100644 index 0000000000000000000000000000000000000000..6fdee9f928dd7057cec58f740bf7520af54a24fb --- /dev/null +++ b/doc/api/index_en.rst @@ -0,0 +1,37 @@ +API +=== + +DataProvider API +---------------- + +.. toctree:: + :maxdepth: 1 + + data_provider/index_en.rst + data_provider/pydataprovider2_en.rst + +.. _api_trainer_config: + +Model Config API +---------------- + +.. toctree:: + :maxdepth: 1 + + trainer_config_helpers/optimizers.rst + trainer_config_helpers/data_sources.rst + trainer_config_helpers/layers.rst + trainer_config_helpers/activations.rst + trainer_config_helpers/poolings.rst + trainer_config_helpers/networks.rst + trainer_config_helpers/evaluators.rst + trainer_config_helpers/attrs.rst + + +Applications API +---------------- + +.. toctree:: + :maxdepth: 1 + + predict/swig_py_paddle_en.rst diff --git a/doc/api/predict/predict_sample.py b/doc/api/predict/predict_sample.py index 63e8b36d26057d4a87dabb8745de8e13efe2524f..51349250e80ce11e476d952991f0d046f65286b4 100644 --- a/doc/api/predict/predict_sample.py +++ b/doc/api/predict/predict_sample.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/doc/api/trainer_config_helpers/data_sources.rst b/doc/api/trainer_config_helpers/data_sources.rst index 44ea59df43762508e86c7b867fcf136d84c8351e..b9dd4dda01ae59d1260356aff50ddf298d02c87f 100644 --- a/doc/api/trainer_config_helpers/data_sources.rst +++ b/doc/api/trainer_config_helpers/data_sources.rst @@ -1,3 +1,5 @@ +.. _api_trainer_config_helpers_data_sources: + DataSources =========== diff --git a/doc/api/trainer_config_helpers/layers.rst b/doc/api/trainer_config_helpers/layers.rst index b487b739a719e9f7118efcc143301da36f7a978e..12a75080d0deab1ecce6b2579b059ba56abf6711 100644 --- a/doc/api/trainer_config_helpers/layers.rst +++ b/doc/api/trainer_config_helpers/layers.rst @@ -20,6 +20,8 @@ LayerOutput Data layer =========== +.. _api_trainer_config_helpers_layers_data_layer: + data_layer ---------- .. automodule:: paddle.trainer_config_helpers.layers @@ -29,6 +31,8 @@ data_layer Fully Connected Layers ====================== +.. _api_trainer_config_helpers_layers_fc_layer: + fc_layer -------- .. automodule:: paddle.trainer_config_helpers.layers @@ -68,6 +72,8 @@ img_conv_layer :members: img_conv_layer :noindex: +.. _api_trainer_config_helpers_layers_context_projection: + context_projection ------------------ .. automodule:: paddle.trainer_config_helpers.layers @@ -185,6 +191,8 @@ mixed_layer :members: mixed_layer :noindex: +.. _api_trainer_config_helpers_layers_embedding_layer: + embedding_layer --------------- .. automodule:: paddle.trainer_config_helpers.layers @@ -237,6 +245,8 @@ trans_full_matrix_projection Aggregate Layers ================ +.. _api_trainer_config_helpers_layers_pooling_layer: + pooling_layer ------------- .. automodule:: paddle.trainer_config_helpers.layers @@ -333,6 +343,8 @@ tensor_layer :members: tensor_layer :noindex: +.. _api_trainer_config_helpers_layers_cos_sim: + cos_sim ------- .. automodule:: paddle.trainer_config_helpers.layers diff --git a/doc/api/trainer_config_helpers/networks.rst b/doc/api/trainer_config_helpers/networks.rst index 29c52c5ce3078f1755162dbbdd65a059d8ba9fa4..e13c368051abe3c50036c3baab988f170df4c641 100644 --- a/doc/api/trainer_config_helpers/networks.rst +++ b/doc/api/trainer_config_helpers/networks.rst @@ -13,6 +13,8 @@ sequence_conv_pool :members: sequence_conv_pool :noindex: +.. _api_trainer_config_helpers_network_text_conv_pool: + text_conv_pool -------------- .. automodule:: paddle.trainer_config_helpers.networks diff --git a/doc/conf.py.in b/doc/conf.py.in index 5fb307e3a9b572f14789dec3707611f336a5d44f..01d156e887b623898df09044a800fd067ee116db 100644 --- a/doc/conf.py.in +++ b/doc/conf.py.in @@ -144,5 +144,6 @@ def setup(app): # no c++ API for now app.add_config_value('recommonmark_config', { 'url_resolver': lambda url: github_doc_root + url, + 'enable_eval_rst': True, }, True) app.add_transform(AutoStructify) diff --git a/doc/getstarted/basic_usage/basic_usage.rst b/doc/getstarted/basic_usage/index_en.rst similarity index 100% rename from doc/getstarted/basic_usage/basic_usage.rst rename to doc/getstarted/basic_usage/index_en.rst diff --git a/doc/getstarted/build_and_install/build_from_source.md b/doc/getstarted/build_and_install/build_from_source_en.md similarity index 99% rename from doc/getstarted/build_and_install/build_from_source.md rename to doc/getstarted/build_and_install/build_from_source_en.md index 150d7fc43720314462ac5c5b72f6a93b18e6d735..3771d316a1b520b9f29b30babd663b4dd27fd650 100644 --- a/doc/getstarted/build_and_install/build_from_source.md +++ b/doc/getstarted/build_and_install/build_from_source_en.md @@ -79,7 +79,7 @@ As a simple example, consider the following: ```bash pip install 'sphinx>=1.4.0' - pip install sphinx_rtd_theme breathe recommonmark + pip install sphinx_rtd_theme recommonmark # install doxygen on Ubuntu sudo apt-get install doxygen diff --git a/doc/getstarted/build_and_install/docker_install.rst b/doc/getstarted/build_and_install/docker_install_en.rst similarity index 62% rename from doc/getstarted/build_and_install/docker_install.rst rename to doc/getstarted/build_and_install/docker_install_en.rst index 1ab6fc6a728f68b16d798a577da2896481eb17d1..8df7e063a1ffba5ed4b4bad409d35671de53a633 100644 --- a/doc/getstarted/build_and_install/docker_install.rst +++ b/doc/getstarted/build_and_install/docker_install_en.rst @@ -104,3 +104,78 @@ container: Then we can direct our Web browser to the HTML version of source code at http://localhost:8088/paddle/ + + +Development Using Docker +------------------------ + +Develpers can work on PaddlePaddle using Docker. This allows +developers to work on different platforms -- Linux, Mac OS X, and +Windows -- in a consistent way. + +The general development workflow with Docker and Bazel is as follows: + +1. Get the source code of Paddle: + + .. code-block:: bash + + git clone --recursive https://github.com/paddlepaddle/paddle + + +2. Build a development Docker image :code:`paddle:dev` from the source + code. This image contains all the development tools and + dependencies of PaddlePaddle. + + + .. code-block:: bash + + cd paddle + docker build -t paddle:dev -f paddle/scripts/docker/Dockerfile . + + +3. Run the image as a container and mounting local source code + directory into the container. This allows us to change the code on + the host and build it within the container. + + .. code-block:: bash + + docker run \ + -d \ + --name paddle \ + -p 2022:22 \ + -v $PWD:/paddle \ + -v $HOME/.cache/bazel:/root/.cache/bazel \ + paddle:dev + + where :code:`-d` makes the container running in background, + :code:`--name paddle` allows us to run a nginx container to serve + documents in this container, :code:`-p 2022:22` allows us to SSH + into this container, :code:`-v $PWD:/paddle` shares the source code + on the host with the container, :code:`-v + $HOME/.cache/bazel:/root/.cache/bazel` shares Bazel cache on the + host with the container. + +4. SSH into the container: + + .. code-block:: bash + + ssh root@localhost -p 2022 + +5. We can edit the source code in the container or on this host. Then + we can build using cmake + + .. code-block:: bash + + cd /paddle # where paddle source code has been mounted into the container + mkdir -p build + cd build + cmake -DWITH_TESTING=ON .. + make -j `nproc` + CTEST_OUTPUT_ON_FAILURE=1 ctest + + or Bazel in the container: + + .. code-block:: bash + + cd /paddle + bazel test ... diff --git a/doc/getstarted/build_and_install/index.rst b/doc/getstarted/build_and_install/index_en.rst similarity index 79% rename from doc/getstarted/build_and_install/index.rst rename to doc/getstarted/build_and_install/index_en.rst index 6187be9d7257b1690d223770f0f6a5b466cf2898..1bfd4f75c0b9b82d61d28a30f03181f7be159f24 100644 --- a/doc/getstarted/build_and_install/index.rst +++ b/doc/getstarted/build_and_install/index_en.rst @@ -6,10 +6,9 @@ Install PaddlePaddle .. toctree:: :maxdepth: 1 - :glob: - docker_install.rst - ubuntu_install.rst + docker_install_en.rst + ubuntu_install_en.rst Build from Source ----------------- @@ -20,6 +19,5 @@ Build from Source .. toctree:: :maxdepth: 1 - :glob: - build_from_source.md \ No newline at end of file + build_from_source_en.md diff --git a/doc/getstarted/build_and_install/ubuntu_install.rst b/doc/getstarted/build_and_install/ubuntu_install_en.rst similarity index 100% rename from doc/getstarted/build_and_install/ubuntu_install.rst rename to doc/getstarted/build_and_install/ubuntu_install_en.rst diff --git a/doc/getstarted/index.rst b/doc/getstarted/index.rst deleted file mode 100644 index 5f2787066ea5cdb32a1eff2939ffd0585d7fbc63..0000000000000000000000000000000000000000 --- a/doc/getstarted/index.rst +++ /dev/null @@ -1,8 +0,0 @@ -GET STARTED -============ - -.. toctree:: - :maxdepth: 2 - - build_and_install/index.rst - basic_usage/basic_usage.rst diff --git a/doc/getstarted/index_en.rst b/doc/getstarted/index_en.rst new file mode 100644 index 0000000000000000000000000000000000000000..55d95d8015e56ddae3363d19315db0fad841caad --- /dev/null +++ b/doc/getstarted/index_en.rst @@ -0,0 +1,8 @@ +GET STARTED +============ + +.. toctree:: + :maxdepth: 2 + + build_and_install/index_en.rst + basic_usage/index_en.rst diff --git a/doc/howto/cluster/cluster_train.md b/doc/howto/cluster/cluster_train_en.md similarity index 100% rename from doc/howto/cluster/cluster_train.md rename to doc/howto/cluster/cluster_train_en.md diff --git a/doc/howto/cmd_parameter/arguments.md b/doc/howto/cmd_parameter/arguments_en.md similarity index 100% rename from doc/howto/cmd_parameter/arguments.md rename to doc/howto/cmd_parameter/arguments_en.md diff --git a/doc/howto/cmd_parameter/detail_introduction.md b/doc/howto/cmd_parameter/detail_introduction_en.md similarity index 100% rename from doc/howto/cmd_parameter/detail_introduction.md rename to doc/howto/cmd_parameter/detail_introduction_en.md diff --git a/doc/howto/cmd_parameter/index.md b/doc/howto/cmd_parameter/index.md deleted file mode 100644 index 48cf835de142f19f41a9d077786d312100859592..0000000000000000000000000000000000000000 --- a/doc/howto/cmd_parameter/index.md +++ /dev/null @@ -1,5 +0,0 @@ -# How to Set Command-line Parameters - -* [Use Case](use_case.md) -* [Arguments](arguments.md) -* [Detailed Descriptions](detail_introduction.md) diff --git a/doc/howto/cmd_parameter/index_en.md b/doc/howto/cmd_parameter/index_en.md new file mode 100644 index 0000000000000000000000000000000000000000..fb658f2aa5bc0edef7b5dcb24a582d2c4182caa7 --- /dev/null +++ b/doc/howto/cmd_parameter/index_en.md @@ -0,0 +1,8 @@ +```eval_rst +.. _cmd_line_index_en: +``` +# How to Set Command-line Parameters + +* [Use Case](use_case_en.md) +* [Arguments](arguments_en.md) +* [Detailed Descriptions](detail_introduction_en.md) diff --git a/doc/howto/cmd_parameter/use_case.md b/doc/howto/cmd_parameter/use_case_en.md similarity index 100% rename from doc/howto/cmd_parameter/use_case.md rename to doc/howto/cmd_parameter/use_case_en.md diff --git a/doc/howto/contribute_to_paddle.md b/doc/howto/contribute_to_paddle_en.md similarity index 100% rename from doc/howto/contribute_to_paddle.md rename to doc/howto/contribute_to_paddle_en.md diff --git a/doc/howto/deep_model/index.rst b/doc/howto/deep_model/index_en.rst similarity index 83% rename from doc/howto/deep_model/index.rst rename to doc/howto/deep_model/index_en.rst index 06ef443f62f63723704d4f06ba5d321636c0b72b..00a45641e6ad60a944c4334503e117cab1624896 100644 --- a/doc/howto/deep_model/index.rst +++ b/doc/howto/deep_model/index_en.rst @@ -4,4 +4,4 @@ How to Configure Deep Models .. toctree:: :maxdepth: 1 - rnn/rnn.rst + rnn/rnn_en.rst diff --git a/doc/howto/deep_model/rnn/rnn.rst b/doc/howto/deep_model/rnn/rnn_en.rst similarity index 100% rename from doc/howto/deep_model/rnn/rnn.rst rename to doc/howto/deep_model/rnn/rnn_en.rst diff --git a/doc/howto/index.rst b/doc/howto/index_en.rst similarity index 51% rename from doc/howto/index.rst rename to doc/howto/index_en.rst index 41877a64a56e289c39ca7513eb05fa6a41129487..bd64c5b1fb1226b07a07094cfd60bce6fa4e7884 100644 --- a/doc/howto/index.rst +++ b/doc/howto/index_en.rst @@ -7,9 +7,9 @@ Usage .. toctree:: :maxdepth: 1 - cmd_parameter/index.md - deep_model/index.rst - cluster/cluster_train.md + cmd_parameter/index_en.md + deep_model/index_en.rst + cluster/cluster_train_en.md Development ------------ @@ -17,8 +17,8 @@ Development .. toctree:: :maxdepth: 1 - new_layer/index.rst - contribute_to_paddle.md + new_layer/index_en.rst + contribute_to_paddle_en.md Optimization ------------- @@ -26,4 +26,4 @@ Optimization .. toctree:: :maxdepth: 1 - optimization/index.rst + optimization/index_en.rst diff --git a/doc/howto/new_layer/index.rst b/doc/howto/new_layer/index_en.rst similarity index 100% rename from doc/howto/new_layer/index.rst rename to doc/howto/new_layer/index_en.rst diff --git a/doc/howto/optimization/gpu_profiling.rst b/doc/howto/optimization/gpu_profiling_en.rst similarity index 100% rename from doc/howto/optimization/gpu_profiling.rst rename to doc/howto/optimization/gpu_profiling_en.rst diff --git a/doc/howto/optimization/index.rst b/doc/howto/optimization/index_en.rst similarity index 78% rename from doc/howto/optimization/index.rst rename to doc/howto/optimization/index_en.rst index e2822a00982b386e8900420e8c200ed1f92a2d9b..1e2f16b5da7a7aa9e5075effea2d2a171a987e6c 100644 --- a/doc/howto/optimization/index.rst +++ b/doc/howto/optimization/index_en.rst @@ -4,4 +4,4 @@ How to Tune GPU Performance .. toctree:: :maxdepth: 3 - gpu_profiling.rst + gpu_profiling_en.rst diff --git a/doc/howto/source/api.rst b/doc/howto/source/api.rst deleted file mode 100644 index 30396c26b61827847cc5acc29cee1c3c8e7b226e..0000000000000000000000000000000000000000 --- a/doc/howto/source/api.rst +++ /dev/null @@ -1,5 +0,0 @@ -API -=== - -.. doxygenfile:: paddle/api/PaddleAPI.h -.. doxygenfile:: paddle/api/Internal.h diff --git a/doc/howto/source/cuda/index.rst b/doc/howto/source/cuda/index.rst deleted file mode 100644 index b0fed2e7f72c9a9671e56e114edfc88d72504dbe..0000000000000000000000000000000000000000 --- a/doc/howto/source/cuda/index.rst +++ /dev/null @@ -1,9 +0,0 @@ -CUDA -==== - -.. toctree:: - :maxdepth: 2 - - matrix.rst - nn.rst - utils.rst diff --git a/doc/howto/source/cuda/matrix.rst b/doc/howto/source/cuda/matrix.rst deleted file mode 100644 index b7699c83eda15d9003506f5fc57b51d52e7af823..0000000000000000000000000000000000000000 --- a/doc/howto/source/cuda/matrix.rst +++ /dev/null @@ -1,59 +0,0 @@ -Matrix -====== - -Base ----- - -hl_matrix.h -``````````` -.. doxygenfile:: paddle/cuda/include/hl_matrix.h - -hl_matrix_base.h -```````````````` -.. doxygenfile:: paddle/cuda/include/hl_matrix_base.cuh - -hl_matrix_apply.cuh -``````````````````` -.. doxygenfile:: paddle/cuda/include/hl_matrix_apply.cuh - -hl_matrix_ops.cuh -````````````````` -.. doxygenfile:: paddle/cuda/include/hl_matrix_ops.cuh - -hl_matrix_type.cuh -`````````````````` -.. doxygenfile:: paddle/cuda/include/hl_matrix_type.cuh - -hl_sse_matrix_kernel.cuh -```````````````````````` -.. doxygenfile:: paddle/cuda/include/hl_sse_matrix_kernel.cuh - -Matrix Function ---------------- - -hl_batch_transpose.h -```````````````````` -.. doxygenfile:: paddle/cuda/include/hl_batch_transpose.h - -hl_aggregate.h -`````````````` -.. doxygenfile:: paddle/cuda/include/hl_aggregate.h - -hl_top_k.h -`````````` -.. doxygenfile:: paddle/cuda/include/hl_top_k.h - -hl_table_apply.h -```````````````` -.. doxygenfile:: paddle/cuda/include/hl_table_apply.h - -Sparse Matrix -------------- - -hl_sparse.h -``````````` -.. doxygenfile:: paddle/cuda/include/hl_sparse.h - -hl_sparse.ph -```````````` -.. doxygenfile:: paddle/cuda/include/hl_sparse.ph diff --git a/doc/howto/source/cuda/nn.rst b/doc/howto/source/cuda/nn.rst deleted file mode 100644 index 5577d01e72a5b22847bda40528c46a28cacc1490..0000000000000000000000000000000000000000 --- a/doc/howto/source/cuda/nn.rst +++ /dev/null @@ -1,39 +0,0 @@ -Neural Network -============== - -Base ----- - -.. doxygenfile:: paddle/cuda/include/hl_gpu.h -.. doxygenfile:: paddle/cuda/include/hl_functions.h -.. doxygenfile:: paddle/cuda/include/hl_avx_functions.h -.. doxygenfile:: paddle/cuda/include/hl_gpu_functions.cuh -.. doxygenfile:: paddle/cuda/include/hl_activation_functions.h - - -CNN Related APIs ----------------- -.. doxygenfile:: paddle/cuda/include/hl_cnn.h -.. doxygenfile:: paddle/cuda/include/hl_cuda_cudnn.h -.. doxygenfile:: paddle/cuda/include/hl_cuda_cudnn.ph - -RNN Related APIs ----------------- - -.. doxygenfile:: paddle/cuda/include/hl_recurrent_apply.cuh -.. doxygenfile:: paddle/cuda/include/hl_sequence.h - -LSTM Model -`````````` - -.. doxygenfile:: paddle/cuda/include/hl_lstm.h -.. dpxygenfile:: paddle/cuda/include/hl_cpu_lstm.cuh -.. doxygenfile:: paddle/cuda/include/hl_gpu_lstm.cuh -.. doxygenfile:: paddle/cuda/include/hl_lstm_ops.cuh - -GRU Model -````````` - -.. doxygenfile:: paddle/cuda/include/hl_gru_ops.cuh -.. doxygenfile:: paddle/cuda/include/hl_cpu_gru.cuh -.. doxygenfile:: paddle/cuda/include/hl_gpu_gru.cuh diff --git a/doc/howto/source/cuda/utils.rst b/doc/howto/source/cuda/utils.rst deleted file mode 100644 index 850e8bd1c6670947e2a5f1b6f9b0d5b252117cbf..0000000000000000000000000000000000000000 --- a/doc/howto/source/cuda/utils.rst +++ /dev/null @@ -1,37 +0,0 @@ -Utils -===== - -Dynamic Link Libs ------------------ -.. doxygenfile:: paddle/cuda/include/hl_dso_loader.h - -GPU Resources -------------- - -hl_cuda.ph -`````````` -.. doxygenfile:: paddle/cuda/include/hl_cuda.ph - -hl_cuda.h -````````` -.. doxygenfile:: paddle/cuda/include/hl_cuda.h - -HPPL Base ---------- -.. doxygenfile:: paddle/cuda/include/hl_base.h - -CUBLAS Wrapper --------------- -.. doxygenfile:: paddle/cuda/include/hl_cuda_cublas.h - -Timer ------ -.. doxygenfile:: paddle/cuda/include/hl_time.h - -Thread Resource ---------------- -.. doxygenfile:: paddle/cuda/include/hl_thread.ph - -Device Function ---------------- -.. doxygenfile:: paddle/cuda/include/hl_device_functions.cuh diff --git a/doc/howto/source/gserver/activations.rst b/doc/howto/source/gserver/activations.rst deleted file mode 100644 index 55b9d3be383c07842d7066280cc0e174788db1fb..0000000000000000000000000000000000000000 --- a/doc/howto/source/gserver/activations.rst +++ /dev/null @@ -1,5 +0,0 @@ -Activations -=========== - -.. doxygenclass:: paddle::ActivationFunction - :members: diff --git a/doc/howto/source/gserver/dataproviders.rst b/doc/howto/source/gserver/dataproviders.rst deleted file mode 100644 index c30d9d6a36a6fbb664ae001274b6a7b0e721070f..0000000000000000000000000000000000000000 --- a/doc/howto/source/gserver/dataproviders.rst +++ /dev/null @@ -1,87 +0,0 @@ -============== -Data Providers -============== - -DataProviders -============= - -Base ----- -.. doxygenclass:: paddle::DataProvider - :members: - -DataProviderGroup ------------------ -.. doxygenclass:: paddle::DataProviderGroup - :members: - -MultiDataProvider ------------------ -.. doxygenclass:: paddle::MultiDataProvider - :members: - -PyDataProvider -============== - -IFieldScanner -------------- -.. doxygenclass:: paddle::IFieldScanner - :members: - -DenseScanner -------------- -.. doxygenclass:: paddle::DenseScanner - :members: - -IndexScanner -------------- -.. doxygenclass:: paddle::IndexScanner - :members: - -SparseNonValueScanner ---------------------- -.. doxygenclass:: paddle::SparseNonValueScanner - :members: - -SparseValueScanner ------------------- -.. doxygenclass:: paddle::SparseValueScanner - :members: - -SequenceScanner ---------------- -.. doxygenclass:: paddle::SparseValueScanner - :members: - -IPyDataProviderCache --------------------- -.. doxygenclass:: paddle::IPyDataProviderCache - :members: - -NoCacheStrategy ---------------- -.. doxygenclass:: paddle::NoCacheStrategy - :members: - -CacheOnePassInMemory --------------------- -.. doxygenclass:: paddle::CacheOnePassInMemory - :members: - -IPyDataProvider ---------------- -.. doxygenclass:: paddle::PyDataProvider2 - :members: - -ProtoDataProvider -================= - -ProtoDataProvider ----------------- -.. doxygenclass:: paddle::ProtoDataProvider - :members: - -ProtoSequenceDataProvider -------------------------- -.. doxygenclass:: paddle::ProtoSequenceDataProvider - :members: diff --git a/doc/howto/source/gserver/evaluators.rst b/doc/howto/source/gserver/evaluators.rst deleted file mode 100644 index f5361f76cd2b1c9c004221c03ea05b2c1f3a652e..0000000000000000000000000000000000000000 --- a/doc/howto/source/gserver/evaluators.rst +++ /dev/null @@ -1,103 +0,0 @@ -========== -Evaluators -========== - -Base -==== - -.. doxygenclass:: paddle::Evaluator - :members: - -Sum -=== - -SumEvaluator ------------- -.. doxygenclass:: paddle::SumEvaluator - :members: - -ColumnSumEvaluator ------------------- -.. doxygenclass:: paddle::ColumnSumEvaluator - :members: - -Classification -============== - -ClassificationErrorEvaluator ---------------------------- -.. doxygenclass:: paddle::ClassificationErrorEvaluator - :members: - -SequenceClassificationErrorEvaluator ------------------------------------- -.. doxygenclass:: paddle::SequenceClassificationErrorEvaluator - :members: - -AucEvaluator -------------- -.. doxygenclass:: paddle::AucEvaluator - :members: - -PrecisionRecallEvaluator ------------------------- -.. doxygenclass:: paddle::PrecisionRecallEvaluator - :members: - -ChunkEvaluator --------------- -.. doxygenclass:: paddle::ChunkEvaluator - :members: - -CTCEvaluator ------------- -.. doxygenclass:: paddle::CTCErrorEvaluator - :members: - - -Rank -==== - -PnpairEvaluator -------------- -.. doxygenclass:: paddle::PnpairEvaluator - :members: - -AucEvaluator -------------- -.. doxygenclass:: paddle::RankAucEvaluator - :members: - - -Printer -======= - -ValuePrinter -------------- -.. doxygenclass:: paddle::ValuePrinter - :members: - -GradientPrinter ---------------- -.. doxygenclass:: paddle::GradientPrinter - :members: - -MaxIdPrinter ------------- -.. doxygenclass:: paddle::MaxIdPrinter - :members: - -MaxFramePrinter ---------------- -.. doxygenclass:: paddle::MaxFramePrinter - :members: - -SequenceTextPrinter ------------------- -.. doxygenclass:: paddle::SequenceTextPrinter - :members: - -ClassificationErrorPrinter --------------------------- -.. doxygenclass:: paddle::ClassificationErrorPrinter - :members: diff --git a/doc/howto/source/gserver/gradientmachines.rst b/doc/howto/source/gserver/gradientmachines.rst deleted file mode 100644 index 04c8e91d0316a45ad10b0ed0513d3e8916b7c3d9..0000000000000000000000000000000000000000 --- a/doc/howto/source/gserver/gradientmachines.rst +++ /dev/null @@ -1,27 +0,0 @@ -Gradient Machines -================= - -GradientMachine ---------------- -.. doxygenclass:: paddle::GradientMachine - :members: - -GradientMachineMode -------------------- -.. doxygenclass:: paddle::IGradientMachineMode - :members: - -MultiGradientMachine --------------------- -.. doxygenclass:: paddle::MultiGradientMachine - :members: - -TrainerThread -````````````` -.. doxygenclass:: paddle::TrainerThread - :members: - -RecurrentGradientMachine ------------------------- -.. doxygenclass:: paddle::RecurrentGradientMachine - :members: diff --git a/doc/howto/source/gserver/index.rst b/doc/howto/source/gserver/index.rst deleted file mode 100644 index 223b00b9a9dbf1db40ce702cf0e154e5e53a8644..0000000000000000000000000000000000000000 --- a/doc/howto/source/gserver/index.rst +++ /dev/null @@ -1,12 +0,0 @@ -GServer -======= - -.. toctree:: - :maxdepth: 2 - - activations.rst - dataproviders.rst - evaluators.rst - gradientmachines.rst - layers.rst - neworks.rst diff --git a/doc/howto/source/gserver/layers.rst b/doc/howto/source/gserver/layers.rst deleted file mode 100644 index 191b2bdff26ed17437370a12036f9dbb174dae15..0000000000000000000000000000000000000000 --- a/doc/howto/source/gserver/layers.rst +++ /dev/null @@ -1,566 +0,0 @@ -====== -Layers -====== - -Base -==== - -Layer ------ -.. doxygenclass:: paddle::Layer - :members: - -Projection ----------- -.. doxygenclass:: paddle::Projection - :members: - -Operator --------- -.. doxygenclass:: paddle::Operator - :members: - -Data Layer -========== - -.. doxygenclass:: paddle::DataLayer - :members: - -Fully Connected Layers -====================== - -FullyConnectedLayer -------------------- -.. doxygenclass:: paddle::FullyConnectedLayer - :members: - -SelectiveFullyConnectedLayer ----------------------------- -.. doxygenclass:: paddle::SelectiveFullyConnectedLayer - :members: - -Conv Layers -=========== - -ConvBaseLayer -------------- -.. doxygenclass:: paddle::ConvBaseLayer - :members: - -ConvOperator ------------- -.. doxygenclass:: paddle::ConvOperator - :members: - -ConvShiftLayer --------------- -.. doxygenclass:: paddle::ConvShiftLayer - :members: - -CudnnConvLayer --------------- -.. doxygenclass:: paddle::CudnnConvLayer - :members: - -ExpandConvBaseLayer -------------------- -.. doxygenclass:: paddle::ExpandConvBaseLayer - :members: - -ExpandConvLayer ---------------- -.. doxygenclass:: paddle::ExpandConvLayer - :members: - -ContextProjection ------------------ -.. doxygenclass:: paddle::ContextProjection - :members: - -Pooling Layers -============== - -PoolLayer ---------- -.. doxygenclass:: paddle::PoolLayer - :members: - -PoolProjectionLayer -------------------- -.. doxygenclass:: paddle::PoolProjectionLayer - :members: - -CudnnPoolLayer --------------- -.. doxygenclass:: paddle::CudnnPoolLayer - :members: - -SpatialPyramidPoolLayer ------------------------ -.. doxygenclass:: paddle::SpatialPyramidPoolLayer - :members: - -MaxOutLayer ------------ -.. doxygenclass:: paddle::MaxOutLayer - :members: - -Norm Layers -=========== - -NormLayer ---------- -.. doxygenclass:: paddle::NormLayer - :members: - -CMRProjectionNormLayer ----------------------- -.. doxygenclass:: paddle::CMRProjectionNormLayer - :members: - -DataNormLayer -------------- -.. doxygenclass:: paddle::DataNormLayer - :members: - -ResponseNormLayer ------------------ -.. doxygenclass:: paddle::ResponseNormLayer - :members: - -BatchNormBaseLayer ------------------- -.. doxygenclass:: paddle::BatchNormBaseLayer - :members: - -BatchNormalizationLayer ------------------------ -.. doxygenclass:: paddle::BatchNormalizationLayer - :members: - -CudnnBatchNormLayer ------------------------ -.. doxygenclass:: paddle::CudnnBatchNormLayer - :members: - -SumToOneNormLayer ------------------ -.. doxygenclass:: paddle::SumToOneNormLayer - :members: - -Activation Layer -================ - -ParameterReluLayer ------------------- -.. doxygenclass:: paddle::ParameterReluLayer - :members: - -Recurrent Layers -================ - -RecurrentLayer --------------- -.. doxygenclass:: paddle::RecurrentLayer - :members: - -SequenceToBatch ---------------- -.. doxygenclass:: paddle::SequenceToBatch - :members: - -LSTM ----- -LstmLayer -````````` -.. doxygenclass:: paddle::LstmLayer - :members: - -LstmStepLayer -````````````` -.. doxygenclass:: paddle::LstmStepLayer - :members: - -LstmCompute -``````````` -.. doxygenclass:: paddle::LstmCompute - :members: - -MDLSTM ------- -MDLstmLayer -``````````` -.. doxygenclass:: paddle::MDLstmLayer - :members: - -CoordIterator -````````````` -.. doxygenclass:: paddle::CoordIterator - :members: - -GRU ---- -GatedRecurrentLayer -``````````````````` -.. doxygenclass:: paddle::GatedRecurrentLayer - :members: - -GruStepLayer -```````````` -.. doxygenclass:: paddle::GruStepLayer - :members: - -GruCompute -`````````` -.. doxygenclass:: paddle::GruCompute - :members: - -Recurrent Layer Group -===================== - -AgentLayer ----------- -.. doxygenclass:: paddle::AgentLayer - :members: - -SequenceAgentLayer ------------------- -.. doxygenclass:: paddle::SequenceAgentLayer - :members: - -GatherAgentLayer ----------------- -.. doxygenclass:: paddle::GatherAgentLayer - :members: - -SequenceGatherAgentLayer ------------------------- -.. doxygenclass:: paddle::SequenceGatherAgentLayer - :members: - -ScatterAgentLayer ------------------ -.. doxygenclass:: paddle::ScatterAgentLayer - :members: - -SequenceScatterAgentLayer -------------------------- -.. doxygenclass:: paddle::SequenceScatterAgentLayer - :members: - -GetOutputLayer --------------- -.. doxygenclass:: paddle::GetOutputLayer - :members: - -Mixed Layer -=========== -.. doxygenclass:: paddle::MixedLayer - :members: - -DotMulProjection ----------------- -.. doxygenclass:: paddle::DotMulProjection - :members: - -DotMulOperator --------------- -.. doxygenclass:: paddle::DotMulOperator - :members: - -FullMatrixProjection --------------------- -.. doxygenclass:: paddle::FullMatrixProjection - :members: - -IdentityProjection ------------------- -.. doxygenclass:: paddle::IdentityProjection - :members: - -IdentityOffsetProjection ------------------------- -.. doxygenclass:: paddle::IdentityOffsetProjection - :members: - -TableProjection ---------------- -.. doxygenclass:: paddle::TableProjection - :members: - -TransposedFullMatrixProjection ------------------------------- -.. doxygenclass:: paddle::TransposedFullMatrixProjection - :members: - -Aggregate Layers -================ - -Aggregate ---------- -AverageLayer -```````````` -.. doxygenclass:: paddle::AverageLayer - :members: - -MaxLayer -```````` -.. doxygenclass:: paddle::MaxLayer - :members: - -SequenceLastInstanceLayer -````````````````````````` -.. doxygenclass:: paddle::SequenceLastInstanceLayer - :members: - -Concat ------- -ConcatenateLayer -```````````````` -.. doxygenclass:: paddle::ConcatenateLayer - :members: - -ConcatenateLayer2 -````````````````` -.. doxygenclass:: paddle::ConcatenateLayer2 - :members: - -SequenceConcatLayer -``````````````````` -.. doxygenclass:: paddle::SequenceConcatLayer - :members: - -Subset ------- -SubSequenceLayer -```````````````` -.. doxygenclass:: paddle::SubSequenceLayer - :members: - -Reshaping Layers -================ - -BlockExpandLayer ----------------- -.. doxygenclass:: paddle::BlockExpandLayer - :members: - -ExpandLayer ------------ -.. doxygenclass:: paddle::ExpandLayer - :members: - -FeatureMapExpandLayer ---------------------- -.. doxygenclass:: paddle::FeatureMapExpandLayer - :members: - -ResizeLayer ------------ -.. doxygenclass:: paddle::ResizeLayer - :members: - -SequenceReshapeLayer --------------------- -.. doxygenclass:: paddle::SequenceReshapeLayer - :members: - -Math Layers -=========== - -AddtoLayer ----------- -.. doxygenclass:: paddle::AddtoLayer - :members: - -ConvexCombinationLayer ----------------------- -.. doxygenclass:: paddle::ConvexCombinationLayer - :members: - -InterpolationLayer ------------------- -.. doxygenclass:: paddle::InterpolationLayer - :members: - -MultiplexLayer --------------- -.. doxygenclass:: paddle::MultiplexLayer - :members: - -OuterProdLayer --------------- -.. doxygenclass:: paddle::OuterProdLayer - :members: - -PowerLayer ----------- -.. doxygenclass:: paddle::PowerLayer - :members: - -ScalingLayer ------------- -.. doxygenclass:: paddle::ScalingLayer - :members: - -SlopeInterceptLayer -------------------- -.. doxygenclass:: paddle::SlopeInterceptLayer - :members: - -TensorLayer ------------- -.. doxygenclass:: paddle::TensorLayer - :members: - -TransLayer ----------- -.. doxygenclass:: paddle::TransLayer - :members: - -Sampling Layers -=============== - -BilinearInterpLayer -------------------- -.. doxygenclass:: paddle::BilinearInterpLayer - :members: - -MultinomialSampler ------------------- -.. doxygenclass:: paddle::MultinomialSampler - :members: - -MaxIdLayer ----------- -.. doxygenclass:: paddle::MaxIdLayer - :members: - -SamplingIdLayer ---------------- -.. doxygenclass:: paddle::SamplingIdLayer - :members: - -Cost Layers -=========== - -CostLayer ------------ -.. doxygenclass:: paddle::CostLayer - :members: - -HuberTwoClass -````````````` -.. doxygenclass:: paddle::HuberTwoClass - :members: - -LambdaCost -``````````` -.. doxygenclass:: paddle::LambdaCost - :members: - -MultiBinaryLabelCrossEntropy -```````````````````````````` -.. doxygenclass:: paddle::MultiBinaryLabelCrossEntropy - :members: - -MultiClassCrossEntropy -``````````````````````` -.. doxygenclass:: paddle::MultiClassCrossEntropy - :members: - -MultiClassCrossEntropyWithSelfNorm -`````````````````````````````````` -.. doxygenclass:: paddle::MultiClassCrossEntropyWithSelfNorm - :members: - -RankingCost -``````````` -.. doxygenclass:: paddle::RankingCost - :members: - -SoftBinaryClassCrossEntropy -``````````````````````````` -.. doxygenclass:: paddle::SoftBinaryClassCrossEntropy - :members: - -SumOfSquaresCostLayer -````````````````````` -.. doxygenclass:: paddle::SumOfSquaresCostLayer - :members: - -SumCostLayer -````````````````````` -.. doxygenclass:: paddle::SumCostLayer - :members: - -CosSimLayer ------------ -.. doxygenclass:: paddle::CosSimLayer - :members: - -CosSimVecMatLayer ------------------ -.. doxygenclass:: paddle::CosSimVecMatLayer - :members: - -CRFDecodingLayer ----------------- -.. doxygenclass:: paddle::CRFDecodingLayer - :members: - -CRFLayer --------- -.. doxygenclass:: paddle::CRFLayer - :members: - -CTCLayer --------- -.. doxygenclass:: paddle::CTCLayer - :members: - -HierarchicalSigmoidLayer ------------------------- -.. doxygenclass:: paddle::HierarchicalSigmoidLayer - :members: - -LinearChainCRF --------------- -.. doxygenclass:: paddle::LinearChainCRF - :members: - -LinearChainCTC --------------- -.. doxygenclass:: paddle::LinearChainCTC - :members: - -NCELayer --------- -.. doxygenclass:: paddle::NCELayer - :members: - -Validation Layers ------------------ - -ValidationLayer -``````````````` -.. doxygenclass:: paddle::ValidationLayer - :members: - -AucValidation -````````````` -.. doxygenclass:: paddle::AucValidation - :members: - -PnpairValidation -```````````````` -.. doxygenclass:: paddle::PnpairValidation - :members: - -Check Layers -============ - -EosIdCheckLayer ---------------- -.. doxygenclass:: paddle::EosIdCheckLayer - :members: diff --git a/doc/howto/source/gserver/neworks.rst b/doc/howto/source/gserver/neworks.rst deleted file mode 100644 index 73fb60d549cc88f61d2e2d18c9ec31c37cf4fa9a..0000000000000000000000000000000000000000 --- a/doc/howto/source/gserver/neworks.rst +++ /dev/null @@ -1,12 +0,0 @@ -Networks -======== - -NeuralNetwork -------------- -.. doxygenclass:: paddle::NeuralNetwork - :members: - -ParallelNeuralNetwork ---------------------- -.. doxygenclass:: paddle::ParallelNeuralNetwork - :members: diff --git a/doc/howto/source/index.rst b/doc/howto/source/index.rst deleted file mode 100644 index 36323c888ee65147f59f28160dc26ca29235ba63..0000000000000000000000000000000000000000 --- a/doc/howto/source/index.rst +++ /dev/null @@ -1,14 +0,0 @@ -Source Code Documents -===================== - -.. toctree:: - :maxdepth: 1 - - gserver/index.rst - trainer.rst - parameter/index.rst - pserver/index.rst - api.rst - cuda/index.rst - math/index.rst - utils/index.rst diff --git a/doc/howto/source/math/functions.rst b/doc/howto/source/math/functions.rst deleted file mode 100644 index aef12e0f005226c6d40d74d0e858a11585339758..0000000000000000000000000000000000000000 --- a/doc/howto/source/math/functions.rst +++ /dev/null @@ -1,10 +0,0 @@ -Functions -========= - -MathFunctions -------------- -.. doxygenfile:: paddle/math/MathFunctions.h - -SIMDFunctions -------------- -.. doxygenfile:: paddle/math/SIMDFunctions.h diff --git a/doc/howto/source/math/index.rst b/doc/howto/source/math/index.rst deleted file mode 100644 index 2ec16f2b4450c870f9590aea4ad4ca7dc415b75d..0000000000000000000000000000000000000000 --- a/doc/howto/source/math/index.rst +++ /dev/null @@ -1,10 +0,0 @@ -Math -==== - -.. toctree:: - :maxdepth: 2 - - vector.rst - matrix.rst - functions.rst - utils.rst diff --git a/doc/howto/source/math/matrix.rst b/doc/howto/source/math/matrix.rst deleted file mode 100644 index 9bb20f618d229e1baea15e26378bf40d7c6e1783..0000000000000000000000000000000000000000 --- a/doc/howto/source/math/matrix.rst +++ /dev/null @@ -1,76 +0,0 @@ -Matrix -====== - -Base ----- - -BaseMatrix Template -``````````````````` -.. doxygenclass:: paddle::BaseMatrixT - :members: - -Matrix -`````` -.. doxygenclass:: paddle::Matrix - :members: - -MatrixOffset -```````````` -.. doxygenclass:: paddle::MatrixOffset - :members: - -CpuMatrix ---------- - -CpuMatrix -````````` -.. doxygenclass:: paddle::CpuMatrix - :members: - -SharedCpuMatrix -``````````````` -.. doxygenclass:: paddle::SharedCpuMatrix - :members: - -GpuMatrix ---------- -.. doxygenclass:: paddle::GpuMatrix - :members: - -CpuSparseMatrix ---------------- - -CpuSparseMatrix -``````````````` -.. doxygenclass:: paddle::CpuSparseMatrix - :members: - -SparseRowCpuMatrix -`````````````````` -.. doxygenclass:: paddle::SparseRowCpuMatrix - :members: - -SparseAutoGrowRowCpuMatrix -`````````````````````````` -.. doxygenclass:: paddle::SparseAutoGrowRowCpuMatrix - :members: - -SparsePrefetchRowCpuMatrix -`````````````````````````` -.. doxygenclass:: paddle::SparsePrefetchRowCpuMatrix - :members: - -SparseRowIdsCpuMatrix -````````````````````` -.. doxygenclass:: paddle::SparseRowIdsCpuMatrix - :members: - -CacheRowCpuMatrix -````````````````` -.. doxygenclass:: paddle::CacheRowCpuMatrix - :members: - -GpuSparseMatrix ---------------- -.. doxygenclass:: paddle::GpuSparseMatrix - :members: diff --git a/doc/howto/source/math/utils.rst b/doc/howto/source/math/utils.rst deleted file mode 100644 index 55d9961a390c205563a9ae4fbd87ac4ae90fc314..0000000000000000000000000000000000000000 --- a/doc/howto/source/math/utils.rst +++ /dev/null @@ -1,18 +0,0 @@ -Memory Manager -============== - -Memory Handle -------------- -.. doxygenfile:: paddle/math/MemoryHandle.h - -Allocator ---------- -.. doxygenfile:: paddle/math/Allocator.h - -PoolAllocator -````````````` -.. doxygenfile:: paddle/math/PoolAllocator.h - -Storage -------- -.. doxygenfile:: paddle/math/Storage.h diff --git a/doc/howto/source/math/vector.rst b/doc/howto/source/math/vector.rst deleted file mode 100644 index 07f7062abaf4f30b8967b594f4e16ab881f5414f..0000000000000000000000000000000000000000 --- a/doc/howto/source/math/vector.rst +++ /dev/null @@ -1,37 +0,0 @@ -Vector -====== - -BaseVector -`````````` -.. doxygenclass:: paddle::BaseVector - :members: - -Vector Template -``````````````` -.. doxygenclass:: paddle::VectorT - :members: - -CpuVector Template -`````````````````` -.. doxygenclass:: paddle::CpuVectorT - :members: - -GpuVector Template -`````````````````` -.. doxygenclass:: paddle::GpuVectorT - :members: - -ParallelCpuVector Template -`````````````````````````` -.. doxygenclass:: paddle::ParallelCpuVectorT - :members: - -ParallelGpuVector Template -`````````````````````````` -.. doxygenclass:: paddle::ParallelGpuVectorT - :members: - -CpuGpuVector Template -````````````````````` -.. doxygenclass:: paddle::CpuGpuVectorT - :members: diff --git a/doc/howto/source/parameter/index.rst b/doc/howto/source/parameter/index.rst deleted file mode 100644 index 3bf6948dc3478574d8d125d8461235f8827e4e42..0000000000000000000000000000000000000000 --- a/doc/howto/source/parameter/index.rst +++ /dev/null @@ -1,9 +0,0 @@ -Parameter -========= - -.. toctree:: - :maxdepth: 2 - - parameter.rst - optimizer.rst - updater.rst diff --git a/doc/howto/source/parameter/optimizer.rst b/doc/howto/source/parameter/optimizer.rst deleted file mode 100644 index b5b8b850b349d547c9e5508d3ebec3d7e00ea310..0000000000000000000000000000000000000000 --- a/doc/howto/source/parameter/optimizer.rst +++ /dev/null @@ -1,22 +0,0 @@ -Optimizer -========= - -ParameterOptimizer ------------------- -.. doxygenfile:: paddle/parameter/ParameterOptimizer.h - -Regularizer ------------ -.. doxygenfile:: paddle/parameter/Regularizer.h - -FirstOrderOptimizer -------------------- -.. doxygenfile:: paddle/parameter/FirstOrderOptimizer.h - -AverageOptimizer ----------------- -.. doxygenfile:: paddle/parameter/AverageOptimizer.h - -OptimizerWithRegularizer ------------------------- -.. doxygenfile:: paddle/parameter/OptimizerWithRegularizer.h diff --git a/doc/howto/source/parameter/parameter.rst b/doc/howto/source/parameter/parameter.rst deleted file mode 100644 index 2daa62d4e63b952cd93bba35ee32ce35ce768a0d..0000000000000000000000000000000000000000 --- a/doc/howto/source/parameter/parameter.rst +++ /dev/null @@ -1,12 +0,0 @@ -Parameter -========= - -Parameter ---------- -.. doxygenfile:: paddle/parameter/Argument.h -.. doxygenfile:: paddle/parameter/Parameter.h -.. doxygenfile:: paddle/parameter/ParallelParameter.h - -Weight ------- -.. doxygenfile:: paddle/parameter/Weight.h diff --git a/doc/howto/source/parameter/updater.rst b/doc/howto/source/parameter/updater.rst deleted file mode 100644 index dfa22e8e7d1d6f0713974835de93194d2cc58e6f..0000000000000000000000000000000000000000 --- a/doc/howto/source/parameter/updater.rst +++ /dev/null @@ -1,14 +0,0 @@ -Updater -======= - -Base ----- -.. doxygenfile:: paddle/parameter/ParameterUpdaterBase.h - -Hook ----- -.. doxygenfile:: paddle/parameter/ParameterUpdaterHook.h - -Functions ---------- -.. doxygenfile:: paddle/parameter/ParameterUpdateFunctions.h diff --git a/doc/howto/source/pserver/client.rst b/doc/howto/source/pserver/client.rst deleted file mode 100644 index e5bba0706a1d919104b85e23861ba490a2c828db..0000000000000000000000000000000000000000 --- a/doc/howto/source/pserver/client.rst +++ /dev/null @@ -1,12 +0,0 @@ -Client -====== - -BaseClient ----------- -.. doxygenclass:: paddle::BaseClient - :members: - -ParameterClient2 ----------------- -.. doxygenclass:: paddle::ParameterClient2 - :members: diff --git a/doc/howto/source/pserver/index.rst b/doc/howto/source/pserver/index.rst deleted file mode 100644 index 0031e9476bd063511cc2f0a8c209f35627cf44ba..0000000000000000000000000000000000000000 --- a/doc/howto/source/pserver/index.rst +++ /dev/null @@ -1,10 +0,0 @@ -PServer -======= - -.. toctree:: - :maxdepth: 2 - - client.rst - network.rst - server.rst - utils.rst diff --git a/doc/howto/source/pserver/network.rst b/doc/howto/source/pserver/network.rst deleted file mode 100644 index 7004c9d91fa9f2af11e15791ef682c108761027e..0000000000000000000000000000000000000000 --- a/doc/howto/source/pserver/network.rst +++ /dev/null @@ -1,27 +0,0 @@ -Network -======= - -SocketServer ------------- -.. doxygenclass:: paddle::SocketServer - :members: - -SocketWorker ------------- -.. doxygenclass:: paddle::SocketWorker - :members: - -SocketClient ------------- -.. doxygenclass:: paddle::SocketClient - :members: - -SocketChannel -------------- -.. doxygenclass:: paddle::SocketChannel - :members: - -MessageReader -------------- -.. doxygenclass:: paddle::MsgReader - :members: diff --git a/doc/howto/source/pserver/server.rst b/doc/howto/source/pserver/server.rst deleted file mode 100644 index 35301acf8ffe3d97e6124c37cf8fe1b43071e14e..0000000000000000000000000000000000000000 --- a/doc/howto/source/pserver/server.rst +++ /dev/null @@ -1,12 +0,0 @@ -Server -====== - -ProtoServer ------------ -.. doxygenclass:: paddle::ProtoServer - :members: - -ParameterServer2 ----------------- -.. doxygenclass:: paddle::ParameterServer2 - :members: diff --git a/doc/howto/source/trainer.rst b/doc/howto/source/trainer.rst deleted file mode 100644 index 85f1feb4fc941f94e65a6b1d037445d2367f65ec..0000000000000000000000000000000000000000 --- a/doc/howto/source/trainer.rst +++ /dev/null @@ -1,32 +0,0 @@ -Trainer -======= - -TrainerStats ------------- - -.. doxygenclass:: paddle::TrainerStats - :members: - -RemoteParameterUpdater ------------------------ - -.. doxygenclass:: paddle::RemoteParameterUpdater - :members: - -ConcurrentRemoteParameterUpdater --------------------------------- - -.. doxygenclass:: paddle::ConcurrentRemoteParameterUpdater - :members: - -SparseRemoteParameterUpdater ----------------------------- - -.. doxygenclass:: paddle::SparseRemoteParameterUpdater - :members: - -SparseRemoteParameterUpdaterComposite -------------------------------------- - -.. doxygenclass:: paddle::SparseRemoteParameterUpdaterComposite - :members: diff --git a/doc/howto/source/utils/customStackTrace.rst b/doc/howto/source/utils/customStackTrace.rst deleted file mode 100644 index cdc8930739eb4b4d6308ff1fbce170d2977d42e8..0000000000000000000000000000000000000000 --- a/doc/howto/source/utils/customStackTrace.rst +++ /dev/null @@ -1,4 +0,0 @@ -CustomStackTrace -================ -.. doxygenclass:: paddle::CustomStackTrace - :members: diff --git a/doc/howto/source/utils/enum.rst b/doc/howto/source/utils/enum.rst deleted file mode 100644 index e0da75afe164f9dab59b862faa7230fc57423e50..0000000000000000000000000000000000000000 --- a/doc/howto/source/utils/enum.rst +++ /dev/null @@ -1,3 +0,0 @@ -Enumeration wrapper -=================== -.. doxygennamespace:: paddle::enumeration_wrapper diff --git a/doc/howto/source/utils/index.rst b/doc/howto/source/utils/index.rst deleted file mode 100644 index 7ddc47d1726f7627852be922d2b769d0752aa799..0000000000000000000000000000000000000000 --- a/doc/howto/source/utils/index.rst +++ /dev/null @@ -1,11 +0,0 @@ -Utils -===== - -.. toctree:: - :maxdepth: 2 - - lock.rst - queue.rst - thread.rst - customStackTrace.rst - enum.rst diff --git a/doc/howto/source/utils/lock.rst b/doc/howto/source/utils/lock.rst deleted file mode 100644 index f011acb9431f0f3dc3b2ba27fcfe71fe6eb07ae9..0000000000000000000000000000000000000000 --- a/doc/howto/source/utils/lock.rst +++ /dev/null @@ -1,32 +0,0 @@ -Lock -==== - -RWLock ------- -.. doxygenclass:: paddle::RWLock - :members: - -ReadLockGuard -------------- -.. doxygenclass:: paddle::ReadLockGuard - :members: - -SpinLock --------- -.. doxygenclass:: paddle::SpinLock - :members: - -Semaphore ---------- -.. doxygenclass:: paddle::Semaphore - :members: - -ThreadBarrier -------------- -.. doxygenclass:: paddle::ThreadBarrier - :members: - -LockedCondition ---------------- -.. doxygenclass:: paddle::LockedCondition - :members: diff --git a/doc/howto/source/utils/queue.rst b/doc/howto/source/utils/queue.rst deleted file mode 100644 index 98192648e2d61e622c2337d10ba024dd676ee685..0000000000000000000000000000000000000000 --- a/doc/howto/source/utils/queue.rst +++ /dev/null @@ -1,12 +0,0 @@ -Queue -===== - -Queue ------ -.. doxygenclass:: paddle::Queue - :members: - -BlockingQueue -------------- -.. doxygenclass:: paddle::BlockingQueue - :members: diff --git a/doc/howto/source/utils/thread.rst b/doc/howto/source/utils/thread.rst deleted file mode 100644 index 23d379a9894e5fc22bc6795a480a53d768e608e6..0000000000000000000000000000000000000000 --- a/doc/howto/source/utils/thread.rst +++ /dev/null @@ -1,27 +0,0 @@ -Thread -====== - -Thread ------- -.. doxygenclass:: paddle::Thread - :members: - -ThreadWorker ------------- -.. doxygenclass:: paddle::ThreadWorker - :members: - -SyncThreadPool --------------- -.. doxygenclass:: paddle::SyncThreadPool - :members: - -MultiThreadWorker ------------------ -.. doxygenclass:: paddle::MultiThreadWorker - :members: - -AsyncThreadPool ---------------- -.. doxygenclass:: paddle::AsyncThreadPool - :members: diff --git a/doc/index.rst b/doc/index.rst index 3555da1dfc81b29a89c7dfa6087d5fbb734a727b..c107239438b038fb6a4a6123e9b61f424b60142f 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -4,9 +4,8 @@ PaddlePaddle Documentation .. toctree:: :maxdepth: 1 - getstarted/index.rst - tutorials/index.md - howto/index.rst - api/index.rst - about/index.rst - \ No newline at end of file + getstarted/index_en.rst + tutorials/index_en.md + howto/index_en.rst + api/index_en.rst + about/index_en.rst diff --git a/doc/tutorials/embedding_model/index.md b/doc/tutorials/embedding_model/index_en.md similarity index 100% rename from doc/tutorials/embedding_model/index.md rename to doc/tutorials/embedding_model/index_en.md diff --git a/doc/tutorials/image_classification/index.rst b/doc/tutorials/image_classification/index.rst deleted file mode 100644 index 1ea68f14164b22cd211d09d72a7358fe24e4fed7..0000000000000000000000000000000000000000 --- a/doc/tutorials/image_classification/index.rst +++ /dev/null @@ -1,10 +0,0 @@ -Image Classification Tutorial -============================= - -.. toctree:: - :maxdepth: 3 - :glob: - - Training Locally - cluster_train/internal/cluster_train.md - cluster_train/opensource/cluster_train.md diff --git a/doc/tutorials/image_classification/image_classification.md b/doc/tutorials/image_classification/index_en.md similarity index 100% rename from doc/tutorials/image_classification/image_classification.md rename to doc/tutorials/image_classification/index_en.md diff --git a/doc/tutorials/imagenet_model/resnet_model.md b/doc/tutorials/imagenet_model/resnet_model_en.md similarity index 100% rename from doc/tutorials/imagenet_model/resnet_model.md rename to doc/tutorials/imagenet_model/resnet_model_en.md diff --git a/doc/tutorials/index.md b/doc/tutorials/index.md deleted file mode 100644 index ebf5397391e65e096b265f44a0ad81942f0b9ec2..0000000000000000000000000000000000000000 --- a/doc/tutorials/index.md +++ /dev/null @@ -1,21 +0,0 @@ -# TUTORIALS -There are serveral examples and demos here. - -## Image - -* [Image Classification](image_classification/index.rst) - -## NLP - -* [Sentiment Analysis](sentiment_analysis/index.rst) -* [Text Generation](text_generation/index.rst) -* [Semantic Role Labeling](semantic_role_labeling/index.rst) - -## Recommendation - -* [MovieLens Dataset](rec/ml_dataset.md) -* [MovieLens Regression](rec/ml_regression.rst) - -## Model Zoo -* [ImageNet: ResNet](imagenet_model/resnet_model.md) -* [Embedding: Chinese Word](embedding_model/index.md) diff --git a/doc/tutorials/index_en.md b/doc/tutorials/index_en.md new file mode 100644 index 0000000000000000000000000000000000000000..97de356665d23543ddc241552c6e3c896a78db86 --- /dev/null +++ b/doc/tutorials/index_en.md @@ -0,0 +1,23 @@ +# TUTORIALS +There are serveral examples and demos here. + +## [Quick Start](quick_start/index_en.md) + +## Image + +* [Image Classification](image_classification/index_en.md) + +## NLP + +* [Sentiment Analysis](sentiment_analysis/index_en.md) +* [Text Generation](text_generation/index_en.md) +* [Semantic Role Labeling](semantic_role_labeling/index_en.md) + +## Recommendation + +* [MovieLens Dataset](rec/ml_dataset_en.md) +* [MovieLens Regression](rec/ml_regression_en.rst) + +## Model Zoo +* [ImageNet: ResNet](imagenet_model/resnet_model_en.md) +* [Embedding: Chinese Word](embedding_model/index_en.md) diff --git a/doc/tutorials/quick_start/index_en.md b/doc/tutorials/quick_start/index_en.md index ec548b5393d7b210d6409328c00917aeb679a451..29637293fad79f3c3b9aabe83b71758b471b9338 100644 --- a/doc/tutorials/quick_start/index_en.md +++ b/doc/tutorials/quick_start/index_en.md @@ -12,7 +12,7 @@ This tutorial will teach the basics of deep learning (DL), including how to impl To get started, please install PaddlePaddle on your computer. Throughout this tutorial, you will learn by implementing different DL models for text classification. -To install PaddlePaddle, please follow the instructions here: Build and Install. +To install PaddlePaddle, please follow the instructions here: Build and Install. ## Overview For the first step, you will use PaddlePaddle to build a **text classification** system. For example, suppose you run an e-commence website, and you want to analyze the sentiment of user reviews to evaluate product quality. @@ -156,14 +156,14 @@ define_py_data_sources2(train_list='data/train.list', obj="process", args={"dictionary": word_dict}) ``` -You can refer to the following link for more detailed examples and data formats: PyDataProvider2. +You can refer to the following link for more detailed examples and data formats: PyDataProvider2. ## Network Architecture You will describe four kinds of network architectures in this section.
![](./PipelineNetwork_en.jpg)
First, you will build a logistic regression model. Later, you will also get chance to build other more powerful network architectures. -For more detailed documentation, you could refer to: Layer documentation。All configuration files are in `demo/quick_start` directory. +For more detailed documentation, you could refer to: layer documentation. All configuration files are in `demo/quick_start` directory. ### Logistic Regression The architecture is illustrated in the following picture: @@ -366,7 +366,7 @@ You can use single layer LSTM model with Dropout for our text classification pro
## Optimization Algorithm -Optimization algorithms include Momentum, RMSProp, AdaDelta, AdaGrad, Adam, and Adamax. You can use Adam optimization method here, with L2 regularization and gradient clipping, because Adam has been proved to work very well for training recurrent neural network. +Optimization algorithms include Momentum, RMSProp, AdaDelta, AdaGrad, Adam, and Adamax. You can use Adam optimization method here, with L2 regularization and gradient clipping, because Adam has been proved to work very well for training recurrent neural network. ```python settings(batch_size=128, @@ -391,7 +391,8 @@ paddle train \ --use_gpu=false ``` -If you want to install the remote training platform, which enables distributed training on clusters, follow the instructions here: Platform documentation. We do not provide examples on how to train on clusters. Please refer to other demos or platform training documentation for mode details on training on clusters. +We do not provide examples on how to train on clusters here. If you want to train on clusters, please follow the distributed training documentation or other demos for more details. + ## Inference You can use the trained model to perform prediction on the dataset with no labels. You can also evaluate the model on dataset with labels to obtain its test accuracy.
![](./PipelineTest_en.png)
@@ -406,7 +407,7 @@ paddle train \ --init_model_path=./output/pass-0000x ``` -We will give an example of performing prediction using Recurrent model on a dataset with no labels. You can refer to: Python Prediction API tutorial,or other demo for the prediction process using Python. You can also use the following script for inference or evaluation. +We will give an example of performing prediction using Recurrent model on a dataset with no labels. You can refer to Python Prediction API tutorial,or other demo for the prediction process using Python. You can also use the following script for inference or evaluation. inference script (predict.sh): @@ -508,7 +509,7 @@ The scripts of data downloading, network configurations, and training scrips are * \--config_args:Other configuration arguments. * \--init_model_path:The path of the initial model parameter. -By default, the trainer will save model every pass. You can also specify `saving_period_by_batches` to set the frequency of batch saving. You can use `show_parameter_stats_period` to print the statistics of the parameters, which are very useful for tuning parameters. Other command line arguments can be found in command line argument documentation。 +By default, the trainer will save model every pass. You can also specify `saving_period_by_batches` to set the frequency of batch saving. You can use `show_parameter_stats_period` to print the statistics of the parameters, which are very useful for tuning parameters. Other command line arguments can be found in command line argument documentation。 ### Log diff --git a/doc/tutorials/rec/ml_dataset.md b/doc/tutorials/rec/ml_dataset_en.md similarity index 98% rename from doc/tutorials/rec/ml_dataset.md rename to doc/tutorials/rec/ml_dataset_en.md index c93a4585e4027b1912da8a77c2562d1ee69c5366..dc11a5e06031b62d9f86e4dd83a14b2f1a72afc3 100644 --- a/doc/tutorials/rec/ml_dataset.md +++ b/doc/tutorials/rec/ml_dataset_en.md @@ -1,3 +1,8 @@ +```eval_rst +.. _demo_ml_dataset_en: + +``` + # MovieLens Dataset The [MovieLens Dataset](http://grouplens.org/datasets/movielens/) was collected by GroupLens Research. diff --git a/doc/tutorials/rec/ml_regression.rst b/doc/tutorials/rec/ml_regression_en.rst similarity index 90% rename from doc/tutorials/rec/ml_regression.rst rename to doc/tutorials/rec/ml_regression_en.rst index 0c14e4f5bb7f815a06c0c756b1a6e6ef9099fd66..ddc00dc706535e1204b033b505ee8bd579f8dea3 100644 --- a/doc/tutorials/rec/ml_regression.rst +++ b/doc/tutorials/rec/ml_regression_en.rst @@ -16,7 +16,7 @@ Data Preparation ```````````````` Download and extract dataset '''''''''''''''''''''''''''' -We use `movielens 1m dataset `_ here. +We use :ref:`demo_ml_dataset_en` here. To download and unzip the dataset, simply run the following commands. .. code-block:: bash @@ -239,26 +239,16 @@ Then we combine each features of movie into one movie feature by a get one user feature. Then we calculate the cosine similarity of these two features. -In these network, we use several api in `trainer_config_helpers -<../../ui/api/trainer_config_helpers/index.html>`_. There are - -* Data Layer, `data_layer - <../../ui/api/trainer_config_helpers/layers.html#id1>`_ -* Fully Connected Layer, `fc_layer - <../../ui/api/trainer_config_helpers/layers.html#fc-layer>`_ -* Embedding Layer, `embedding_layer - <../../ui/api/trainer_config_helpers/layers.html#embedding-layer>`_ -* Context Projection Layer, `context_projection - <../../ui/api/trainer_config_helpers/layers.html#context-projection>`_ -* Pooling Layer, `pooling_layer - <../../ui/api/trainer_config_helpers/layers.html#pooling-layer>`_ -* Cosine Similarity Layer, `cos_sim - <../../ui/api/trainer_config_helpers/layers.html#cos-sim>`_ -* Text Convolution Pooling Layer, `text_conv_pool - <../../ui/api/trainer_config_helpers/networks.html - #trainer_config_helpers.networks.text_conv_pool>`_ -* Declare Python Data Sources, `define_py_data_sources2 - <../../ui/api/trainer_config_helpers/data_sources.html>`_ +In these network, we use several api in :ref:`api_trainer_config` . There are + +* Data Layer, :ref:`api_trainer_config_helpers_layers_data_layer` +* Fully Connected Layer, :ref:`api_trainer_config_helpers_layers_fc_layer` +* Embedding Layer, :ref:`api_trainer_config_helpers_layers_embedding_layer` +* Context Projection Layer, :ref:`api_trainer_config_helpers_layers_context_projection` +* Pooling Layer, :ref:`api_trainer_config_helpers_layers_pooling_layer` +* Cosine Similarity Layer, :ref:`api_trainer_config_helpers_layers_cos_sim` +* Text Convolution Pooling Layer, :ref:`api_trainer_config_helpers_network_text_conv_pool` +* Declare Python Data Sources :ref:`api_trainer_config_helpers_data_sources`. Data Provider ''''''''''''' @@ -274,7 +264,7 @@ In this :code:`dataprovider.py`, we should set\: * use_seq\: Whether this :code:`dataprovider.py` in sequence mode or not. * process\: Return each sample of data to :code:`paddle`. -The data provider details document see `there <../../ui/data_provider/pydataprovider2.html>`_. +The data provider details document see :ref:`api_pydataprovider`. Train ````` @@ -290,8 +280,7 @@ The run.sh is shown as follow: It just start a paddle training process, write the log to `log.txt`, then print it on screen. -Each command line argument in :code:`run.sh`, please refer to the `command line -arguments <../../ui/index.html#command-line-argument>`_ page. The short description of these arguments is shown as follow. +Each command line argument in :code:`run.sh`, please refer to the :ref:`cmd_line_index_en` page. The short description of these arguments is shown as follow. * config\: Tell paddle which file is neural network configuration. * save_dir\: Tell paddle save model into './output' diff --git a/doc/tutorials/semantic_role_labeling/index.rst b/doc/tutorials/semantic_role_labeling/index.rst deleted file mode 100644 index ff3035059bd77a8688714db484e420b113c73e53..0000000000000000000000000000000000000000 --- a/doc/tutorials/semantic_role_labeling/index.rst +++ /dev/null @@ -1,7 +0,0 @@ -Semantic Role Labeling Tutorial -=============================== - -.. toctree:: - :maxdepth: 3 - - semantic_role_labeling.md diff --git a/doc/tutorials/semantic_role_labeling/index_cn.md b/doc/tutorials/semantic_role_labeling/index_cn.md new file mode 100644 index 0000000000000000000000000000000000000000..c7e0a78f5071ed0d1702036f4ee0af3881096c68 --- /dev/null +++ b/doc/tutorials/semantic_role_labeling/index_cn.md @@ -0,0 +1,201 @@ +# 语义角色标注教程 # + +语义角色标注(Semantic role labeling, SRL)是浅层语义解析的一种形式,其目的是在给定的输入句子中发现每个谓词的谓词论元结构。 SRL作为很多自然语言处理任务中的中间步骤是很有用的,如信息提取、文档自动分类和问答。 实例如下 [1]: + + [ A0 He ] [ AM-MOD would ][ AM-NEG n’t ] [ V accept] [ A1 anything of value ] from [A2 those he was writing about ]. + +- V: 动词 +- A0: 接受者 +- A1: 接受的东西 +- A2: 从……接受 +- A3: 属性 +- AM-MOD: 情态动词 +- AM-NEG: 否定 + +给定动词“accept”,句子中的组块将会扮演某些语义角色。这里,标签方案来自 Penn Proposition Bank。 + +到目前为止,大多数成功的SRL系统是建立在某种形式的句法分析结果之上的,使用了基于句法结构的预定义特征模板。 本教程将介绍使用深度双向长短期记忆(DB-LSTM)模型[2]的端到端系统来解决SRL任务,这在很大程度上优于先前的最先进的系统。 这个系统将SRL任务视为序列标注问题。 + +## 数据描述 +相关论文[2]采用 CoNLL-2005&2012 共享任务中设置的数据进行训练和测试。由于数据许可的原因,演示采用 CoNLL-2005 的测试数据集,可以在网站上找到。 + +用户只需执行以下命令就可以下载并处理原始数据: + +```bash +cd data +./get_data.sh +``` +`data `目录会出现如下几个新的文件: +```bash +conll05st-release:the test data set of CoNll-2005 shared task +test.wsj.words:the Wall Street Journal data sentences +test.wsj.props: the propositional arguments +feature: the extracted features from data set +``` + +## 训练 +### DB-LSTM +请参阅情感分析的演示以了解有关长期短期记忆单元的更多信息。 + +与在 Sentiment Analysis 演示中使用的 Bidirectional-LSTM 不同,DB-LSTM 采用另一种方法来堆叠LSTM层。首先,标准LSTM以正向处理该序列。该 LSTM 层的输入和输出作为下一个 LSTM 层的输入,并被反向处理。这两个标准 LSTM 层组成一对 LSTM。然后我们堆叠一对对的 LSTM 层后得到深度 LSTM 模型。 + +下图展示了时间扩展的2层 DB-LSTM 网络。 +
+![pic](./network_arch.png) +
+ +### 特征 +两个输入特征在这个流程中起着至关重要的作用:predicate(pred)和argument(arguments)。 还采用了两个其他特征:谓词上下文(ctx-p)和区域标记(mr)。 因为单个谓词不能精确地描述谓词信息,特别是当相同的词在句子中出现多于一次时。 使用谓词上下文,可以在很大程度上消除歧义。类似地,如果它位于谓词上下文区域中,则使用区域标记 mr = 1 来表示参数位置,反之则 mr = 0。这四个简单的特征是我们的SRL系统所需要的。上下文大小设置为1的一个样本的特征如下[2]所示: +
+![pic](./feature.jpg) +
+ +在这个示例中,相应的标记句子是: + +[ A1 A record date ] has [ AM-NEG n't ] been [ V set ] . + +在演示中, 我们采用上面的特征模板, 包括: `argument`, `predicate`, `ctx-p (p=-1,0,1)`, `mark` 并使用 `B/I/O` 方案来标记每个参数。这些特征和标签存储在 `feature` 文件中, 用`\t`分割。 + +### 数据提供 + +`dataprovider.py` 是一个包装数据的 Python 文件。 函数 `hook()` 定义了网络的数据槽。六个特征和标签都是索引槽。 +``` +def hook(settings, word_dict, label_dict, **kwargs): + settings.word_dict = word_dict + settings.label_dict = label_dict + #all inputs are integral and sequential type + settings.slots = [ + integer_value_sequence(len(word_dict)), + integer_value_sequence(len(predicate_dict)), + integer_value_sequence(len(word_dict)), + integer_value_sequence(len(word_dict)), + integer_value_sequence(len(word_dict)), + integer_value_sequence(len(word_dict)), + integer_value_sequence(len(word_dict)), + integer_value_sequence(2), + integer_value_sequence(len(label_dict))] +``` +相应的数据迭代器如下: +``` +@provider(init_hook=hook, should_shuffle=True, calc_batch_size=get_batch_size, + can_over_batch_size=False, cache=CacheType.CACHE_PASS_IN_MEM) +def process(settings, file_name): + with open(file_name, 'r') as fdata: + for line in fdata: + sentence, predicate, ctx_n2, ctx_n1, ctx_0, ctx_p1, ctx_p2, mark, label = \ + line.strip().split('\t') + + words = sentence.split() + sen_len = len(words) + word_slot = [settings.word_dict.get(w, UNK_IDX) for w in words] + + predicate_slot = [settings.predicate_dict.get(predicate)] * sen_len + ctx_n2_slot = [settings.word_dict.get(ctx_n2, UNK_IDX)] * sen_len + ctx_n1_slot = [settings.word_dict.get(ctx_n1, UNK_IDX)] * sen_len + ctx_0_slot = [settings.word_dict.get(ctx_0, UNK_IDX)] * sen_len + ctx_p1_slot = [settings.word_dict.get(ctx_p1, UNK_IDX)] * sen_len + ctx_p2_slot = [settings.word_dict.get(ctx_p2, UNK_IDX)] * sen_len + + marks = mark.split() + mark_slot = [int(w) for w in marks] + + label_list = label.split() + label_slot = [settings.label_dict.get(w) for w in label_list] + yield word_slot, predicate_slot, ctx_n2_slot, ctx_n1_slot, \ + ctx_0_slot, ctx_p1_slot, ctx_p2_slot, mark_slot, label_slot +``` +函数 `process` 返回8个特征list和1个标签list。 + +### 神经网络配置 + +`db_lstm.py` 是在训练过程中加载字典并定义数据提供程序模块和网络架构的神经网络配置文件。 + +九个 `data_layer` 从数据提供程序加载实例。八个特征分别转换为向量,并由`mixed_layer`混合。 深度双向LSTM层提取softmax层的特征。目标函数是标签的交叉熵。 + +### 训练 +训练的脚本是 `train.sh`,用户只需执行: +```bash + ./train.sh +``` +`train.sh` 中的内容: +``` +paddle train \ + --config=./db_lstm.py \ + --use_gpu=0 \ + --log_period=5000 \ + --trainer_count=1 \ + --show_parameter_stats_period=5000 \ + --save_dir=./output \ + --num_passes=10000 \ + --average_test_period=10000000 \ + --init_model_path=./data \ + --load_missing_parameter_strategy=rand \ + --test_all_data_in_one_period=1 \ +2>&1 | tee 'train.log' +``` + +- \--config=./db_lstm.py : 网络配置文件 +- \--use_gpu=false: 使用 CPU 训练(如果已安装 PaddlePaddle GPU版本并想使用 GPU 训练可以设置为true,目前 crf_layer 不支持 GPU) +- \--log_period=500: 每20个batch输出日志 +- \--trainer_count=1: 设置线程数(或 GPU 数) +- \--show_parameter_stats_period=5000: 每100个batch显示参数统计 +- \--save_dir=./output: 模型输出路径 +- \--num_passes=10000: 设置数据遍历次数,一个pass意味着PaddlePaddle训练数据集中的所有样本被遍历一次 +- \--average_test_period=10000000: 每个 average_test_period 批次对平均参数进行测试 +- \--init_model_path=./data: 参数初始化路径 +- \--load_missing_parameter_strategy=rand: 随机初始不存在的参数 +- \--test_all_data_in_one_period=1: 在一个周期内测试所有数据 + + +训练后,模型将保存在目录`output`中。 我们的训练曲线如下: +
+![pic](./curve.jpg) +
+ +### 测试 +测试脚本是 `test.sh`, 执行: +```bash + ./test.sh +``` +`tesh.sh` 的主要部分: +``` +paddle train \ + --config=./db_lstm.py \ + --model_list=$model_list \ + --job=test \ + --config_args=is_test=1 \ +``` + + - \--config=./db_lstm.py: 网络配置文件 + - \--model_list=$model_list.list: 模型列表文件 + - \--job=test: 指示测试任务 + - \--config_args=is_test=1: 指示测试任务的标记 + - \--test_all_data_in_one_period=1: 在一个周期内测试所有数据 + + +### 预测 +预测脚本是 `predict.sh`,用户只需执行: +```bash + ./predict.sh + +``` +在`predict.sh`中,用户应该提供网络配置文件,模型路径,标签文件,字典文件,特征文件。 +``` +python predict.py + -c $config_file \ + -w $best_model_path \ + -l $label_file \ + -p $predicate_dict_file \ + -d $dict_file \ + -i $input_file \ + -o $output_file +``` + +`predict.py` 是主要的可执行python脚本,其中包括函数:加载模型,加载数据,数据预测。网络模型将输出标签的概率分布。 在演示中,我们使用最大概率的标签作为结果。用户还可以根据概率分布矩阵实现柱搜索或维特比解码。 + +预测后,结果保存在 `predict.res` 中。 + +## 引用 +[1] Martha Palmer, Dan Gildea, and Paul Kingsbury. The Proposition Bank: An Annotated Corpus of Semantic Roles , Computational Linguistics, 31(1), 2005. + +[2] Zhou, Jie, and Wei Xu. "End-to-end learning of semantic role labeling using recurrent neural networks." Proceedings of the Annual Meeting of the Association for Computational Linguistics. 2015. diff --git a/doc/tutorials/semantic_role_labeling/semantic_role_labeling.md b/doc/tutorials/semantic_role_labeling/index_en.md similarity index 100% rename from doc/tutorials/semantic_role_labeling/semantic_role_labeling.md rename to doc/tutorials/semantic_role_labeling/index_en.md diff --git a/doc/tutorials/semantic_role_labeling/semantic_role_labeling_cn.md b/doc/tutorials/semantic_role_labeling/semantic_role_labeling_cn.md new file mode 100644 index 0000000000000000000000000000000000000000..f3c855a9fd72b894ab69050b08c750fe9e4aa1a2 --- /dev/null +++ b/doc/tutorials/semantic_role_labeling/semantic_role_labeling_cn.md @@ -0,0 +1,201 @@ +# 语义角色标注教程 # + +语义角色标注(Semantic role labeling, SRL)是浅语义解析的一种形式,其目的是在给定的输入句子中发现每个谓词的谓词参数结构。 SRL作为很多自然语言处理任务中的中间步骤是很有用的,如信息提取、文档自动分类和问答。 实例如下 [1]: + + [ A0 他 ] [ AM-MOD 将 ][ AM-NEG 不会 ] [ V 接受] [ A1 任何东西 ] 从 [A2 那些他写的东西中 ]。 + +- V: 动词 +- A0: 接受者 +- A1: 接受的东西 +- A2: 从……接受 +- A3: 属性 +- AM-MOD: 情态动词 +- AM-NEG: 否定 + +给定动词“接受”,句子中的大部分将会扮演某些语义角色。这里,标签方案来自 Penn Proposition Bank。 + +到目前为止,大多数成功的SRL系统是建立在某种形式的解析结果之上的,其中在语法结构上使用了预先定义的特征模板。 本教程将介绍使用深度双向长短期记忆(DB-LSTM)模型[2]的端到端系统来解决SRL任务,这在很大程度上优于先前的最先进的系统。 这个系统将SRL任务视为序列标记问题。 + +## 数据描述 +相关论文[2]采用 CoNLL-2005&2012 共享任务中设置的数据进行训练和测试。根据数据许可证,演示采用 CoNLL-2005 的测试数据集,可以在网站上找到。 + +用户只需执行以下命令就可以下载并处理原始数据: + +```bash +cd data +./get_data.sh +``` +`data `目录会出现如下几个新的文件: +```bash +conll05st-release:the test data set of CoNll-2005 shared task +test.wsj.words:the Wall Street Journal data sentences +test.wsj.props: the propositional arguments +feature: the extracted features from data set +``` + +## 训练 +### DB-LSTM +请参阅情绪分析的演示以了解有关长期短期记忆单元的更多信息。 + +与在 Sentiment Analysis 演示中使用的 Bidirectional-LSTM 不同,DB-LSTM 采用另一种方法来堆叠LSTM层。首先,标准LSTM以正向处理该序列。该 LSTM 层的输入和输出作为下一个 LSTM 层的输入,并被反向处理。这两个标准 LSTM 层组成一对 LSTM。然后我们堆叠一对对的 LSTM 层后得到深度 LSTM 模型。 + +下图展示了时间扩展的2层 DB-LSTM 网络。 +
+![pic](./network_arch.png) +
+ +### 特征 +两个输入特性在这个管道中起着至关重要的作用:predicate(pred)和argument(arguments)。 还采用了两个其他特征:谓词上下文(ctx-p)和区域标记(mr)。 因为单个谓词不能精确地描述谓词信息,特别是当相同的词在句子中出现多于一次时。 使用谓词上下文,可以在很大程度上消除歧义。类似地,如果它位于谓词上下文区域中,则使用区域标记 mr = 1 来表示参数位置,反之则 mr = 0。这四个简单的特征是我们的SRL系统所需要的。上下文大小设置为1的一个样本的特征如下[2]所示: +
+![pic](./feature.jpg) +
+ +在这个示例中,相应的标记句子是: + +[ A1 A record date ] has [ AM-NEG n't ] been [ V set ] . + +在演示中, 我们采用上面的特征模板, 包括: `argument`, `predicate`, `ctx-p (p=-1,0,1)`, `mark` 并使用 `B/I/O` 方案来标记每个参数。这些特征和标签存储在 `feature` 文件中, 用`\t`分割。 + +### 数据提供 + +`dataprovider.py` 是一个包装数据的 Python 文件。 函数 `hook()` 定义了网络的数据槽。六个特征和标签都是索引槽。 +``` +def hook(settings, word_dict, label_dict, **kwargs): + settings.word_dict = word_dict + settings.label_dict = label_dict + #all inputs are integral and sequential type + settings.slots = [ + integer_value_sequence(len(word_dict)), + integer_value_sequence(len(predicate_dict)), + integer_value_sequence(len(word_dict)), + integer_value_sequence(len(word_dict)), + integer_value_sequence(len(word_dict)), + integer_value_sequence(len(word_dict)), + integer_value_sequence(len(word_dict)), + integer_value_sequence(2), + integer_value_sequence(len(label_dict))] +``` +相应的数据迭代器如下: +``` +@provider(init_hook=hook, should_shuffle=True, calc_batch_size=get_batch_size, + can_over_batch_size=False, cache=CacheType.CACHE_PASS_IN_MEM) +def process(settings, file_name): + with open(file_name, 'r') as fdata: + for line in fdata: + sentence, predicate, ctx_n2, ctx_n1, ctx_0, ctx_p1, ctx_p2, mark, label = \ + line.strip().split('\t') + + words = sentence.split() + sen_len = len(words) + word_slot = [settings.word_dict.get(w, UNK_IDX) for w in words] + + predicate_slot = [settings.predicate_dict.get(predicate)] * sen_len + ctx_n2_slot = [settings.word_dict.get(ctx_n2, UNK_IDX)] * sen_len + ctx_n1_slot = [settings.word_dict.get(ctx_n1, UNK_IDX)] * sen_len + ctx_0_slot = [settings.word_dict.get(ctx_0, UNK_IDX)] * sen_len + ctx_p1_slot = [settings.word_dict.get(ctx_p1, UNK_IDX)] * sen_len + ctx_p2_slot = [settings.word_dict.get(ctx_p2, UNK_IDX)] * sen_len + + marks = mark.split() + mark_slot = [int(w) for w in marks] + + label_list = label.split() + label_slot = [settings.label_dict.get(w) for w in label_list] + yield word_slot, predicate_slot, ctx_n2_slot, ctx_n1_slot, \ + ctx_0_slot, ctx_p1_slot, ctx_p2_slot, mark_slot, label_slot +``` +函数 `process` 产出有8个特征和标签的9个表。 + +### 神经网络配置 + +`db_lstm.py` 是在训练过程中加载字典并定义数据提供程序模块和网络架构的神经网络配置文件。 + +九个 `data_layer` 从数据提供程序加载实例。八个特征分别转换为嵌入,并由`mixed_layer`混合。 深度双向LSTM层提取softmax层的特征。目标函数是标签的交叉熵。 + +### 训练 +训练的脚本是 `train.sh`,用户只需执行: +```bash + ./train.sh +``` +`train.sh` 中的内容: +``` +paddle train \ + --config=./db_lstm.py \ + --use_gpu=0 \ + --log_period=5000 \ + --trainer_count=1 \ + --show_parameter_stats_period=5000 \ + --save_dir=./output \ + --num_passes=10000 \ + --average_test_period=10000000 \ + --init_model_path=./data \ + --load_missing_parameter_strategy=rand \ + --test_all_data_in_one_period=1 \ +2>&1 | tee 'train.log' +``` + +- \--config=./db_lstm.py : 网络配置文件 +- \--use_gpu=false: 使用 CPU 训练(如果已安装 PaddlePaddle GPU版本并想使用 GPU 训练可以设置为true,目前 crf_layer 不支持 GPU) +- \--log_period=500: 每20批(batch)输出日志 +- \--trainer_count=1: 设置线程数(或 GPU 数) +- \--show_parameter_stats_period=5000: 每100批显示参数统计 +- \--save_dir=./output: 模型输出路径 +- \--num_passes=10000: 设置通过数,一次通过意味着PaddlePaddle训练数据集中的所有样本一次 +- \--average_test_period=10000000: 每个 average_test_period 批次对平均参数进行测试 +- \--init_model_path=./data: 参数初始化路径 +- \--load_missing_parameter_strategy=rand: 随机初始不存在的参数 +- \--test_all_data_in_one_period=1: 在一个周期内测试所有数据 + + +训练后,模型将保存在目录`output`中。 我们的训练曲线如下: +
+![pic](./curve.jpg) +
+ +### 测试 +测试脚本是 `test.sh`, 执行: +```bash + ./test.sh +``` +`tesh.sh` 的主要部分: +``` +paddle train \ + --config=./db_lstm.py \ + --model_list=$model_list \ + --job=test \ + --config_args=is_test=1 \ +``` + + - \--config=./db_lstm.py: 网络配置文件 + - \--model_list=$model_list.list: 模型列表文件 + - \--job=test: 指示测试任务 + - \--config_args=is_test=1: 指示测试任务的标记 + - \--test_all_data_in_one_period=1: 在一个周期内测试所有数据 + + +### 预测 +预测脚本是 `predict.sh`,用户只需执行: +```bash + ./predict.sh + +``` +在`predict.sh`中,用户应该提供网络配置文件,模型路径,标签文件,字典文件,特征文件。 +``` +python predict.py + -c $config_file \ + -w $best_model_path \ + -l $label_file \ + -p $predicate_dict_file \ + -d $dict_file \ + -i $input_file \ + -o $output_file +``` + +`predict.py` 是主要的可执行python脚本,其中包括函数:加载模型,加载数据,数据预测。网络模型将输出标签的概率分布。 在演示中,我们使用最大概率的标签作为结果。用户还可以根据概率分布矩阵实现集束搜索或维特比解码。 + +预测后,结果保存在 `predict.res` 中。 + +## 引用 +[1] Martha Palmer, Dan Gildea, and Paul Kingsbury. The Proposition Bank: An Annotated Corpus of Semantic Roles , Computational Linguistics, 31(1), 2005. + +[2] Zhou, Jie, and Wei Xu. "End-to-end learning of semantic role labeling using recurrent neural networks." Proceedings of the Annual Meeting of the Association for Computational Linguistics. 2015. diff --git a/doc/tutorials/sentiment_analysis/index.rst b/doc/tutorials/sentiment_analysis/index.rst deleted file mode 100644 index 9ee6d3a177c19de9fabf7b7e86c7c371bc094736..0000000000000000000000000000000000000000 --- a/doc/tutorials/sentiment_analysis/index.rst +++ /dev/null @@ -1,9 +0,0 @@ -Sentiment Analasis Tutorial -=========================== - -.. toctree:: - :maxdepth: 3 - :glob: - - Training Locally - internal/cluster_train.md diff --git a/doc/tutorials/sentiment_analysis/sentiment_analysis.md b/doc/tutorials/sentiment_analysis/index_en.md similarity index 96% rename from doc/tutorials/sentiment_analysis/sentiment_analysis.md rename to doc/tutorials/sentiment_analysis/index_en.md index c53952c544de9fa88a6318432e34b0d05b149445..bb7681db44ca6f286ad6935ddfecb9becb429192 100644 --- a/doc/tutorials/sentiment_analysis/sentiment_analysis.md +++ b/doc/tutorials/sentiment_analysis/index_en.md @@ -293,20 +293,21 @@ predict.sh: model=model_output/pass-00002/ config=trainer_config.py label=data/pre-imdb/labels.list -python predict.py \ - -n $config\ - -w $model \ - -b $label \ - -d data/pre-imdb/dict.txt \ - -i data/aclImdb/test/pos/10007_10.txt -``` - -* `predict.py`: predicting interface. -* -n $config : set network configure. -* -w $model: set model path. -* -b $label: set dictionary about corresponding relation between integer label and string label. -* -d data/pre-imdb/dict.txt: set dictionary. -* -i data/aclImdb/test/pos/10014_7.txt: set one example file to predict. +cat ./data/aclImdb/test/pos/10007_10.txt | python predict.py \ + --tconf=$config\ + --model=$model \ + --label=$label \ + --dict=./data/pre-imdb/dict.txt \ + --batch_size=1 +``` + +* `cat ./data/aclImdb/test/pos/10007_10.txt` : the input sample. +* `predict.py` : predicting interface. +* `--tconf=$config` : set network configure. +* ` --model=$model` : set model path. +* `--label=$label` : set dictionary about corresponding relation between integer label and string label. +* `--dict=data/pre-imdb/dict.txt` : set dictionary. +* `--batch_size=1` : set batch size. Note you should make sure the default model path `model_output/pass-00002` exists or change the model path. diff --git a/doc/tutorials/text_generation/index.rst b/doc/tutorials/text_generation/index.rst deleted file mode 100644 index 82da5524197ac8d4652f0e30f446b5a88bf1629d..0000000000000000000000000000000000000000 --- a/doc/tutorials/text_generation/index.rst +++ /dev/null @@ -1,9 +0,0 @@ -Text Generation Tutorial -======================== - -.. toctree:: - :maxdepth: 3 - :glob: - - Training Locally - internal/cluster_train.md diff --git a/doc/tutorials/text_generation/text_generation.md b/doc/tutorials/text_generation/index_en.md similarity index 100% rename from doc/tutorials/text_generation/text_generation.md rename to doc/tutorials/text_generation/index_en.md diff --git a/doc_cn/algorithm/rnn/glossary_rnn.dot b/doc_cn/algorithm/rnn/glossary_rnn.dot new file mode 100644 index 0000000000000000000000000000000000000000..2cd0fb1820c44b0e8e0b869f9d39fcad27efa758 --- /dev/null +++ b/doc_cn/algorithm/rnn/glossary_rnn.dot @@ -0,0 +1,42 @@ +digraph G{ + subgraph cluster_timestep0 { + label="recurrent timestep i-1" + bgcolor=lightgray + node [style=filled,color=white] + fc0_0 [label="fc 0"] + fc0_1 [label="fc 1"] + fc0_2 [label="fc 2"] + + fc0_0 -> fc0_1 + fc0_1 -> fc0_2 + } + + subgraph cluster_timestep1 { + label="recurrent timestep i" + node [style=filled]; + fc1_0 [label="fc 0"] + fc1_1 [label="fc 1"] + fc1_2 [label="fc 2"] + color=blue + + fc1_0 -> fc1_1 + fc1_1 -> fc1_2 + } + + subgraph cluster_timestep2 { + label="recurrent timestep i+1" + bgcolor=lightgray + node [style=filled,color=white] + fc2_0 [label="fc 0"] + fc2_1 [label="fc 1"] + fc2_2 [label="fc 2"] + + fc2_0 -> fc2_1 + fc2_1 -> fc2_2 + } + + + fc0_1 -> fc1_1 [style="dotted" constraint=false] + fc1_1 -> fc2_1 [style="dotted" constraint=false] + +} \ No newline at end of file diff --git a/doc_cn/algorithm/rnn/glossary_rnn_with_memory.dot b/doc_cn/algorithm/rnn/glossary_rnn_with_memory.dot new file mode 100644 index 0000000000000000000000000000000000000000..0f101ec2d8f15aec76c57f328046b6b55cf0c7eb --- /dev/null +++ b/doc_cn/algorithm/rnn/glossary_rnn_with_memory.dot @@ -0,0 +1,48 @@ +digraph G{ + subgraph cluster_timestep0 { + label="recurrent timestep i-1" + bgcolor=lightgray + node [style=filled,color=white] + fc0_0 [label="fc 0"] + fc0_1 [label="fc 1"] + fc0_2 [label="fc 2"] + m0 [label="memory"] + fc0_0 -> fc0_1 + fc0_1 -> fc0_2 + fc0_1 -> m0 + m0 -> fc0_1 + } + + subgraph cluster_timestep1 { + label="recurrent timestep i" + node [style=filled]; + fc1_0 [label="fc 0"] + fc1_1 [label="fc 1"] + fc1_2 [label="fc 2"] + m1 [label="memory"] + color=blue + fc1_0 -> fc1_1 + fc1_1 -> fc1_2 + fc1_1 -> m1 + m1 -> fc1_1 + } + + subgraph cluster_timestep2 { + label="recurrent timestep i+1" + bgcolor=lightgray + node [style=filled,color=white] + fc2_0 [label="fc 0"] + fc2_1 [label="fc 1"] + fc2_2 [label="fc 2"] + m2 [label="memory"] + fc2_0 -> fc2_1 + fc2_1 -> fc2_2 + fc2_1 -> m2 + m2 -> fc2_1 + } + + + m0 -> m1 [style="dotted" constraint=false] + m1 -> m2 [style="dotted" constraint=false] + +} \ No newline at end of file diff --git a/doc_cn/algorithm/rnn/hierarchical-rnn.md b/doc_cn/algorithm/rnn/hierarchical-rnn.md deleted file mode 100644 index c184a34e85a571e98e88c14ef653356fdd555a19..0000000000000000000000000000000000000000 --- a/doc_cn/algorithm/rnn/hierarchical-rnn.md +++ /dev/null @@ -1,403 +0,0 @@ -# 双层RNN配置与示例 - -我们在`paddle/gserver/tests/test_RecurrentGradientMachine`单测中,通过多组语义相同的单双层RNN配置,讲解如何使用双层RNN。 - -## 示例1:双进双出,subseq间无memory - -配置:单层RNN(`sequence_layer_group`)和双层RNN(`sequence_nest_layer_group`),语义完全相同。 - -### 读取双层序列的方法 - -首先,我们看一下单双层序列的不同数据组织形式(您也可以采用别的组织形式): - -- 单层序列的数据(`Sequence/tour_train_wdseg`)如下,一共有10个样本。每个样本由两部分组成,一个label(此处都为2)和一个已经分词后的句子。 - -```text -2 酒店 有 很 舒适 的 床垫 子 , 床上用品 也 应该 是 一人 一 换 , 感觉 很 利落 对 卫生 很 放心 呀 。 -2 很 温馨 , 也 挺 干净 的 * 地段 不错 , 出来 就 有 全家 , 离 地铁站 也 近 , 交通 很方便 * 就是 都 不 给 刷牙 的 杯子 啊 , 就 第一天 给 了 一次性杯子 * -2 位置 方便 , 强烈推荐 , 十一 出去玩 的 时候 选 的 , 对面 就是 华润万家 , 周围 吃饭 的 也 不少 。 -2 交通便利 , 吃 很 便利 , 乾 浄 、 安静 , 商务 房 有 电脑 、 上网 快 , 价格 可以 , 就 早餐 不 好吃 。 整体 是 不错 的 。 適 合 出差 來 住 。 -2 本来 准备 住 两 晚 , 第 2 天 一早 居然 停电 , 且 无 通知 , 只有 口头 道歉 。 总体来说 性价比 尚可 , 房间 较 新 , 还是 推荐 . -2 这个 酒店 去过 很多 次 了 , 选择 的 主要原因 是 离 客户 最 便宜 相对 又 近 的 酒店 -2 挺好 的 汉庭 , 前台 服务 很 热情 , 卫生 很 整洁 , 房间 安静 , 水温 适中 , 挺好 ! -2 HowardJohnson 的 品质 , 服务 相当 好 的 一 家 五星级 。 房间 不错 、 泳池 不错 、 楼层 安排 很 合理 。 还有 就是 地理位置 , 简直 一 流 。 就 在 天一阁 、 月湖 旁边 , 离 天一广场 也 不远 。 下次 来 宁波 还会 住 。 -2 酒店 很干净 , 很安静 , 很 温馨 , 服务员 服务 好 , 各方面 都 不错 * -2 挺好 的 , 就是 没 窗户 , 不过 对 得 起 这 价格 -``` - -- 双层序列的数据(`Sequence/tour_train_wdseg.nest`)如下,一共有4个样本。样本间用空行分开,代表不同的双层序列,序列数据和上面的完全一样。每个样本的子句数分别为2,3,2,3。 - -```text -2 酒店 有 很 舒适 的 床垫 子 , 床上用品 也 应该 是 一人 一 换 , 感觉 很 利落 对 卫生 很 放心 呀 。 -2 很 温馨 , 也 挺 干净 的 * 地段 不错 , 出来 就 有 全家 , 离 地铁站 也 近 , 交通 很方便 * 就是 都 不 给 刷牙 的 杯子 啊 , 就 第一天 给 了 一次性杯子 * - -2 位置 方便 , 强烈推荐 , 十一 出去玩 的 时候 选 的 , 对面 就是 华润万家 , 周围 吃饭 的 也 不少 。 -2 交通便利 , 吃 很 便利 , 乾 浄 、 安静 , 商务 房 有 电脑 、 上网 快 , 价格 可以 , 就 早餐 不 好吃 。 整体 是 不错 的 。 適 合 出差 來 住 。 -2 本来 准备 住 两 晚 , 第 2 天 一早 居然 停电 , 且 无 通知 , 只有 口头 道歉 。 总体来说 性价比 尚可 , 房间 较 新 , 还是 推荐 . - -2 这个 酒店 去过 很多 次 了 , 选择 的 主要原因 是 离 客户 最 便宜 相对 又 近 的 酒店 -2 挺好 的 汉庭 , 前台 服务 很 热情 , 卫生 很 整洁 , 房间 安静 , 水温 适中 , 挺好 ! - -2 HowardJohnson 的 品质 , 服务 相当 好 的 一 家 五星级 。 房间 不错 、 泳池 不错 、 楼层 安排 很 合理 。 还有 就是 地理位置 , 简直 一 流 。 就 在 天一阁 、 月湖 旁边 , 离 天一广场 也 不远 。 下次 来 宁波 还会 住 。 -2 酒店 很干净 , 很安静 , 很 温馨 , 服务员 服务 好 , 各方面 都 不错 * -2 挺好 的 , 就是 没 窗户 , 不过 对 得 起 这 价格 -``` - -其次,我们看一下单双层序列的不同dataprovider(见`sequenceGen.py`): - -- 单层序列的dataprovider如下: - - word_slot是integer_value_sequence类型,代表单层序列。 - - label是integer_value类型,代表一个向量。 - -```python -def hook(settings, dict_file, **kwargs): - settings.word_dict = dict_file - settings.input_types = [integer_value_sequence(len(settings.word_dict)), - integer_value(3)] - -@provider(init_hook=hook) -def process(settings, file_name): - with open(file_name, 'r') as fdata: - for line in fdata: - label, comment = line.strip().split('\t') - label = int(''.join(label.split())) - words = comment.split() - word_slot = [settings.word_dict[w] for w in words if w in settings.word_dict] - yield word_slot, label -``` - -- 双层序列的dataprovider如下: - - word_slot是integer_value_sub_sequence类型,代表双层序列。 - - label是integer_value_sequence类型,代表单层序列,即一个子句一个label。注意:也可以为integer_value类型,代表一个向量,即一个句子一个label。通常根据任务需求进行不同设置。 - - 关于dataprovider中input_types的详细用法,参见PyDataProvider2。 - -```python -def hook2(settings, dict_file, **kwargs): - settings.word_dict = dict_file - settings.input_types = [integer_value_sub_sequence(len(settings.word_dict)), - integer_value_sequence(3)] - -@provider(init_hook=hook2) -def process2(settings, file_name): - with open(file_name) as fdata: - label_list = [] - word_slot_list = [] - for line in fdata: - if (len(line)) > 1: - label,comment = line.strip().split('\t') - label = int(''.join(label.split())) - words = comment.split() - word_slot = [settings.word_dict[w] for w in words if w in settings.word_dict] - label_list.append(label) - word_slot_list.append(word_slot) - else: - yield word_slot_list, label_list - label_list = [] - word_slot_list = [] -``` - -### 模型中的配置 - -首先,我们看一下单层序列的配置(见`sequence_layer_group.conf`)。注意:batchsize=5表示一次过5句单层序列,因此2个batch就可以完成1个pass。 - -```python -settings(batch_size=5) - -data = data_layer(name="word", size=dict_dim) - -emb = embedding_layer(input=data, size=word_dim) - -# (lstm_input + lstm) is equal to lstmemory -with mixed_layer(size=hidden_dim*4) as lstm_input: - lstm_input += full_matrix_projection(input=emb) - -lstm = lstmemory_group(input=lstm_input, - size=hidden_dim, - act=TanhActivation(), - gate_act=SigmoidActivation(), - state_act=TanhActivation(), - lstm_layer_attr=ExtraLayerAttribute(error_clipping_threshold=50)) - -lstm_last = last_seq(input=lstm) - -with mixed_layer(size=label_dim, - act=SoftmaxActivation(), - bias_attr=True) as output: - output += full_matrix_projection(input=lstm_last) - -outputs(classification_cost(input=output, label=data_layer(name="label", size=1))) - -``` -其次,我们看一下语义相同的双层序列配置(见`sequence_nest_layer_group.conf`),并对其详细分析: - -- batchsize=2表示一次过2句双层序列。但从上面的数据格式可知,2句双层序列和5句单层序列的数据完全一样。 -- data_layer和embedding_layer不关心数据是否是序列格式,因此两个配置在这两层上的输出是一样的。 -- lstmemory: - - 单层序列过了一个mixed_layer和lstmemory_group。 - - 双层序列在同样的mixed_layer和lstmemory_group外,直接加了一层group。由于这个外层group里面没有memory,表示subseq间不存在联系,即起到的作用仅仅是把双层seq拆成单层,因此双层序列过完lstmemory的输出和单层的一样。 -- last_seq: - - 单层序列直接取了最后一个元素 - - 双层序列首先(last_seq层)取了每个subseq的最后一个元素,将其拼接成一个新的单层序列;接着(expand_layer层)将其扩展成一个新的双层序列,其中第i个subseq中的所有向量均为输入的单层序列中的第i个向量;最后(average_layer层)取了每个subseq的平均值。 - - 分析得出:第一个last_seq后,每个subseq的最后一个元素就等于单层序列的最后一个元素,而expand_layer和average_layer后,依然保持每个subseq最后一个元素的值不变(这两层仅是为了展示它们的用法,实际中并不需要)。因此单双层序列的输出是一样旳。 - -```python -settings(batch_size=2) - -data = data_layer(name="word", size=dict_dim) - -emb_group = embedding_layer(input=data, size=word_dim) - -# (lstm_input + lstm) is equal to lstmemory -def lstm_group(lstm_group_input): - with mixed_layer(size=hidden_dim*4) as group_input: - group_input += full_matrix_projection(input=lstm_group_input) - - lstm_output = lstmemory_group(input=group_input, - name="lstm_group", - size=hidden_dim, - act=TanhActivation(), - gate_act=SigmoidActivation(), - state_act=TanhActivation(), - lstm_layer_attr=ExtraLayerAttribute(error_clipping_threshold=50)) - return lstm_output - -lstm_nest_group = recurrent_group(input=SubsequenceInput(emb_group), - step=lstm_group, - name="lstm_nest_group") -# hasSubseq ->(seqlastins) seq -lstm_last = last_seq(input=lstm_nest_group, agg_level=AggregateLevel.EACH_SEQUENCE) - -# seq ->(expand) hasSubseq -lstm_expand = expand_layer(input=lstm_last, expand_as=emb_group, expand_level=ExpandLevel.FROM_SEQUENCE) - -# hasSubseq ->(average) seq -lstm_average = pooling_layer(input=lstm_expand, - pooling_type=AvgPooling(), - agg_level=AggregateLevel.EACH_SEQUENCE) - -with mixed_layer(size=label_dim, - act=SoftmaxActivation(), - bias_attr=True) as output: - output += full_matrix_projection(input=lstm_average) - -outputs(classification_cost(input=output, label=data_layer(name="label", size=1))) -``` -## 示例2:双进双出,subseq间有memory - -配置:单层RNN(`sequence_rnn.conf`),双层RNN(`sequence_nest_rnn.conf`和`sequence_nest_rnn_readonly_memory.conf`),语义完全相同。 - -### 读取双层序列的方法 - -我们看一下单双层序列的不同数据组织形式和dataprovider(见`rnn_data_provider.py`) -```python -data = [ - [[[1, 3, 2], [4, 5, 2]], 0], - [[[0, 2], [2, 5], [0, 1, 2]], 1], -] - -@provider(input_types=[integer_value_sub_sequence(10), - integer_value(3)]) -def process_subseq(settings, file_name): - for d in data: - yield d - -@provider(input_types=[integer_value_sequence(10), - integer_value(3)]) -def process_seq(settings, file_name): - for d in data: - seq = [] -``` -- 单层序列:有两句,分别为[1,3,2,4,5,2]和[0,2,2,5,0,1,2]。 -- 双层序列:有两句,分别为[[1,3,2],[4,5,2]](2个子句)和[[0,2],[2,5],[0,1,2]](3个子句)。 -- 单双层序列的label都分别是0和1 - -### 模型中的配置 - -我们选取单双层序列配置中的不同部分,来对比分析两者语义相同的原因。 - -- 单层序列:过了一个很简单的recurrent_group。每一个时间步,当前的输入y和上一个时间步的输出rnn_state做了一个全链接。 - -```python -def step(y): - mem = memory(name="rnn_state", size=hidden_dim) - return fc_layer(input=[y, mem], - size=hidden_dim, - act=TanhActivation(), - bias_attr=True, - name="rnn_state") - -out = recurrent_group(step=step, input=emb) -``` -- 双层序列,外层memory是一个元素: - - 内层inner_step的recurrent_group和单层序列的几乎一样。除了boot_layer=outer_mem,表示将外层的outer_mem作为内层memory的初始状态。外层outer_step中,outer_mem是一个子句的最后一个向量,即整个双层group是将前一个子句的最后一个向量,作为下一个子句memory的初始状态。 - - 从输入数据上看,单双层序列的句子是一样的,只是双层序列将其又做了子序列划分。因此双层序列的配置中,必须将前一个子句的最后一个元素,作为boot_layer传给下一个子句的memory,才能保证和单层序列的配置中“每一个时间步都用了上一个时间步的输出结果”一致。 - -```python -def outer_step(x): - outer_mem = memory(name="outer_rnn_state", size=hidden_dim) - def inner_step(y): - inner_mem = memory(name="inner_rnn_state", - size=hidden_dim, - boot_layer=outer_mem) - return fc_layer(input=[y, inner_mem], - size=hidden_dim, - act=TanhActivation(), - bias_attr=True, - name="inner_rnn_state") - - inner_rnn_output = recurrent_group( - step=inner_step, - input=x) - last = last_seq(input=inner_rnn_output, name="outer_rnn_state") - - return inner_rnn_output - -out = recurrent_group(step=outer_step, input=SubsequenceInput(emb)) -``` -- 双层序列,外层memory是单层序列: - - 由于外层每个时间步返回的是一个子句,这些子句的长度往往不等长。因此当外层有is_seq=True的memory时,内层是**无法直接使用**它的,即内层memory的boot_layer不能链接外层的这个memory。 - - 如果内层memory想**间接使用**这个外层memory,只能通过`pooling_layer`、`last_seq`或`first_seq`这三个layer将它先变成一个元素。但这种情况下,外层memory必须有boot_layer,否则在第0个时间步时,由于外层memory没有任何seq信息,因此上述三个layer的前向会报出“**Check failed: input.sequenceStartPositions**”的错误。 - -## 示例3:双进双出,输入不等长 - -**输入不等长**是指recurrent_group的多个输入在各时刻的长度可以不相等, 但需要指定一个和输出长度一致的input,用targetInlink表示。参考配置:单层RNN(`sequence_rnn_multi_unequalength_inputs.conf`),双层RNN(`sequence_nest_rnn_multi_unequalength_inputs.conf`) - -### 读取双层序列的方法 - -我们看一下单双层序列的数据组织形式和dataprovider(见`rnn_data_provider.py`) -```python -data2 = [ - [[[1, 2], [4, 5, 2]], [[5, 4, 1], [3, 1]] ,0], - [[[0, 2], [2, 5], [0, 1, 2]],[[1, 5], [4], [2, 3, 6, 1]], 1], -] - -@provider(input_types=[integer_value_sub_sequence(10), - integer_value_sub_sequence(10), - integer_value(2)], - should_shuffle=False) -def process_unequalength_subseq(settings, file_name): #双层RNN的dataprovider - for d in data2: - yield d - - -@provider(input_types=[integer_value_sequence(10), - integer_value_sequence(10), - integer_value(2)], - should_shuffle=False) -def process_unequalength_seq(settings, file_name): #单层RNN的dataprovider - for d in data2: - words1=reduce(lambda x,y: x+y, d[0]) - words2=reduce(lambda x,y: x+y, d[1]) - yield words1, words2, d[2] -``` - -data2 中有两个样本,每个样本有两个特征, 记fea1, fea2。 - -- 单层序列:两个样本分别为[[1, 2, 4, 5, 2], [5, 4, 1, 3, 1]] 和 [[0, 2, 2, 5, 0, 1, 2], [1, 5, 4, 2, 3, 6, 1]] -- 双层序列:两个样本分别为 - - **样本1**:[[[1, 2], [4, 5, 2]], [[5, 4, 1], [3, 1]]]。fea1和fea2都分别有2个子句,fea1=[[1, 2], [4, 5, 2]], fea2=[[5, 4, 1], [3, 1]] - - **样本2**:[[[0, 2], [2, 5], [0, 1, 2]],[[1, 5], [4], [2, 3, 6, 1]]]。fea1和fea2都分别有3个子句, fea1=[[0, 2], [2, 5], [0, 1, 2]], fea2=[[1, 5], [4], [2, 3, 6, 1]]。
- - **注意**:每个样本中,各特征的子句数目需要相等。这里说的“双进双出,输入不等长”是指fea1在i时刻的输入的长度可以不等于fea2在i时刻的输入的长度。如对于第1个样本,时刻i=2, fea1[2]=[4, 5, 2],fea2[2]=[3, 1],3≠2。 -- 单双层序列中,两个样本的label都分别是0和1 - -### 模型中的配置 - -单层RNN(`sequence_rnn_multi_unequalength_inputs.conf`)和双层RNN(`sequence_nest_rnn_multi_unequalength_inputs.conf`)两个模型配置达到的效果完全一样,区别只在于输入为单层还是双层序列,现在我们来看它们内部分别是如何实现的。 - -- 单层序列: - - 过了一个简单的recurrent_group。每一个时间步,当前的输入y和上一个时间步的输出rnn_state做了一个全连接,功能与示例2中`sequence_rnn.conf`的`step`函数完全相同。这里,两个输入x1,x2分别通过calrnn返回最后时刻的状态。结果得到的encoder1_rep和encoder2_rep分别是单层序列,最后取encoder1_rep的最后一个时刻和encoder2_rep的所有时刻分别相加得到context。 - - 注意到这里recurrent_group输入的每个样本中,fea1和fea2的长度都分别相等,这并非偶然,而是因为recurrent_group要求输入为单层序列时,所有输入的长度都必须相等。 - -```python -def step(x1, x2): - def calrnn(y): - mem = memory(name = 'rnn_state_' + y.name, size = hidden_dim) - out = fc_layer(input = [y, mem], - size = hidden_dim, - act = TanhActivation(), - bias_attr = True, - name = 'rnn_state_' + y.name) - return out - - encoder1 = calrnn(x1) - encoder2 = calrnn(x2) - return [encoder1, encoder2] - -encoder1_rep, encoder2_rep = recurrent_group( - name="stepout", - step=step, - input=[emb1, emb2]) - -encoder1_last = last_seq(input = encoder1_rep) -encoder1_expandlast = expand_layer(input = encoder1_last, - expand_as = encoder2_rep) -context = mixed_layer(input = [identity_projection(encoder1_expandlast), - identity_projection(encoder2_rep)], - size = hidden_dim) -``` -- 双层序列: - - 双层RNN中,对输入的两个特征分别求时序上的连续全连接(`inner_step1`和`inner_step2`分别处理fea1和fea2),其功能与示例2中`sequence_nest_rnn.conf`的`outer_step`函数完全相同。不同之处是,此时输入`[SubsequenceInput(emb1), SubsequenceInput(emb2)]`在各时刻并不等长。 - - 函数`outer_step`中可以分别处理这两个特征,但我们需要用targetInlink指定recurrent_group的输出的格式(各子句长度)只能和其中一个保持一致,如这里选择了和emb2的长度一致。 - - 最后,依然是取encoder1_rep的最后一个时刻和encoder2_rep的所有时刻分别相加得到context。 - -```python -def outer_step(x1, x2): - outer_mem1 = memory(name = "outer_rnn_state1", size = hidden_dim) - outer_mem2 = memory(name = "outer_rnn_state2", size = hidden_dim) - def inner_step1(y): - inner_mem = memory(name = 'inner_rnn_state_' + y.name, - size = hidden_dim, - boot_layer = outer_mem1) - out = fc_layer(input = [y, inner_mem], - size = hidden_dim, - act = TanhActivation(), - bias_attr = True, - name = 'inner_rnn_state_' + y.name) - return out - - def inner_step2(y): - inner_mem = memory(name = 'inner_rnn_state_' + y.name, - size = hidden_dim, - boot_layer = outer_mem2) - out = fc_layer(input = [y, inner_mem], - size = hidden_dim, - act = TanhActivation(), - bias_attr = True, - name = 'inner_rnn_state_' + y.name) - return out - - encoder1 = recurrent_group( - step = inner_step1, - name = 'inner1', - input = x1) - - encoder2 = recurrent_group( - step = inner_step2, - name = 'inner2', - input = x2) - - sentence_last_state1 = last_seq(input = encoder1, name = 'outer_rnn_state1') - sentence_last_state2_ = last_seq(input = encoder2, name = 'outer_rnn_state2') - - encoder1_expand = expand_layer(input = sentence_last_state1, - expand_as = encoder2) - - return [encoder1_expand, encoder2] - -encoder1_rep, encoder2_rep = recurrent_group( - name="outer", - step=outer_step, - input=[SubsequenceInput(emb1), SubsequenceInput(emb2)], - targetInlink=emb2) - -encoder1_last = last_seq(input = encoder1_rep) -encoder1_expandlast = expand_layer(input = encoder1_last, - expand_as = encoder2_rep) -context = mixed_layer(input = [identity_projection(encoder1_expandlast), - identity_projection(encoder2_rep)], - size = hidden_dim) -``` - -## 示例4:beam_search的生成 - -TBD diff --git a/doc_cn/algorithm/rnn/hrnn_demo.rst b/doc_cn/algorithm/rnn/hrnn_demo.rst new file mode 100644 index 0000000000000000000000000000000000000000..96396ff105d134920396ded9ad8f00494357a37c --- /dev/null +++ b/doc_cn/algorithm/rnn/hrnn_demo.rst @@ -0,0 +1,7 @@ +.. _algo_hrnn_demo: + +################# +双层RNN的使用示例 +################# + +TBD \ No newline at end of file diff --git a/doc_cn/algorithm/rnn/hrnn_rnn_api_compare.rst b/doc_cn/algorithm/rnn/hrnn_rnn_api_compare.rst new file mode 100644 index 0000000000000000000000000000000000000000..9baa0b578041ab82331a94c2a9e4d081697a5fda --- /dev/null +++ b/doc_cn/algorithm/rnn/hrnn_rnn_api_compare.rst @@ -0,0 +1,230 @@ +.. _algo_hrnn_rnn_api_compare: + +##################### +单双层RNN API对比介绍 +##################### + +本文以PaddlePaddle的双层RNN单元测试为示例,用多对效果完全相同的、分别使用单双层RNN作为网络配置的模型,来讲解如何使用双层RNN。本文中所有的例子,都只是介绍双层RNN的API接口,并不是使用双层RNN解决实际的问题。如果想要了解双层RNN在具体问题中的使用,请参考\ :ref:`algo_hrnn_demo`\ 。本文中示例所使用的单元测试文件是\ `test_RecurrentGradientMachine.cpp `_\ 。 + +示例1:双层RNN,子序列间无Memory +================================ + +在双层RNN中的经典情况是将内层的每一个时间序列数据,分别进行序列操作;并且内层的序列操作之间独立无依赖,即不需要使用Memory\ 。 + +在本示例中,单层RNN和双层RNN的网络配置,都是将每一句分好词后的句子,使用LSTM作为encoder,压缩成一个向量。区别是RNN使用两层序列模型,将多句话看成一个整体同时使用encoder压缩。二者语意上完全一致。这组语义相同的示例配置如下: + +* 单层RNN\: `sequence_layer_group.conf `_ +* 双层RNN\: `sequence_nest_layer_group.conf `_ + + +读取双层序列数据 +---------------- + +首先,本示例中使用的原始数据如下\: + +- 本例中的原始数据一共有10个样本。每个样本由两部分组成,一个label(此处都为2)和一个已经分词后的句子。这个数据也被单层RNN网络直接使用。 + +.. literalinclude:: ../../../paddle/gserver/tests/Sequence/tour_train_wdseg + :language: text + + +- 双层序列数据一共有4个样本。 每个样本间用空行分开,整体数据和原始数据完全一样。但于双层序列的LSTM来说,第一个样本同时encode两条数据成两个向量。这四条数据同时处理的句子数量为\ :code:`[2, 3, 2, 3]`\ 。 + +.. literalinclude:: ../../../paddle/gserver/tests/Sequence/tour_train_wdseg.nest + :language: text + +其次,对于两种不同的输入数据类型,不同DataProvider对比如下(`sequenceGen.py `_)\: + +.. literalinclude:: ../../../paddle/gserver/tests/sequenceGen.py + :language: python + :lines: 21-39 + :linenos: + +- 这是普通的单层时间序列的DataProvider代码,其说明如下: + + * DataProvider共返回两个数据,分别是words和label。即上述代码中的第19行。 + - words是原始数据中的每一句话,所对应的词表index数组。它是integer_value_sequence类型的,即整数数组。words即为这个数据中的单层时间序列。 + - label是原始数据中对于每一句话的分类标签,它是integer_value类型的。 + +.. literalinclude:: ../../../paddle/gserver/tests/sequenceGen.py + :language: python + :lines: 42-71 + :linenos: + +- 对于同样的数据,双层时间序列的DataProvider的代码。其说明如下: + + - DataProvider共返回两组数据,分别是sentences和labels。即在双层序列的原始数据中,每一组内的所有句子和labels + - sentences是双层时间序列的数据。由于它内部包含了每组数据中的所有句子,且每个句子表示为对应的词表索引数组,因此它是integer_value_sub_sequence 类型的,即双层时间序列。 + - labels是每组内每个句子的标签,故而是一个单层时间序列。 + + +模型配置的模型配置 +------------------------------------------ + +首先,我们看一下单层RNN的配置。代码中9-15行(高亮部分)即为单层RNN序列的使用代码。这里使用了PaddlePaddle预定义好的RNN处理函数。在这个函数中,RNN对于每一个时间步通过了一个LSTM网络。 + +.. literalinclude:: ../../../paddle/gserver/tests/sequence_layer_group.conf + :language: python + :lines: 38-63 + :linenos: + :emphasize-lines: 9-15 + + +其次,我们看一下语义相同的双层RNN的网络配置\: + +* PaddlePaddle中的许多layer并不在意输入是否是时间序列,例如\ :code:`embedding_layer`\ 。在这些layer中,所有的操作都是针对每一个时间步来进行的。 + +* 在该配置的7-26行(高亮部分),将双层时间序列数据先变换成单层时间序列数据,再对每一个单层时间序列进行处理。 + + * 使用\ :code:`recurrent_group`\ 这个函数进行变换,在变换时需要将输入序列传入。由于我们想要的变换是双层时间序列=> 单层时间序列,所以我们需要将输入数据标记成\ :code:`SubsequenceInput`\ 。 + + * 在本例中,我们将原始数据的每一组,通过\ :code:`recurrent_group`\ 进行拆解,拆解成的每一句话再通过一个LSTM网络。这和单层RNN的配置是等价的。 + +* 与单层RNN的配置类似,我们只需要使用LSTM encode成的最后一个向量。所以对\ :code:`recurrent_group`\ 进行了\ :code:`last_seq`\ 操作。但和单层RNN不同,我们是对每一个子序列取最后一个元素,因此\ :code:`agg_level=AggregateLevel.EACH_SEQUENCE`\ 。 + +* 至此,\ :code:`lstm_last`\ 便和单层RNN配置中的\ :code:`lstm_last`\ 具有相同的结果了。 + +.. literalinclude:: ../../../paddle/gserver/tests/sequence_nest_layer_group.conf + :language: python + :lines: 38-64 + :linenos: + :emphasize-lines: 7-26 + +示例2:双层RNN,子序列间有Memory +================================ + +本示例意图使用单层RNN和双层RNN实现两个完全等价的全连接RNN。 + +* 对于单层RNN,输入数据为一个完整的时间序列,例如\ :code:`[4, 5, 2, 0, 9, 8, 1, 4]`\ 。 + +* 对于双层RNN,输入数据为在单层RNN数据里面,任意将一些数据组合成双层时间序列,例如\ :code:`[ [4, 5, 2], [0, 9], [8, 1, 4]]`。 + +模型配置的模型配置 +------------------ + +我们选取单双层序列配置中的不同部分,来对比分析两者语义相同的原因。 + +- 单层RNN:过了一个很简单的recurrent_group。每一个时间步,当前的输入y和上一个时间步的输出rnn_state做了一个全链接。 + +.. literalinclude:: ../../../paddle/gserver/tests/sequence_rnn.conf + :language: python + :lines: 36-48 + +- 双层RNN,外层memory是一个元素: + + - 内层inner_step的recurrent_group和单层序列的几乎一样。除了boot_layer=outer_mem,表示将外层的outer_mem作为内层memory的初始状态。外层outer_step中,outer_mem是一个子句的最后一个向量,即整个双层group是将前一个子句的最后一个向量,作为下一个子句memory的初始状态。 + - 从输入数据上看,单双层序列的句子是一样的,只是双层序列将其又做了子序列划分。因此双层序列的配置中,必须将前一个子句的最后一个元素,作为boot_layer传给下一个子句的memory,才能保证和单层序列的配置中“每个时间步都用了上一个时间步的输出结果”一致。 + +.. literalinclude:: ../../../paddle/gserver/tests/sequence_nest_rnn.conf + :language: python + :lines: 39-66 + +.. warning:: + PaddlePaddle目前只支持在每个时间步中,Memory的时间序列长度一致的情况。 + +示例3:双层RNN,输入不等长 +========================== + +.. role:: red + +.. raw:: html + + + +**输入不等长** 是指recurrent_group的多个输入序列,在每个时间步的子序列长度可以不相等。但序列输出时,需要指定与某一个输入的序列信息是一致的。使用\ :red:`targetInlink`\ 可以指定哪一个输入和输出序列信息一致,默认指定第一个输入。 + +示例3的配置分别为\ `单层不等长RNN `_\ 和\ `双层不等长RNN `_\ 。 + +示例3对于单层RNN和双层RNN数据完全相同。 + +* 对于单层RNN的数据一共有两个样本,他们分别是\ :code:`[1, 2, 4, 5, 2], [5, 4, 1, 3, 1]`\ 和\ :code:`[0, 2, 2, 5, 0, 1, 2], [1, 5, 4, 2, 3, 6, 1]`\ 。对于每一个单层RNN的数据,均有两组特征。 + +* 在单层数据的基础上,双层RNN数据随意加了一些隔断,例如将第一条数据转化为\ :code:`[[0, 2], [2, 5], [0, 1, 2]],[[1, 5], [4], [2, 3, 6, 1]]`\ 。 + +* 需要注意的是PaddlePaddle目前只支持子序列数目一样的多输入双层RNN。例如本例中的两个特征,均有三个子序列。每个子序列长度可以不一致,但是子序列的数目必须一样。 + + +模型配置 +-------- + +和示例2中的配置类似,示例3的配置使用了单层RNN和双层RNN,实现两个完全等价的全连接RNN。 + +* 单层RNN\: + +.. literalinclude:: ../../../paddle/gserver/tests/sequence_rnn_multi_unequalength_inputs.py + :language: python + :lines: 42-59 + :linenos: + +* 双层RNN\ \: + +.. literalinclude:: ../../../paddle/gserver/tests/sequence_nest_rnn_multi_unequalength_inputs.py + :language: python + :lines: 41-80 + :linenos: + +在上面代码中,单层和双层序列的使用和示例2中的示例类似,区别是同时处理了两个输入。而对于双层序列,两个输入的子序列长度也并不相同。但是,我们使用了\ :code:`targetInlink`\ 参数设置了外层\ :code:`recurrent_group`\ 的输出格式。所以外层输出的序列形状,和\ :code:`emb2`\ 的序列形状一致。 + +示例4:beam_search的生成 +======================== + +TBD + + +词汇表 +====== + +.. _glossary_memory: + +Memory +------ + +Memory是PaddlePaddle实现RNN时候使用的一个概念。RNN即时间递归神经网络,通常要求时间步之间具有一些依赖性,即当前时间步下的神经网络依赖前一个时间步神经网络中某一个神经元输出。如下图所示。 + +.. graphviz:: glossary_rnn.dot + +上图中虚线的连接,即是跨越时间步的网络连接。PaddlePaddle在实现RNN的时候,将这种跨越时间步的连接用一个特殊的神经网络单元实现。这个神经网络单元就叫Memory。Memory可以缓存上一个时刻某一个神经元的输出,然后在下一个时间步输入给另一个神经元。使用Memory的RNN实现便如下图所示。 + +.. graphviz:: glossary_rnn_with_memory.dot + +使用这种方式,PaddlePaddle可以比较简单的判断哪些输出是应该跨越时间步的,哪些不是。 + +.. _glossary_timestep: + +时间步 +------ + +参考时间序列。 + + +.. _glossary_sequence: + +时间序列 +-------- + +时间序列(time series)是指一系列的特征数据。这些特征数据之间的顺序是有意义的。即特征的数组,而不是特征的集合。而这每一个数组元素,或者每一个系列里的特征数据,即为一个时间步(time step)。值得注意的是,时间序列、时间步的概念,并不真正的和『时间』有关。只要一系列特征数据中的『顺序』是有意义的,即为时间序列的输入。 + +举例说明,例如文本分类中,我们通常将一句话理解成一个时间序列。比如一句话中的每一个单词,会变成词表中的位置。而这一句话就可以表示成这些位置的数组。例如 :code:`[9, 2, 3, 5, 3]` 。 + +关于时间序列(time series)的更详细准确的定义,可以参考 `维基百科页面 Time series `_ 或者 `维基百科中文页面 时间序列 `_ 。 + +另外,Paddle中经常会将时间序列成为 :code:`Sequence` 。他们在Paddle的文档和API中是一个概念。 + +.. _glossary_RNN: + +RNN +--- + +RNN 在PaddlePaddle的文档中,一般表示 :code:`Recurrent neural network`,即时间递归神经网络。详细介绍可以参考 `维基百科页面 Recurrent neural network `_ 或者 `中文维基百科页面 `_ 中关于时间递归神经网络的介绍。 + +RNN 一般在PaddlePaddle中,指对于一个时间序列输入数据,每一个时间步之间的神经网络具有一定的相关性。例如,某一个神经元的一个输入为上一个时间步网络中某一个神经元的输出。或者,从每一个时间步来看,神经网络的网络结构中具有有向环结构。 + +.. _glossary_双层RNN: + +双层RNN +------- + +双层RNN顾名思义,即RNN之间有一次嵌套关系。输入数据整体上是一个时间序列,而对于每一个内层特征数据而言,也是一个时间序列。即二维数组,或者数组的数组这个概念。 而双层RNN是可以处理这种输入数据的网络结构。 + +例如,对于段落的文本分类,即将一段话进行分类。我们将一段话看成句子的数组,每个句子又是单词的数组。这便是一种双层RNN的输入数据。而将这个段落的每一句话用lstm编码成一个向量,再对每一句话的编码向量用lstm编码成一个段落的向量。再对这个段落向量进行分类,即为这个双层RNN的网络结构。 + diff --git a/doc_cn/algorithm/rnn/simple_full_hierarchical_recurrent.dot b/doc_cn/algorithm/rnn/simple_full_hierarchical_recurrent.dot new file mode 100644 index 0000000000000000000000000000000000000000..ff278a0323bb2c3ef07bf6f016a3a8df05783581 --- /dev/null +++ b/doc_cn/algorithm/rnn/simple_full_hierarchical_recurrent.dot @@ -0,0 +1,30 @@ +digraph G { + rankdir=LR; + + subgraph cluster_t0 { + a [label="4"] + b [label="5"] + c [label="2"] + } + + subgraph cluster_t1 { + d [label="0"] + e [label="9"] + } + + subgraph cluster_t2 { + f [label="8"] + g [label="1"] + h [label="4"] + } + + a -> b; + b -> c; + c -> d [constraint=false]; + + d -> e; + e -> f [constraint=false]; + + f -> g; + g -> h; +} \ No newline at end of file diff --git a/doc_cn/algorithm/rnn/simple_full_recurrent.dot b/doc_cn/algorithm/rnn/simple_full_recurrent.dot new file mode 100644 index 0000000000000000000000000000000000000000..cee281fbac993afbd0cc3416570f95965cdf0a59 --- /dev/null +++ b/doc_cn/algorithm/rnn/simple_full_recurrent.dot @@ -0,0 +1,19 @@ +digraph G { + rankdir=LR; + a [label="4"] + b [label="5"] + c [label="2"] + d [label="0"] + e [label="9"] + f [label="8"] + g [label="1"] + h [label="4"] + + a -> b; + b -> c; + c -> d; + d -> e; + e -> f; + f -> g; + g -> h; +} \ No newline at end of file diff --git a/doc_cn/cluster/k8s/distributed_training_on_kubernetes.md b/doc_cn/cluster/k8s/distributed_training_on_kubernetes.md index d9ed431ec0566cf90f11ebaeec56560ff69e71fe..64f8fd4b4398ee6ca324584f7cd2418601cb4c57 100644 --- a/doc_cn/cluster/k8s/distributed_training_on_kubernetes.md +++ b/doc_cn/cluster/k8s/distributed_training_on_kubernetes.md @@ -306,4 +306,4 @@ I1116 09:10:18.019069 50 ParameterClient2.cpp:122] pserver 2 192.168.223.143: I1116 09:10:18.019492 50 ParameterClient2.cpp:122] pserver 3 192.168.223.143:7165 I1116 09:10:18.019716 50 ParameterClient2.cpp:122] pserver 4 192.168.129.71:7164 I1116 09:10:18.019836 50 ParameterClient2.cpp:122] pserver 5 192.168.129.71:7165 -``` \ No newline at end of file +``` diff --git a/doc_cn/cluster/k8s/job.yaml b/doc_cn/cluster/k8s/job.yaml index 1e0ac464b2ec71e98c28f090124690b01b0755ce..488aad0bede4f940b25c7be04259f209c3de9f52 100644 --- a/doc_cn/cluster/k8s/job.yaml +++ b/doc_cn/cluster/k8s/job.yaml @@ -40,4 +40,4 @@ spec: - name: jobpath mountPath: /home/jobpath restartPolicy: Never - \ No newline at end of file + diff --git a/doc_cn/cluster/k8s/start_paddle.py b/doc_cn/cluster/k8s/start_paddle.py index bc0112a77fb84db8965a09716006377c127ad4db..df00d82919faa2acecc79c28e3d773ba3de9672a 100755 --- a/doc_cn/cluster/k8s/start_paddle.py +++ b/doc_cn/cluster/k8s/start_paddle.py @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -19,7 +19,6 @@ import socket import os import argparse - # configuration for cluster API = "/api/v1/namespaces/" JOBSELECTOR = "labelSelector=job-name=" @@ -145,8 +144,8 @@ def startPaddle(idMap={}, train_args_dict=None): if __name__ == '__main__': - parser = argparse.ArgumentParser(prog="start_paddle.py", - description='simple tool for k8s') + parser = argparse.ArgumentParser( + prog="start_paddle.py", description='simple tool for k8s') args, train_args_list = parser.parse_known_args() train_args = refine_unknown_args(train_args_list) train_args_dict = dict(zip(train_args[:-1:2], train_args[1::2])) diff --git a/doc_cn/concepts/use_concepts.rst b/doc_cn/concepts/use_concepts.rst index 67e98edabc0c2a4ecdf8d7993f8dd66b9365a05d..2d27e29fac37d54e4a31540cf75361464f51b193 100644 --- a/doc_cn/concepts/use_concepts.rst +++ b/doc_cn/concepts/use_concepts.rst @@ -2,16 +2,18 @@ PaddlePaddle 基本使用概念 ######################### -PaddlePaddle是一个神经网络学习框架。其单机进程为 :code:`paddle train`。 单机的所有设备使用,均在单机进程内调度完成。 而多机辅助进程 :code:`paddle pserver` 负责联合多个单机进程进行通信,进而充分利用集群的计算资源。 PaddlePaddle同时以 :code:`swig api` 的形式,提供训练结果模型预测的方法和自定义训练流程。 +PaddlePaddle是一个深度学习框架,支持单机模式和多机模式。 -下面我们会分别介绍主要进程 :code:`paddle train` 中的一些概念。这些概念会对如何使用PaddlePaddle有一定的帮助。 了解这些概念的前提是,读者已经了解 `基本的神经网络/机器学习原理和概念 `_ 。同时,如果想要了解PaddlePaddle实现中的一些概念,请参考 `PaddlePaddle 编程中的基本概念 `_ 。 +单机模式用命令 ``paddle train`` 可以启动一个trainer进程,单机训练通常只包括一个trainer进程。如果数据规模比较大,希望加速训练,可以启动分布式作业。一个分布式作业里包括若干trainer进程和若干Parameter Server(或称pserver)进程。用命令 ``paddle pserver`` 可以启动 pserver 进程,pserver进程用于协调多个trainer进程之间的通信。 + +本文首先介绍trainer进程中的一些使用概念,然后介绍pserver进程中概念。 .. contents:: -PaddlePaddle 的进程模型 -======================= +系统框图 +======== -PaddlePaddle进程内嵌了一个 :code:`python` 解释器。 这个 :code:`python` 解释器负责解析用户定义的神经网络配置,和解析用户数据,并将用户数据传入给 PaddlePaddle。 +下图描述了用户使用框图,PaddlePaddle的trainer进程里内嵌了Python解释器,trainer进程可以利用这个解释器执行Python脚本,Python脚本里定义了模型配置、训练算法、以及数据读取函数。其中,数据读取程序往往定义在一个单独Python脚本文件里,被称为数据提供器(DataProvider),通常是一个Python函数。模型配置、训练算法通常定义在另一单独Python文件中, 称为训练配置文件。下面将分别介绍这两部分。 .. graphviz:: @@ -30,162 +32,124 @@ PaddlePaddle进程内嵌了一个 :code:`python` 解释器。 这个 :code:`pyth py -> data_provider [dir="back"]; } -所以,PaddlePaddle单机训练进程,:code:`paddle train` , 对于用户的主要接口语言为 python。 主要需要用户配置的两个文件为 :code:`DataProvider` 和训练文件 :code:`TrainerConfig` 。 - - -DataProvider -============ +数据提供器 +========== -DataProvider是 :code:`paddle train` 的数据提供器。 它负责将用户的原始数据转换成 PaddlePaddle 可以识别的数据类型。每当 PaddlePaddle 需要新的数据训练时,都会调用 DataProvider 返回数据。 当所有数据读取完一轮后,DataProvider 便返回空数据通知 PaddlePaddle。PaddlePaddle负责在下一轮训练开始前,将DataProvider重置。 +DataProvider是PaddlePaddle系统的数据提供器,将用户的原始数据转换成系统可以识别的数据类型。每当系统需要新的数据训练时, trainer进程会调用DataProvider函数返回数据。当所有数据读取完一轮后,DataProvider返回空数据,通知系统一轮数据读取结束,并且系统每一轮训练开始时会重置DataProvider。需要注意的是,DataProvider是被系统调用,而不是新数据驱动系统,一些随机化噪声添加都应该在DataProvider中完成。 -需要注意的是,DataProvider在PaddlePaddle中是被训练逻辑调用的关系, 而不是新的数据驱动训练。并且所有的 :code:`shuffle` , 和一些随机化的噪声添加,都应该在 DataProvider 阶段完成。 - -为了方便用户使用自己的数据格式, PaddlePaddle 提供了 `PyDataProvider`_ 来处理数据。 并且在这个Provider中,PaddlePaddle的 C++ 部分接管了如何shuffle,处理 batch,GPU/CPU通信,双缓冲,异步读取等问题。 用户可以参考 `PyDataProvider`_ 的相关文档,继续深入了解 DataProvider 的使用。 - - -训练文件 -======== +在不同的应用里,训练数据的格式往往各不相同。因此,为了用户能够灵活的处理数据,我们提供了Python处理数据的接口,称为 `PyDataProvider`_ 。在 ``PyDataProvider`` 中,系统C++模块接管了shuffle、处理batch、GPU和CPU通信、双缓冲、异步读取等问题,一些情况下(如:``min_pool_size=0``)需要Python接口里处理shuffle,可以参考 `PyDataProvider`_ 的相关文档继续深入了解。 -训练文件是PaddlePaddle中配置神经网络结构、学习优化算法、数据传入方式的地方。 训练文件是一个python文件,使用命令行参数 :code:`--config` 传给 paddle 的主程序。 例如\: -.. code-block:: bash +训练配置文件 +============ - paddle train --config=trainer_config.py +训练配置文件主要包括数据源、优化算法、网络结构配置三部分。 其中数据源配置与DataProvider的关系是:DataProvider里定义数据读取函数,训练配置文件的数据源配置中指定DataProvider文件名字、生成数据函数接口,请不要混淆。 -一个典型简单的训练文件可能为 +一个简单的训练配置文件为: .. literalinclude:: trainer_config.py :linenos: -下面我们详细的介绍一下训练文件中各个模块的概念。 +文件开头 ``from paddle.trainer_config_helpers import *`` ,是因为PaddlePaddle配置文件与C++模块通信的最基础协议是protobuf,为了避免用户直接写复杂的protobuf string,我们为用户定以Python接口来配置网络,该Python代码可以生成protobuf包,这就是`trainer_config_helpers`_的作用。因此,在文件的开始,需要import这些函数。 这个包里面包含了模型配置需要的各个模块。 +下面分别介绍数据源配置、优化算法配置、网络结构配置这三部分该概念。 -trainer_config_helpers ----------------------- +数据源配置 +---------- -PaddlePaddle的配置文件与PaddlePaddle C++端通信的最基础协议是 :code:`protobuf` 。而为了避免用户直接写比较难写的 protobuf string,我们书写了一个helpers来生成这个protobuf包。所以在文件的开始,import这些helpers函数。 +使用 `PyDataProvider`_ 的函数 ``define_py_data_sources2`` 配置数据源。``define_py_data_sources2`` 里通过train_list和test_list指定是训练文件列表和测试文件列表。 如果传入字符串的话,是指一个数据列表文件。这个数据列表文件中包含的是每一个训练或者测试文件的路径。如果传入一个list的话,则会默认生成一个list文件,再传入给train.list或者test.list。 -需要注意的是,这个 :code:`paddle.trainer_config_helpers` 包是标准的python包,这意味着用户可以选择自己喜欢的 :code:`ide` 或者编辑器来编写Paddle的配置文件,这个python包注释文档比较完善,并且考虑了IDE的代码提示与类型注释。 +``module`` 和 ``obj`` 指定了DataProvider的文件名和返回数据的函数名。更详细的使用,请参考 `PyDataProvider`_ 。 -data_sources +优化算法配置 ------------ -data_sources是配置神经网络的数据源。这里使用的函数是 :code:`define_py_data_sources2` ,这个函数是定义了使用 `PyDataProvider`_ 作为数据源。 而后缀 :code:`2` 是Paddle历史遗留问题,因为Paddle之前使用的 PyDataProvider 性能较差,所以完全重构了一个新的 `PyDataProvider`_ 。 - -data_sources里面的 train_list 和 test_list 指定的是训练文件列表和测试文件列表。 如果传入一个字符串的话,是指一个训练列表文件。这个训练列表文件中包含的是每一个训练或者测试文件的路径。如果传入一个list的话,则会默认生成一个 list 文件,再传入给 train.list 或者 test.list 。 - -而 :code:`module` 和 :code:`obj` 指定了 DataProvider 的模块名和函数名。 +通过 `settings`_ 接口设置神经网络所使用的训练参数和 `优化算法`_ ,包括学习率、batch_size、优化算法、正则方法等,具体的使用方法请参考 `settings`_ 文档。 -更具体的使用,请参考 `PyDataProvider`_ 。 - -settings --------- - -`settings`_ 是神经网络训练算法相关的设置项。包括学习率,batch_size,优化算法,正则方法等等。具体的使用方法请参考 `settings`_ 文档。 +网络结构配置 +------------ -网络配置 --------- +神经网络配置主要包括网络连接、激活函数、损失函数、评估器。 -上述网络配置中余下的部分均是神经网络配置。第一行是定义一个名字叫 "pixel" 的 :code:`data_layer` 。每一个layer返回的都是一个 :code:`LayerOutput` 对象。 这里第一层的输出对象是 :code:`img` 。然后这个对象传输给了另一个 layer 函数, -:code:`simple_img_conv_pool` 。:code:`simple_img_conv_pool` 是一个组合层, -包括了图像的卷积 (convolution) 和池化(pooling), -并继续接了一个全连接层( :code:`fc_layer` ),然后再接了一个Softmax的全连接层。 +- 网络连接: 主要由Layer组成,每个Layer返回的都是一个 ``LayerOutput`` 对象,Layer里面可以定义参数属性、激活类型等。 -最终,网络配置输出了 :code:`classification_cost` 。标记网络输出的函数为 -:code:`outputs` 。网络的输出是神经网络的优化目标,神经网络训练的时候,实际上就是 -要最小化这个输出。 + 为了更灵活的配置,PaddlePaddle提供了基于 Projection 或者 Operator 的配置,这两个需要与 ``mixed_layer`` 配合使用。这里简单介绍Layer、Projection、Operator的概念: -在神经网络进行预测的时候,实际上网络的输出也是通过 :code:`outputs` 标记。 + - Layer: 神经网络的某一层,可以有可学习的参数,一般是封装了许多复杂操作的集合。 + - Projection:需要与 ``mixed_layer`` 配合使用,含可学习参数。 + - Operator: 需要与 ``mixed_layer`` 配合使用,不含可学习参数,输入全是其他Layer的输出。 + + 这个配置文件网络由 ``data_layer`` 、 ``simple_img_conv_pool`` 、 ``fc_layer`` 组成。 -Layer、Projection、Operator -=========================== + - `data_layer`_ : 通常每个配置文件都会包括 ``data_layer`` ,定义输入数据大小。 + - `simple_img_conv_pool`_ :是一个组合层,包括了图像的卷积 (convolution)和池化(pooling)。 + - `fc_layer`_ :全连接层,激活函数为Softmax,这里也可叫分类层。 -PaddlePaddle的网络基本上是基于Layer来配置的。所谓的Layer即是神经网络的某一层, -而神经网络的某一层,一般是封装了许多复杂操作的操作集合。比如最简单的 -:code:`fc_layer` ,也包括矩阵乘法,多输入的求和,和activation。 + +- 损失函数和评估器:损失函数即为网络的优化目标,评估器可以评价模型结果。 -.. code-block:: python + PaddlePaddle包括很多损失函数和评估起,详细可以参考 `损失函数层`_ 和 `评估器`_ 。这里 ``classification_cost`` 默认使用多类交叉熵损失函数和分类错误率统计评估器。 + +- ``outputs``: 标记网络输出的函数为 ``outputs`` 。 - data = data_layer(name='data', size=200) - out = fc_layer(input=data, size=200, act=TanhActivation()) + 训练阶段,网络的输出为神经网络的优化目标;预测阶段,网络的输出也可通过 ``outputs`` 标记。 -而对于更灵活配置需求,可能这样基于Layer的配置是不灵活的。于是 PaddlePaddle 提供 -了基于 Projection 或者 Operator 的配置。使用Projection和Operator需要与 -:code:`mixed_layer` 配合使用。 :code:`mixed_layer` 是将layer中的元素累加求和, -并且做一个 :code:`activation` , 而这个layer具体如何计算,是交由内部的Projection -和 Operator 定义。Projection是指含有可学习参数的操作,而Operator不含有可学习的 -参数,输入全是其他Layer的输出。 +这里对 ``mixed_layer`` 稍做详细说明, 该Layer将多个输入(Projection 或 Operator)累加求和,具体计算是通过内部的 Projection 和 Operator 完成,然后加 Bias 和 activation 操作, -例如,和 :code:`fc_layer` 同样功能的 :code:`mixed_layer` 。 +例如,和 ``fc_layer`` 同样功能的 ``mixed_layer`` 是: .. code-block:: python + + data = data_layer(name='data', size=200) + with mixed_layer(size=200) as out: + out += full_matrix_projection(input=data) - data = data_layer(name='data', size=200) - with mixed_layer(size=200) as out: - out += full_matrix_projection(input=data) +PaddlePaddle 可以使用 ``mixed layer`` 配置出非常复杂的网络,甚至可以直接配置一个完整的LSTM。用户可以参考 `mixed_layer`_ 的相关文档进行配置。 -PaddlePaddle可以使用的mixed layer 配置出非常复杂的网络,甚至可以直接配置一个完整的LSTM。 -用户可以参考 `mixed_layer`_ 的相关文档进行配置。 -如何利用单机的所有GPU或所有CPU核心 -================================== +分布式训练 +========== -PaddlePaddle的单机进程 :code:`paddle train` 可以充分利用一台计算机上所有的GPU资 -源或者CPU。 - -如果要使用机器上多块GPU,使用如下命令即可\: - -.. code-block:: bash - - paddle train --use_gpu=true --trainer_count=4 # use 4 gpu card, 0, 1, 2, 3 - -如果要使用机器上多块CPU, 使用如下命令即可\: - -.. code-block:: bash - - paddle train --trainer_config=4 # use 4 cpu cores. - -对于其他设置GPU的选择情况,例如选择第0、2号GPU显卡,则可以使用 :code:`CUDA_VISIBLE_DEVICES` 环境变量来选择部分的显卡。 具体可以参考连接`masking-gpus`_ 。 可以使用的命令为 - -.. code-block:: bash - - env CUDA_VISIBLE_DEVICES=0,2 paddle train --use_gpu=true --trainer_config=2 - -如何利用多台机器的计算资源训练神经网络 -====================================== - -PaddlePaddle多机使用的经典方法是通过 :code:`Parameter Server` 来对多机的 :code:`paddle train` 进行同步。 而多机训练神经网络,首先要讲数据切分到不同的机器上。 切分数据文件的方式在PaddlePaddle的开源实现中并没有提供工具包。 但是切分数据并不是一件非常复杂的事情,也不是神经网络实现的重点。 - -多机训练过程中,经典的拓扑结构如下\: +PaddlePaddle多机采用经典的 Parameter Server 架构对多个节点的 trainer 进行同步。多机训练的经典拓扑结构如下\: .. graphviz:: pserver_topology.dot -图中每个灰色方块是一台机器,在每个机器中,先去启动一个 :code:`paddle pserver` 进程,并确定整体的端口号。可能的参数是\: +图中每个灰色方块是一台机器,在每个机器中,先使用命令 ``paddle pserver`` 启动一个pserver进程,并指定端口号,可能的参数是\: .. code-block:: bash - paddle pserver --port=5000 --num_gradient_servers=4 --nics='eth0' + paddle pserver --port=5000 --num_gradient_servers=4 --tcp_rdma='tcp' --nics='eth0' + +* ``--port=5000`` : 指定 pserver 进程端口是 5000 。 +* ``--gradient_servers=4`` : 有四个训练进程(PaddlePaddle 将 trainer 也称作 GradientServer ,因为其为负责提供Gradient) 。 +* ``--tcp_rdma='tcp' --nics=`eth0```: 指定以太网类型为TCP网络,指定网络接口名字为eth0。 -这里说明系统的 :code:`paddle pserver` 的起始端口是 :code:`5000` ,并且有四个训练进程(:code:`gradient_servers`,Paddle同时将 :code:`paddle train` 进程称作 :code:`GradientServer` 。因为其为负责提供Gradient的进程)。 而对于训练进程的话,则需要在 :code:`paddle pserver` 启动之后,再在各个节点上运行如下命令\: +启动之后 pserver 进程之后,需要启动 trainer 训练进程,在各个机器上运行如下命令\: .. code-block:: bash paddle train --port=5000 --pservers=192.168.100.101,192.168.100.102,192.168.100.103,192.168.100.104 --config=... -对于简单的多机协同使用上述方式即可。同时,pserver/train 通常在高级情况下,还有两个参数需要设置,他们是 +对于简单的多机协同训练使用上述方式即可。另外,pserver/train 通常在高级情况下,还需要设置下面两个参数\: -* --ports_num\: 一个 pserver进程共绑定多少个端口用来做稠密更新。默认是1 -* --ports_num_for_sparse\: 一个pserver进程共绑定多少端口用来做稀疏更新,默认是0 +* --ports_num\: 一个 pserver 进程共绑定多少个端口用来做稠密更新,默认是1。 +* --ports_num_for_sparse\: 一个pserver进程共绑定多少端口用来做稀疏更新,默认是0。 -使用手工指定端口数量,是因为Paddle的网络通信中,使用了 :code:`int32` 作为消息长度,比较容易在大模型下溢出。所以,在 :code:`paddle pserver` 进程中可以启动多个子线程去接受 trainer 的数据,这样单个子线程的长度就不会溢出了。但是这个值不可以调的过大,因为增加这个值,还是对性能,尤其是内存占用有一定的开销的,另外稀疏更新的端口如果太大的话,很容易某一个参数服务器没有分配到任何参数。 +使用手工指定端口数量,是因为Paddle的网络通信中,使用了 int32 作为消息长度,比较容易在大模型下溢出。所以,在 pserver 进程中可以启动多个子线程去接受 trainer 的数据,这样单个子线程的长度就不会溢出了。但是这个值不可以调的过大,因为增加这个值,对性能尤其是内存占用有一定的开销,另外稀疏更新的端口如果太大的话,很容易导致某一个参数服务器没有分配到任何参数。 详细的说明可以参考,使用 `集群训练Paddle`_ 。 .. _PyDataProvider: ../ui/data_provider/pydataprovider2.html -.. _settings: ../../doc/ui/api/trainer_config_helpers/optimizers.html#settings -.. _mixed_layer: ../../doc/ui/api/trainer_config_helpers/layers.html#mixed-layer -.. _masking-gpu: http://www.acceleware.com/blog/cudavisibledevices-masking-gpus +.. _settings: ../../doc/ui/api/trainer_config_helpers/optimizers.html#settings +.. _优化算法: ../../doc/ui/api/trainer_config_helpers/optimizers.html#optimizers +.. _trainer_config_helper: ../../doc/ui/api/trainer_config_helpers/index.html +.. _data_layer: ../../doc/ui/api/trainer_config_helpers/layers.html#data-layer +.. _simple_img_conv_pool: ../../doc/ui/api/trainer_config_helpers/networks.html#simple-img-conv-pool +.. _fc_layer: ../../doc/ui/api/trainer_config_helpers/layers.html#fc-layer +.. _损失函数层: ../../doc/ui/api/trainer_config_helpers/layers.html#cost-layers +.. _评估器: ../../doc/ui/api/trainer_config_helpers/evaluators.html +.. _mixed_layer: ../../doc/ui/api/trainer_config_helpers/layers.html#mixed-layer .. _集群训练Paddle: ../cluster/index.html diff --git a/doc_cn/conf.py.in b/doc_cn/conf.py.in index 421e0c298d4430082b5ba7ef317408fc5c32cda7..4f3afb814f1e779a711e3535da1f8853aa0d97c6 100644 --- a/doc_cn/conf.py.in +++ b/doc_cn/conf.py.in @@ -69,7 +69,7 @@ master_doc = 'index' # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = None +language = 'zh_CN' # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: diff --git a/doc_cn/demo/sentiment_analysis/index.rst b/doc_cn/demo/sentiment_analysis/index.rst index 82400b2459ebcaf89ff5e884edfe721b9ec01d7f..9d7972b219851d117b1ce72d8eb83eea256e2f87 100644 --- a/doc_cn/demo/sentiment_analysis/index.rst +++ b/doc_cn/demo/sentiment_analysis/index.rst @@ -1,8 +1,8 @@ -情感分析教程 -=========================== - -.. toctree:: - :maxdepth: 3 - :glob: - +情感分析教程 +=========================== + +.. toctree:: + :maxdepth: 3 + :glob: + Training Locally \ No newline at end of file diff --git a/doc_cn/demo/sentiment_analysis/sentiment_analysis.md b/doc_cn/demo/sentiment_analysis/sentiment_analysis.md index b70f2d59675615c26b29932cdf99d728bb206148..ba307e97e3010629548460e25e894d082a6ddd4e 100644 --- a/doc_cn/demo/sentiment_analysis/sentiment_analysis.md +++ b/doc_cn/demo/sentiment_analysis/sentiment_analysis.md @@ -291,20 +291,21 @@ predict.sh: model=model_output/pass-00002/ config=trainer_config.py label=data/pre-imdb/labels.list -python predict.py \ - -n $config\ - -w $model \ - -b $label \ - -d data/pre-imdb/dict.txt \ - -i data/aclImdb/test/pos/10007_10.txt -``` - -* `predict.py`: 预测接口脚本。 -* -n $config : 设置网络配置。 -* -w $model: 设置模型路径。 -* -b $label: 设置标签类别字典,这个字典是整数标签和字符串标签的一个对应。 -* -d data/pre-imdb/dict.txt: 设置字典文件。 -* -i data/aclImdb/test/pos/10014_7.txt: 设置一个要预测的示例文件。 +cat ./data/aclImdb/test/pos/10007_10.txt | python predict.py \ + --tconf=$config\ + --model=$model \ + --label=$label \ + --dict=./data/pre-imdb/dict.txt \ + --batch_size=1 +``` + +* `cat ./data/aclImdb/test/pos/10007_10.txt` : 输入预测样本。 +* `predict.py` : 预测接口脚本。 +* `--tconf=$config` : 设置网络配置。 +* `--model=$model` : 设置模型路径。 +* `--label=$label` : 设置标签类别字典,这个字典是整数标签和字符串标签的一个对应。 +* `--dict=data/pre-imdb/dict.txt` : 设置字典文件。 +* `--batch_size=1` : 设置batch size。 注意应该确保默认模型路径`model_output / pass-00002`存在或更改为其它模型路径。 diff --git a/doc_cn/faq/index.rst b/doc_cn/faq/index.rst index 0f4267ca0351056b859cd6ff1bfd87faa80ef913..df8f1308cbc4d93cfeab4d921dcbbf5155eb4cc1 100644 --- a/doc_cn/faq/index.rst +++ b/doc_cn/faq/index.rst @@ -267,4 +267,21 @@ PaddlePaddle的参数使用名字 :code:`name` 作为参数的ID,相同名字 obj="process", args={"src_dict_path": src_dict_path}) -完整源码可参考 `seqToseq `_ 示例。 \ No newline at end of file +完整源码可参考 `seqToseq `_ 示例。 + +11. 如何指定GPU设备 +------------------- + +例如机器上有4块GPU,编号从0开始,指定使用2、3号GPU: + +* 方式1:通过 `CUDA_VISIBLE_DEVICES `_ 环境变量来指定特定的GPU。 + +.. code-block:: bash + + env CUDA_VISIBLE_DEVICES=2,3 paddle train --use_gpu=true --trainer_count=2 + +* 方式2:通过命令行参数 ``--gpu_id`` 指定。 + +.. code-block:: bash + + paddle train --use_gpu=true --trainer_count=2 --gpu_id=2 diff --git a/doc_cn/index.rst b/doc_cn/index.rst index c9f2126c3e36a019a1dbff2cfafd109eb58b77aa..88a9f79fd23c97785a054af2aa9ee53f8578ef63 100644 --- a/doc_cn/index.rst +++ b/doc_cn/index.rst @@ -23,7 +23,7 @@ PaddlePaddle文档 * `Recurrent Group教程 `_ * `单层RNN示例 <../doc/algorithm/rnn/rnn.html>`_ -* `双层RNN示例 `_ +* :ref:`algo_hrnn_rnn_api_compare` * `支持双层序列作为输入的Layer `_ 常见问题 diff --git a/doc_theme/static/js/paddle_doc_init.js b/doc_theme/static/js/paddle_doc_init.js index 5c815a8d3a3dab9bdbce544ff3bb49be40ad8934..153ce30745a0a21097fb385f2d66f12e6c8d5be5 100644 --- a/doc_theme/static/js/paddle_doc_init.js +++ b/doc_theme/static/js/paddle_doc_init.js @@ -28,4 +28,4 @@ $(document).ready(function(){ $('.doc-menu-vertical').find('li.current').last().addClass('active'); $('.doc-menu-vertical').perfectScrollbar(); -}); \ No newline at end of file +}); diff --git a/paddle/.common_test_util.sh b/paddle/.common_test_util.sh index dc1525061590808e3cc9c7b606aca5d5d9195a3a..8d024bc7d01a26624ee5eaef339f216cdadbe2e2 100644 --- a/paddle/.common_test_util.sh +++ b/paddle/.common_test_util.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/.set_port.sh b/paddle/.set_port.sh index 33596fac600ed5952798b5119f7ecaa999c7d5a7..617ac79a24889eef23b66235ace20be80e1ff4dc 100755 --- a/paddle/.set_port.sh +++ b/paddle/.set_port.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/.set_python_path.sh b/paddle/.set_python_path.sh index 657fdf65e92c9ddde7bb3b4590b48b45e0152870..fa7baccc86e0b56e57d52a40c95cfe1b98fececc 100755 --- a/paddle/.set_python_path.sh +++ b/paddle/.set_python_path.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/api/Arguments.cpp b/paddle/api/Arguments.cpp index bd1fdffe8984e8b8804c576890ec6a37dc7cf574..0cafbd896e2d88aee4406bd0305878ce489bc18d 100644 --- a/paddle/api/Arguments.cpp +++ b/paddle/api/Arguments.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/api/ConfigParser.cpp b/paddle/api/ConfigParser.cpp index bc40d871d180a6bfe21200c866181dc161f5f078..2f45173bfd401ddda26d61ab7fcfe131d079f710 100644 --- a/paddle/api/ConfigParser.cpp +++ b/paddle/api/ConfigParser.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/api/GradientMachine.cpp b/paddle/api/GradientMachine.cpp index 9a4846d80980e23e97f89b6134e15af71207ae6b..297eaa19bb9981c7f07c90763d76494b7910af93 100644 --- a/paddle/api/GradientMachine.cpp +++ b/paddle/api/GradientMachine.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -15,8 +15,8 @@ limitations under the License. */ #include "PaddleAPI.h" #include "PaddleAPIPrivate.h" -#include "paddle/gserver/gradientmachines/NeuralNetwork.h" #include "Internal.h" +#include "paddle/gserver/gradientmachines/NeuralNetwork.h" std::vector GradientMachine::defaultParamTypes = { PARAMETER_VALUE, PARAMETER_GRADIENT, PARAMETER_MOMENTUM}; diff --git a/paddle/api/Internal.h b/paddle/api/Internal.h index 66a13bc603ed5098997f168d3f527160ac3822ef..d48dd3a04c14f559e3c8ceb67226ddb36272e444 100644 --- a/paddle/api/Internal.h +++ b/paddle/api/Internal.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -16,14 +16,13 @@ limitations under the License. */ #include "PaddleAPI.h" -#include #include +#include template void staticCastVector(std::vector* dest, const std::vector& src) { dest->resize(src.size()); - std::transform(src.begin(), - src.end(), - dest->begin(), - [](T1 t) { return static_cast(t); }); + std::transform(src.begin(), src.end(), dest->begin(), [](T1 t) { + return static_cast(t); + }); } diff --git a/paddle/api/Matrix.cpp b/paddle/api/Matrix.cpp index f257ee65aa4a12dfcd1914ddbf0e16461a9b128c..7c375e5cfb91fc5824f823346af6f80c90b36821 100644 --- a/paddle/api/Matrix.cpp +++ b/paddle/api/Matrix.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,12 +12,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "PaddleAPI.h" #include "paddle/math/Matrix.h" -#include "paddle/math/SparseMatrix.h" -#include "paddle/math/CpuSparseMatrix.h" -#include #include +#include +#include "PaddleAPI.h" +#include "paddle/math/CpuSparseMatrix.h" +#include "paddle/math/SparseMatrix.h" struct MatrixPrivate { std::shared_ptr mat; diff --git a/paddle/api/PaddleAPI.h b/paddle/api/PaddleAPI.h index a125934fc17ceb2df3b4fd89538e7a79eee3761e..84a66719c33678fc4aeb038bb81a6b7c5d0c93fb 100644 --- a/paddle/api/PaddleAPI.h +++ b/paddle/api/PaddleAPI.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -16,8 +16,8 @@ limitations under the License. */ #include #include -#include #include +#include #include #include "paddle/utils/GlobalConstants.h" #include "paddle/utils/TypeDefs.h" diff --git a/paddle/api/PaddleAPIPrivate.h b/paddle/api/PaddleAPIPrivate.h index 5ffeff6a9726c7445db36c7c1bec7c74825884a0..d2b56fc41c8aadb136ad6812f848e764e031073c 100644 --- a/paddle/api/PaddleAPIPrivate.h +++ b/paddle/api/PaddleAPIPrivate.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/api/Parameter.cpp b/paddle/api/Parameter.cpp index 9c30ef6ff421235e84896813c701da5d8bfe7af9..4eed00a84a695f2c48ff93b33419ae2b3dd03768 100644 --- a/paddle/api/Parameter.cpp +++ b/paddle/api/Parameter.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "PaddleAPI.h" #include "paddle/parameter/Parameter.h" +#include "PaddleAPI.h" struct ParameterPrivate { std::shared_ptr sharedPtr; diff --git a/paddle/api/ParameterOptimizer.cpp b/paddle/api/ParameterOptimizer.cpp index 21d031e4bcb897eb693e5cff56bc77a637dc6bd2..21b851dd5e26c4752888067b20d0b1e16a4ab52d 100644 --- a/paddle/api/ParameterOptimizer.cpp +++ b/paddle/api/ParameterOptimizer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,11 +12,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "PaddleAPI.h" -#include "PaddleAPIPrivate.h" #include "paddle/parameter/ParameterOptimizer.h" -#include "Internal.h" #include +#include "Internal.h" +#include "PaddleAPI.h" +#include "PaddleAPIPrivate.h" struct ParameterOptimizerPrivate { std::unique_ptr optimizer; @@ -36,16 +36,13 @@ struct ParameterTraverseCallbackPrivate { size_t sparseId) { std::vector real_vecs; real_vecs.resize(vecs.size()); - std::transform(vecs.begin(), - vecs.end(), - real_vecs.begin(), - [](Vector* v) { - if (v) { - return *(paddle::VectorPtr*)(v->getSharedPtr()); - } else { - return paddle::VectorPtr(); - } - }); + std::transform(vecs.begin(), vecs.end(), real_vecs.begin(), [](Vector* v) { + if (v) { + return *(paddle::VectorPtr*)(v->getSharedPtr()); + } else { + return paddle::VectorPtr(); + } + }); paddle::ParameterConfig& real_conf = *(paddle::ParameterConfig*)(const_cast(conf) diff --git a/paddle/api/SequenceGenerator.cpp b/paddle/api/SequenceGenerator.cpp index d51be78d45902967107f4bf0af995958faed931a..8428edc60df6219fd1d3aebf74b0911a79d370cb 100644 --- a/paddle/api/SequenceGenerator.cpp +++ b/paddle/api/SequenceGenerator.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,14 +12,14 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include +#include +#include +#include #include "PaddleAPI.h" #include "paddle/gserver/gradientmachines/GradientMachine.h" #include "paddle/parameter/Argument.h" #include "paddle/utils/Flags.h" -#include -#include -#include -#include // used to represent partial sequence struct Path { diff --git a/paddle/api/Trainer.cpp b/paddle/api/Trainer.cpp index 7a6aa69fb652313748b1fa787847ffd74fda7a22..59b47d4b1c7b6d586e89624c155d7ba6f3885eb6 100644 --- a/paddle/api/Trainer.cpp +++ b/paddle/api/Trainer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -16,12 +16,12 @@ limitations under the License. */ #include "PaddleAPIPrivate.h" #include -#include #include +#include +#include "paddle/gserver/gradientmachines/NeuralNetwork.h" #include "paddle/trainer/ParamUtil.h" #include "paddle/trainer/Trainer.h" -#include "paddle/gserver/gradientmachines/NeuralNetwork.h" #include "paddle/trainer/TrainerInternal.h" #include "paddle/utils/Flags.h" diff --git a/paddle/api/Util.cpp b/paddle/api/Util.cpp index 1bba1df2e1c0a2d3cd2d8307ed3a0d784bb949b4..c3f739568f50b6ee8b0894d06a4d7f91c7816879 100644 --- a/paddle/api/Util.cpp +++ b/paddle/api/Util.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,16 +14,16 @@ limitations under the License. */ #include "PaddleAPI.h" -#include "paddle/utils/Util.h" -#include "paddle/utils/PythonUtil.h" -#include "paddle/utils/Flags.h" -#include "paddle/utils/Excepts.h" #include "paddle/parameter/Parameter.h" +#include "paddle/utils/Excepts.h" +#include "paddle/utils/Flags.h" +#include "paddle/utils/PythonUtil.h" +#include "paddle/utils/Util.h" #include +#include #include #include -#include void initPaddle(int argc, char** argv) { paddle::initMain(argc, argv); diff --git a/paddle/api/Vector.cpp b/paddle/api/Vector.cpp index 74c9ff8dc7373f2beb6e6faaf951678038803c56..874f2fd044e9e86b44f8ca69f08bdfd3287d4749 100644 --- a/paddle/api/Vector.cpp +++ b/paddle/api/Vector.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -282,7 +282,7 @@ FloatArray Vector::getData() const { } void Vector::copyFrom(Vector* src) throw(RangeError) { - if (src->m->vec->getSize() != m->vec->getSize()) { + if (src->m->vec->getSize() != m->vec->getSize()) { throw RangeError(); } m->vec->copyFrom(*src->m->vec); diff --git a/paddle/api/__init__.py b/paddle/api/__init__.py index c90af2ee000d46a032984ee23559e7e99b49ddad..f662d6826321eb840739382558f76327d27b5847 100644 --- a/paddle/api/__init__.py +++ b/paddle/api/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/api/paddle_ld_flags.py b/paddle/api/paddle_ld_flags.py index ebe00798e8b7169ecbbef53e287ab4b78334bcf9..85cc54700faceb5a514cebe665a2da5ed2f7aa3c 100644 --- a/paddle/api/paddle_ld_flags.py +++ b/paddle/api/paddle_ld_flags.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/api/test/run_tests.sh b/paddle/api/test/run_tests.sh index ff69c45264950db90fbec44c0ab6087994ddeea2..2f12ba026430ba7adb6f4dee11ed17ea3ad3f36d 100755 --- a/paddle/api/test/run_tests.sh +++ b/paddle/api/test/run_tests.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/api/test/testArguments.py b/paddle/api/test/testArguments.py index 70fb169fd5c43d5768e67ad8e4c62a9f4d302eaf..8cabecd242fb4eb98c0fe468687ef179245e4535 100644 --- a/paddle/api/test/testArguments.py +++ b/paddle/api/test/testArguments.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/api/test/testGradientMachine.py b/paddle/api/test/testGradientMachine.py index e12613fbb8a66545dd3ad20d59b0b951e86e8683..b81eafa9673ca34f1b7e06401098d55bdb1b35a5 100644 --- a/paddle/api/test/testGradientMachine.py +++ b/paddle/api/test/testGradientMachine.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/api/test/testMatrix.py b/paddle/api/test/testMatrix.py index 8b0da626928e292c392142a1c25c6bd8f677372b..37666bdccc9aedfe8f8079124129aad2ade53a43 100644 --- a/paddle/api/test/testMatrix.py +++ b/paddle/api/test/testMatrix.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -100,11 +100,12 @@ class TestMatrix(unittest.TestCase): for a, e in zip(gpu_m.getData(), [1.0, 3.23, 3.0, 4.0, 5.0, 6.0]): self.assertAlmostEqual(a, e) - + def test_numpy(self): numpy_mat = np.matrix([[1, 2], [3, 4], [5, 6]], dtype="float32") m = swig_paddle.Matrix.createDenseFromNumpy(numpy_mat) - self.assertEqual((int(m.getHeight()), int(m.getWidth())), numpy_mat.shape) + self.assertEqual((int(m.getHeight()), int(m.getWidth())), + numpy_mat.shape) self.assertEqual(m.isGpu(), swig_paddle.isUsingGpu()) for a, e in zip(m.getData(), [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]): self.assertAlmostEqual(a, e) diff --git a/paddle/api/test/testTrain.py b/paddle/api/test/testTrain.py index a3ba4eaaa69b39b75e7ece3095b6f236c1248d41..a90d15c272a3a2b56e35c979e053deb2b54eebc1 100644 --- a/paddle/api/test/testTrain.py +++ b/paddle/api/test/testTrain.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/api/test/testTrainer.py b/paddle/api/test/testTrainer.py index edd5a2da5785c405b46c2559ee93837ac68d7c3a..a76cbf02d83ac5ad82a96deee43c4afd104266a2 100644 --- a/paddle/api/test/testTrainer.py +++ b/paddle/api/test/testTrainer.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/api/test/testVector.py b/paddle/api/test/testVector.py index 963359236d5e27ac569c00fd82b9a58f44eee4c9..1ab095c1d3d0d2c84d2d2f95a03f172b901de209 100644 --- a/paddle/api/test/testVector.py +++ b/paddle/api/test/testVector.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -26,17 +26,17 @@ class TestIVector(unittest.TestCase): self.assertEqual(m[i], 0) m[i] = i self.assertEqual(m[i], i) - + m = swig_paddle.IVector.createZero(10) self.assertEqual(m.isGpu(), swig_paddle.isUsingGpu()) - self.assertEqual(m.getData(), [0]*10) + self.assertEqual(m.getData(), [0] * 10) def test_create(self): m = swig_paddle.IVector.create(range(10), False) self.assertIsNotNone(m) for i in xrange(10): self.assertEqual(m[i], i) - + m = swig_paddle.IVector.create(range(10)) self.assertEqual(m.isGpu(), swig_paddle.isUsingGpu()) self.assertEqual(m.getData(), range(10)) @@ -69,7 +69,7 @@ class TestIVector(unittest.TestCase): expect_vec = range(0, 10) expect_vec[4] = 7 self.assertEqual(vec.getData(), expect_vec) - + def test_numpy(self): vec = np.array([1, 3, 4, 65, 78, 1, 4], dtype="int32") iv = swig_paddle.IVector.createVectorFromNumpy(vec) @@ -85,10 +85,10 @@ class TestVector(unittest.TestCase): self.assertTrue(util.doubleEqual(v[i], 0)) v[i] = i self.assertTrue(util.doubleEqual(v[i], i)) - + v = swig_paddle.Vector.createZero(10) self.assertEqual(v.isGpu(), swig_paddle.isUsingGpu()) - self.assertEqual(v.getData(), [0]*10) + self.assertEqual(v.getData(), [0] * 10) def testCreate(self): v = swig_paddle.Vector.create([x / 100.0 for x in xrange(100)], False) @@ -96,14 +96,13 @@ class TestVector(unittest.TestCase): for i in xrange(len(v)): self.assertTrue(util.doubleEqual(v[i], i / 100.0)) self.assertEqual(100, len(v)) - + v = swig_paddle.Vector.create([x / 100.0 for x in xrange(100)]) self.assertEqual(v.isGpu(), swig_paddle.isUsingGpu()) self.assertEqual(100, len(v)) vdata = v.getData() for i in xrange(len(v)): self.assertTrue(util.doubleEqual(vdata[i], i / 100.0)) - def testCpuNumpy(self): numpy_arr = np.array([1.2, 2.3, 3.4, 4.5], dtype="float32") @@ -128,7 +127,7 @@ class TestVector(unittest.TestCase): for i in xrange(1, len(numpy_3)): util.doubleEqual(numpy_3[i], vec[i]) - + def testNumpy(self): numpy_arr = np.array([1.2, 2.3, 3.4, 4.5], dtype="float32") vec = swig_paddle.Vector.createVectorFromNumpy(numpy_arr) @@ -136,7 +135,6 @@ class TestVector(unittest.TestCase): vecData = vec.getData() for n, v in zip(numpy_arr, vecData): self.assertTrue(util.doubleEqual(n, v)) - def testCopyFromNumpy(self): vec = swig_paddle.Vector.createZero(1, False) diff --git a/paddle/api/test/util.py b/paddle/api/test/util.py index dbcdba5bf27c2fd7df95f8838ad5fdcd131cccf1..9f4631c53e11d55f9a2638f98c52ba2f5e955b37 100644 --- a/paddle/api/test/util.py +++ b/paddle/api/test/util.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_activation_functions.h b/paddle/cuda/include/hl_activation_functions.h index 03e15b2223a50625c6999f6b081ae984e76b182b..cdb2dba06cb4123da4be2088e290c6a740e0375b 100644 --- a/paddle/cuda/include/hl_activation_functions.h +++ b/paddle/cuda/include/hl_activation_functions.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_aggregate.h b/paddle/cuda/include/hl_aggregate.h index a6d9ff8483eee28b2c8a380f0aca097c7662a02e..d2189de689f75d737be96d958e5da071cfeca5cf 100644 --- a/paddle/cuda/include/hl_aggregate.h +++ b/paddle/cuda/include/hl_aggregate.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_avx_functions.h b/paddle/cuda/include/hl_avx_functions.h index ed339e312a7639cf9b78f130a43d67a7446576bb..35f4eabb4c07c6cc9d2edded02e5b6290b1232f8 100644 --- a/paddle/cuda/include/hl_avx_functions.h +++ b/paddle/cuda/include/hl_avx_functions.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_base.h b/paddle/cuda/include/hl_base.h index a076952467a5ce10dc1f58007dda2170aa694fbb..84c5f2d5c91feb7896643d2c5f60a279ebe944e7 100644 --- a/paddle/cuda/include/hl_base.h +++ b/paddle/cuda/include/hl_base.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -223,9 +223,9 @@ typedef struct { #ifdef __NVCC__ -#include "paddle/utils/Logging.h" -#include "hl_cuda.h" #include "cuda_runtime.h" +#include "hl_cuda.h" +#include "paddle/utils/Logging.h" extern __thread bool g_sync_flag; extern __thread cudaStream_t default_stream; diff --git a/paddle/cuda/include/hl_batch_transpose.h b/paddle/cuda/include/hl_batch_transpose.h index f3630e9762508fd39935e62e0007de04f9140fff..e2e958cd67aa72b0f654e758e1da4753412aab3f 100644 --- a/paddle/cuda/include/hl_batch_transpose.h +++ b/paddle/cuda/include/hl_batch_transpose.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_cnn.h b/paddle/cuda/include/hl_cnn.h index cffaac634f0f64be5ddab961d549ae43775bb7b0..06ee3b3654b576ec57dc437582e37ed0cea328ee 100644 --- a/paddle/cuda/include/hl_cnn.h +++ b/paddle/cuda/include/hl_cnn.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_cpu_gru.cuh b/paddle/cuda/include/hl_cpu_gru.cuh index d39cf67448b4f226a2a10223ec1dee64bcaa82c6..c0a37ced2a72a1ab410025e2aa45313c23f1349a 100644 --- a/paddle/cuda/include/hl_cpu_gru.cuh +++ b/paddle/cuda/include/hl_cpu_gru.cuh @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_cpu_lstm.cuh b/paddle/cuda/include/hl_cpu_lstm.cuh index 65a174d85ba2cd4dd0d703f14175aed865945894..0e412fcdf57fe99f596f8dd597d67e10624f459c 100644 --- a/paddle/cuda/include/hl_cpu_lstm.cuh +++ b/paddle/cuda/include/hl_cpu_lstm.cuh @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_cpu_matrix_kernel.cuh b/paddle/cuda/include/hl_cpu_matrix_kernel.cuh index 239a2419918f9a1397e7ec79ac89a44accad6f3a..f35bfbc5c8253d632f8089f5037421f527633aad 100644 --- a/paddle/cuda/include/hl_cpu_matrix_kernel.cuh +++ b/paddle/cuda/include/hl_cpu_matrix_kernel.cuh @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_cuda.h b/paddle/cuda/include/hl_cuda.h index 2c7d665101f36f9c32ab132ca279abf3ac062a8f..5383c1130bba30a0c553afe8d6fc34a6400f236b 100644 --- a/paddle/cuda/include/hl_cuda.h +++ b/paddle/cuda/include/hl_cuda.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_cuda.ph b/paddle/cuda/include/hl_cuda.ph index 9e0537aaf168713113649c07e068fe1f57d0f85f..701916b27922f980d0aa70eec8358eb10f006df5 100644 --- a/paddle/cuda/include/hl_cuda.ph +++ b/paddle/cuda/include/hl_cuda.ph @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_cuda_cublas.h b/paddle/cuda/include/hl_cuda_cublas.h index db8c03c2c01c67788622d37b5330e22c31e03f34..e206e42b2aba9c83296de60ca7ef4784fb869c61 100644 --- a/paddle/cuda/include/hl_cuda_cublas.h +++ b/paddle/cuda/include/hl_cuda_cublas.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_cuda_cudnn.h b/paddle/cuda/include/hl_cuda_cudnn.h index 3a2f916210277145efa8f6d7663a2698ea546b0b..db18e4912b63ec18dcfff3ef3aaf0c7947e0af18 100644 --- a/paddle/cuda/include/hl_cuda_cudnn.h +++ b/paddle/cuda/include/hl_cuda_cudnn.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_cuda_cudnn.ph b/paddle/cuda/include/hl_cuda_cudnn.ph index c0e82abe1785a030abe2f441b00c74ce8658aaa9..61378937cee78f9f2fb5c7f176555d3ead87da6c 100644 --- a/paddle/cuda/include/hl_cuda_cudnn.ph +++ b/paddle/cuda/include/hl_cuda_cudnn.ph @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_device_functions.cuh b/paddle/cuda/include/hl_device_functions.cuh index 159c26f443cb17116da2d2d5282f883d875a85be..e0b5632f23edc5cb4769a6e60c8e461d6011a3e0 100755 --- a/paddle/cuda/include/hl_device_functions.cuh +++ b/paddle/cuda/include/hl_device_functions.cuh @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_dso_loader.h b/paddle/cuda/include/hl_dso_loader.h index e5d3d4031140391339d5a53c9ee11ca942697730..20c13f21e61a92b0635b686f6f724ae2b44518cc 100644 --- a/paddle/cuda/include/hl_dso_loader.h +++ b/paddle/cuda/include/hl_dso_loader.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -16,8 +16,8 @@ limitations under the License. */ #define HL_DSO_LOADER_H_ #include -#include #include +#include #include "hl_base.h" /** diff --git a/paddle/cuda/include/hl_functions.h b/paddle/cuda/include/hl_functions.h index 91ce9a0678463597df88c548aeac322ee19d95de..0d7e80a855d83f1b03046c04eea1a47a7a59e550 100644 --- a/paddle/cuda/include/hl_functions.h +++ b/paddle/cuda/include/hl_functions.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_gpu.h b/paddle/cuda/include/hl_gpu.h index 6dd6d1321270a5f24661911f8bee9de1d0cbb4cf..ede2670882ee2b93f610a2261a4ecc1784bc2d0c 100644 --- a/paddle/cuda/include/hl_gpu.h +++ b/paddle/cuda/include/hl_gpu.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -15,28 +15,28 @@ limitations under the License. */ #ifndef HL_GPU_H_ #define HL_GPU_H_ +#include "hl_aggregate.h" #include "hl_base.h" +#include "hl_cnn.h" #include "hl_cuda.h" #include "hl_cuda_cublas.h" #include "hl_cuda_cudnn.h" -#include "hl_matrix.h" -#include "hl_aggregate.h" -#include "hl_cnn.h" -#include "hl_sparse.h" #include "hl_lstm.h" +#include "hl_matrix.h" #include "hl_sequence.h" +#include "hl_sparse.h" #include "hl_warpctc_wrap.h" #ifdef HPPL_STUB_FUNC -#include "stub/hl_cuda_stub.h" -#include "stub/hl_cuda_cublas_stub.h" -#include "stub/hl_cuda_cudnn_stub.h" -#include "stub/hl_matrix_stub.h" #include "stub/hl_aggregate_stub.h" #include "stub/hl_cnn_stub.h" -#include "stub/hl_sparse_stub.h" +#include "stub/hl_cuda_cublas_stub.h" +#include "stub/hl_cuda_cudnn_stub.h" +#include "stub/hl_cuda_stub.h" #include "stub/hl_lstm_stub.h" +#include "stub/hl_matrix_stub.h" #include "stub/hl_sequence_stub.h" +#include "stub/hl_sparse_stub.h" #endif #endif /* HL_GPU_H_ */ diff --git a/paddle/cuda/include/hl_gpu_functions.cuh b/paddle/cuda/include/hl_gpu_functions.cuh index a2c5ebd18a4403a0eab5341b509ed65148f4aa88..8e64cbe360eb9f2ddfb0b30f2d73408b182b4b3c 100644 --- a/paddle/cuda/include/hl_gpu_functions.cuh +++ b/paddle/cuda/include/hl_gpu_functions.cuh @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_gpu_gru.cuh b/paddle/cuda/include/hl_gpu_gru.cuh index 3e0cfdbe4f771782ca669470d819b923f67e2a37..6668e135d2b8c793b510bf06797dbc5ffb747dc9 100644 --- a/paddle/cuda/include/hl_gpu_gru.cuh +++ b/paddle/cuda/include/hl_gpu_gru.cuh @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_gpu_lstm.cuh b/paddle/cuda/include/hl_gpu_lstm.cuh index 07806e11c18a2b47d79237587a0e882d7bf2a1d2..5dceba2f5b82a2b33273cb027049894998a5dfcf 100644 --- a/paddle/cuda/include/hl_gpu_lstm.cuh +++ b/paddle/cuda/include/hl_gpu_lstm.cuh @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_gpu_matrix_kernel.cuh b/paddle/cuda/include/hl_gpu_matrix_kernel.cuh index 201c5c25f19cd87e9ffd26fbbbb32b77ba5127a9..9bbdf5fa72678ef7ded0c4343bbd97306b78fe9a 100644 --- a/paddle/cuda/include/hl_gpu_matrix_kernel.cuh +++ b/paddle/cuda/include/hl_gpu_matrix_kernel.cuh @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_gru_ops.cuh b/paddle/cuda/include/hl_gru_ops.cuh index 3c137d8d44bfe131fd91aa361541c0aec8c37318..45f66ad533ebd00171dfa86eaa66dc6612c72403 100644 --- a/paddle/cuda/include/hl_gru_ops.cuh +++ b/paddle/cuda/include/hl_gru_ops.cuh @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_lstm.h b/paddle/cuda/include/hl_lstm.h index 7e527a79025969320f1aca75d313fd9d0194efd1..857756e5cd4c77ce618b03eddc9ca94948bd123a 100644 --- a/paddle/cuda/include/hl_lstm.h +++ b/paddle/cuda/include/hl_lstm.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_lstm_ops.cuh b/paddle/cuda/include/hl_lstm_ops.cuh index a5ea018dbcf77c74b2036b3a6670fe9cc00ba5a3..2601060cc2e50b876d2731c2b05ce54ff47d9315 100644 --- a/paddle/cuda/include/hl_lstm_ops.cuh +++ b/paddle/cuda/include/hl_lstm_ops.cuh @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_matrix.h b/paddle/cuda/include/hl_matrix.h index 96648661e345d8fa5d50cb2aae3a56ee53921f90..abd5eb3a0cf338c689680dd0f7192be7b2530383 100644 --- a/paddle/cuda/include/hl_matrix.h +++ b/paddle/cuda/include/hl_matrix.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_matrix_apply.cuh b/paddle/cuda/include/hl_matrix_apply.cuh index 927212c83d2e5a1d586bd132b06b75198fc619ee..b10d177b970e259e98972bbe465a1b8cdb563c0e 100644 --- a/paddle/cuda/include/hl_matrix_apply.cuh +++ b/paddle/cuda/include/hl_matrix_apply.cuh @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_matrix_base.cuh b/paddle/cuda/include/hl_matrix_base.cuh index a3645ef51e6ef7d3c7e204e4f29f68442101ad3e..db35ee2037433163ebb3673edb350e3fab71fba9 100644 --- a/paddle/cuda/include/hl_matrix_base.cuh +++ b/paddle/cuda/include/hl_matrix_base.cuh @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_matrix_base_sse.cuh b/paddle/cuda/include/hl_matrix_base_sse.cuh index dd55b848849404c85b3b8d1a947ec0a63771c159..db6c9cca03a8974a15cd2e7fbaf73033e3a57f4b 100644 --- a/paddle/cuda/include/hl_matrix_base_sse.cuh +++ b/paddle/cuda/include/hl_matrix_base_sse.cuh @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_matrix_ops.cuh b/paddle/cuda/include/hl_matrix_ops.cuh index 3e5e1bc7010ec53cfd23b93652aae2498ae23773..fc29201357ce564dcf20b12d998223f7a4cc22b4 100644 --- a/paddle/cuda/include/hl_matrix_ops.cuh +++ b/paddle/cuda/include/hl_matrix_ops.cuh @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_matrix_type.cuh b/paddle/cuda/include/hl_matrix_type.cuh index 060be073645b1d5f79e55dc02fdb60f42bcea61b..59213eee75f50d3c054ed8684a9a0e1053342a0a 100644 --- a/paddle/cuda/include/hl_matrix_type.cuh +++ b/paddle/cuda/include/hl_matrix_type.cuh @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_perturbation_util.cuh b/paddle/cuda/include/hl_perturbation_util.cuh index 90fc1cb06035a292ae2d146222868400f031343e..93b81bf0358694219c55bf076c454790286c2418 100644 --- a/paddle/cuda/include/hl_perturbation_util.cuh +++ b/paddle/cuda/include/hl_perturbation_util.cuh @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_recurrent_apply.cuh b/paddle/cuda/include/hl_recurrent_apply.cuh index 0ccbf01f1c58daaed6731b62e8d7255eb2829ba2..113446cf75658f603200a57f3d8cd8a9e47fe728 100644 --- a/paddle/cuda/include/hl_recurrent_apply.cuh +++ b/paddle/cuda/include/hl_recurrent_apply.cuh @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_sequence.h b/paddle/cuda/include/hl_sequence.h index b98d7bdeafe5dfbd6b27304b11c55329f861165e..9bcd25b0623e569052e08c0befc8e09f937fa4bd 100644 --- a/paddle/cuda/include/hl_sequence.h +++ b/paddle/cuda/include/hl_sequence.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_sparse.h b/paddle/cuda/include/hl_sparse.h index c4e0be23e2031cbcb124b532216a23d8a344668d..67fe701c109db43eec844944efa76cd3cb79edee 100644 --- a/paddle/cuda/include/hl_sparse.h +++ b/paddle/cuda/include/hl_sparse.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_sparse.ph b/paddle/cuda/include/hl_sparse.ph index d3bc73c80d3741a47997337351c2a56cb42ea0bf..13bba17811630ff12e9fcd85c520e83f44a086df 100644 --- a/paddle/cuda/include/hl_sparse.ph +++ b/paddle/cuda/include/hl_sparse.ph @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_sse_matrix_kernel.cuh b/paddle/cuda/include/hl_sse_matrix_kernel.cuh index 45db2f313e0d6e5d991a9bcc3ccd71262818ad09..9e50580669d2d4523dda239e90b4ed18a9214e2f 100644 --- a/paddle/cuda/include/hl_sse_matrix_kernel.cuh +++ b/paddle/cuda/include/hl_sse_matrix_kernel.cuh @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_table_apply.h b/paddle/cuda/include/hl_table_apply.h index b4ac83a66af13c2a843872faba2ebd972008a738..2170b97f4d286608fb4b69ecbd9150e19b74834f 100644 --- a/paddle/cuda/include/hl_table_apply.h +++ b/paddle/cuda/include/hl_table_apply.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_tensor_ops.h b/paddle/cuda/include/hl_tensor_ops.h index cc95620e37cec55df667f56c6d7dedc7e20dcb54..7945b98201b1812790fb0d53123e9ee007640485 100644 --- a/paddle/cuda/include/hl_tensor_ops.h +++ b/paddle/cuda/include/hl_tensor_ops.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_thread.ph b/paddle/cuda/include/hl_thread.ph index 0cfc45993676d996e41a62ec34207aeb03151aa9..a3830ff8d8af5dfd3b932677c7f1e6ffcee97d47 100644 --- a/paddle/cuda/include/hl_thread.ph +++ b/paddle/cuda/include/hl_thread.ph @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_time.h b/paddle/cuda/include/hl_time.h index b0a88c66a12fcfec6ea96b877423f907dac8dfa1..f63f02582060156562061f73c429fc7bbd878d2c 100644 --- a/paddle/cuda/include/hl_time.h +++ b/paddle/cuda/include/hl_time.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ limitations under the License. */ #ifndef HL_TIME_H_ #define HL_TIME_H_ - +#include /** * @brief High resolution timer. * diff --git a/paddle/cuda/include/hl_top_k.h b/paddle/cuda/include/hl_top_k.h index e8cfebbf6a3bd27c10a71d7817238bc304681fa4..77949ed295a6eaf7cc535853e53bef066ffac37c 100644 --- a/paddle/cuda/include/hl_top_k.h +++ b/paddle/cuda/include/hl_top_k.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/hl_warpctc_wrap.h b/paddle/cuda/include/hl_warpctc_wrap.h index dc50cf9d20829c4b7d03a4445c81cc912c4eb072..79bf6c3db7f876009d98a62b6523588f021886e8 100644 --- a/paddle/cuda/include/hl_warpctc_wrap.h +++ b/paddle/cuda/include/hl_warpctc_wrap.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/stub/hl_aggregate_stub.h b/paddle/cuda/include/stub/hl_aggregate_stub.h index bb53fc581e09905aa7a9b2d8dfe44b04c677c40a..bbfa9b8fad5b49290c05eeeeeeea4fe4b85a683f 100644 --- a/paddle/cuda/include/stub/hl_aggregate_stub.h +++ b/paddle/cuda/include/stub/hl_aggregate_stub.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/stub/hl_cnn_stub.h b/paddle/cuda/include/stub/hl_cnn_stub.h index 2f73b9671edd3609996aebff2913f5262805f869..52c978735279ed804c44f0e93472355637e8b98d 100644 --- a/paddle/cuda/include/stub/hl_cnn_stub.h +++ b/paddle/cuda/include/stub/hl_cnn_stub.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/stub/hl_cuda_cublas_stub.h b/paddle/cuda/include/stub/hl_cuda_cublas_stub.h index 85f7c390c47397127487b16fdc933f0afe2fb880..e86fd853f407de8bbcec5a2629d6ae600f696eb3 100644 --- a/paddle/cuda/include/stub/hl_cuda_cublas_stub.h +++ b/paddle/cuda/include/stub/hl_cuda_cublas_stub.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/stub/hl_cuda_cudnn_stub.h b/paddle/cuda/include/stub/hl_cuda_cudnn_stub.h index 3beb0e5b5170261a6c453936b8b0347f3e97dbff..abd0d6b09901a7cd124c245e359f9d38f52bda26 100644 --- a/paddle/cuda/include/stub/hl_cuda_cudnn_stub.h +++ b/paddle/cuda/include/stub/hl_cuda_cudnn_stub.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/stub/hl_cuda_stub.h b/paddle/cuda/include/stub/hl_cuda_stub.h index 24923a0d4a0cdd49214305c2f7716eeef575c7ee..5246a8d5a48fa7a6ac075f12a312d9c5383cdf8c 100644 --- a/paddle/cuda/include/stub/hl_cuda_stub.h +++ b/paddle/cuda/include/stub/hl_cuda_stub.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/stub/hl_lstm_stub.h b/paddle/cuda/include/stub/hl_lstm_stub.h index 7ccda032d26f2fbbe99136e8481416daea557a78..246ba79f6324dd48a423d3f748bf8f551ec3d376 100644 --- a/paddle/cuda/include/stub/hl_lstm_stub.h +++ b/paddle/cuda/include/stub/hl_lstm_stub.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/stub/hl_matrix_stub.h b/paddle/cuda/include/stub/hl_matrix_stub.h index 1bd78d23fbaf46e6265ba0db25ea399a204bd96f..0b669f6735cb9771fd63ed8e3b45602db0db447c 100644 --- a/paddle/cuda/include/stub/hl_matrix_stub.h +++ b/paddle/cuda/include/stub/hl_matrix_stub.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/stub/hl_sequence_stub.h b/paddle/cuda/include/stub/hl_sequence_stub.h index 3343463a8d5faa2f409a710752a29238455b2085..d6b07556f8958a62bd47f0b47b75bbebafeb58d3 100644 --- a/paddle/cuda/include/stub/hl_sequence_stub.h +++ b/paddle/cuda/include/stub/hl_sequence_stub.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/include/stub/hl_sparse_stub.h b/paddle/cuda/include/stub/hl_sparse_stub.h index d47bdd2c47d097c4c68b7b7e88ef888bc18270c2..bd17461d88f716a0ed96e90ae36bb0f65099e110 100644 --- a/paddle/cuda/include/stub/hl_sparse_stub.h +++ b/paddle/cuda/include/stub/hl_sparse_stub.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/src/hl_avx_functions.cc b/paddle/cuda/src/hl_avx_functions.cc index c1e0c7f9d9e7958a6b4ba3617ca488e49af20655..906647587642f3815915efbeca7aab6458d25a70 100644 --- a/paddle/cuda/src/hl_avx_functions.cc +++ b/paddle/cuda/src/hl_avx_functions.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/src/hl_batch_transpose.cu b/paddle/cuda/src/hl_batch_transpose.cu index 00fd18e7f3936c2b2374d747745f296c7b9cf728..f047403da17e66960f029f2fee7312210009c952 100644 --- a/paddle/cuda/src/hl_batch_transpose.cu +++ b/paddle/cuda/src/hl_batch_transpose.cu @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/src/hl_cpu_functions.cc b/paddle/cuda/src/hl_cpu_functions.cc index af00f352e536bf342e15315d1f6804225b87eb0b..c2117a7315fed506d0f746ddfceaf304942cf5a2 100644 --- a/paddle/cuda/src/hl_cpu_functions.cc +++ b/paddle/cuda/src/hl_cpu_functions.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/src/hl_cuda_aggregate.cu b/paddle/cuda/src/hl_cuda_aggregate.cu index 4eb775eb7971e467ef8b3a059af6f0d35b77e8ff..97034a917708487d1c5dc59e6ebbf45bad1c3227 100644 --- a/paddle/cuda/src/hl_cuda_aggregate.cu +++ b/paddle/cuda/src/hl_cuda_aggregate.cu @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/src/hl_cuda_cnn.cu b/paddle/cuda/src/hl_cuda_cnn.cu index 7f2f6897b49af5d9aa33b2ade3e20114440c8364..0992286f360fb8be22e3c35b632e4b7163036277 100644 --- a/paddle/cuda/src/hl_cuda_cnn.cu +++ b/paddle/cuda/src/hl_cuda_cnn.cu @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/src/hl_cuda_cublas.cc b/paddle/cuda/src/hl_cuda_cublas.cc index e8ba232d44b3f66254d4749d4abbcfbe46d1fd0e..182e8ab218cce18448f8a08f5c1a1dab7e38f2b6 100644 --- a/paddle/cuda/src/hl_cuda_cublas.cc +++ b/paddle/cuda/src/hl_cuda_cublas.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,12 +12,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "hl_cuda_cublas.h" #include #include #include "hl_cuda.h" -#include "hl_cuda_cublas.h" -#include "hl_thread.ph" #include "hl_dso_loader.h" +#include "hl_thread.ph" #include "paddle/utils/Logging.h" namespace dynload { diff --git a/paddle/cuda/src/hl_cuda_cudnn.cc b/paddle/cuda/src/hl_cuda_cudnn.cc index 9d4ff08a78d641896e946e9bf04590d4ba93350f..7111224d599f0d67395254a95d7f63110a6a87c4 100644 --- a/paddle/cuda/src/hl_cuda_cudnn.cc +++ b/paddle/cuda/src/hl_cuda_cudnn.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,14 +12,14 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "hl_cuda_cudnn.h" #include #include -#include "hl_cuda_cudnn.h" #include "hl_cuda_cudnn.ph" -#include "hl_thread.ph" #include "hl_dso_loader.h" -#include "paddle/utils/Logging.h" +#include "hl_thread.ph" #include "paddle/utils/CommandLineParser.h" +#include "paddle/utils/Logging.h" P_DEFINE_int32(cudnn_conv_workspace_limit_in_mb, 4096, diff --git a/paddle/cuda/src/hl_cuda_device.cc b/paddle/cuda/src/hl_cuda_device.cc index 6b71a538485a09cf40a53eddf1ee2f3e2c768b2c..b0bba73594d0f7d4aba02745d78da68f0baa3f8a 100644 --- a/paddle/cuda/src/hl_cuda_device.cc +++ b/paddle/cuda/src/hl_cuda_device.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,13 +12,13 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "hl_cuda.h" #include #include #include #include #include #include -#include "hl_cuda.h" #include "hl_cuda.ph" #include "hl_dso_loader.h" #include "hl_thread.ph" diff --git a/paddle/cuda/src/hl_cuda_lstm.cu b/paddle/cuda/src/hl_cuda_lstm.cu index cf009620bf69d05397c5e03de3f7f2856bf4ff6b..b869d903ba3cfb188f823518ba8ee7d17f9b2440 100644 --- a/paddle/cuda/src/hl_cuda_lstm.cu +++ b/paddle/cuda/src/hl_cuda_lstm.cu @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/src/hl_cuda_matrix.cu b/paddle/cuda/src/hl_cuda_matrix.cu index 0b7cd3375671d58464dac93458ec6659add8b730..2b4c6f7c39cff78c0e76cc1dfd41e1c7ef334f11 100644 --- a/paddle/cuda/src/hl_cuda_matrix.cu +++ b/paddle/cuda/src/hl_cuda_matrix.cu @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/src/hl_cuda_sequence.cu b/paddle/cuda/src/hl_cuda_sequence.cu index e83a60ad72fa45999b0c29656f7eaf55c81910a5..4e33ac443c1f78b7fa50a15784875cbadfcf7497 100644 --- a/paddle/cuda/src/hl_cuda_sequence.cu +++ b/paddle/cuda/src/hl_cuda_sequence.cu @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/src/hl_cuda_sparse.cu b/paddle/cuda/src/hl_cuda_sparse.cu index 1687fcc221ab85aff943ccf8c5be7c1ed918f853..ab9ab57c884137f117c25c2752b5603b2e8b7135 100644 --- a/paddle/cuda/src/hl_cuda_sparse.cu +++ b/paddle/cuda/src/hl_cuda_sparse.cu @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/src/hl_cuda_sparse.cuh b/paddle/cuda/src/hl_cuda_sparse.cuh index 9cf2d5a843343075c33d19bf34d9ed315299de83..72572756a671b0d43f9b5e68bab2a5e5aef5f762 100644 --- a/paddle/cuda/src/hl_cuda_sparse.cuh +++ b/paddle/cuda/src/hl_cuda_sparse.cuh @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/src/hl_cudart_wrap.cc b/paddle/cuda/src/hl_cudart_wrap.cc index a95f5557afb4976e5fc1d5a71ea4f70463f00122..ecc03a729dde2f2b4f8f004234a47d9272997a50 100644 --- a/paddle/cuda/src/hl_cudart_wrap.cc +++ b/paddle/cuda/src/hl_cudart_wrap.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,8 +14,8 @@ limitations under the License. */ #ifdef PADDLE_USE_DSO -#include #include +#include #include "hl_dso_loader.h" /** diff --git a/paddle/cuda/src/hl_dso_loader.cc b/paddle/cuda/src/hl_dso_loader.cc index ce19073626a8e85e5133d4e1ba1ca71e5653025c..f509b8924319dcaa48adaf1de32fec03e45d61c5 100644 --- a/paddle/cuda/src/hl_dso_loader.cc +++ b/paddle/cuda/src/hl_dso_loader.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/src/hl_math.cc b/paddle/cuda/src/hl_math.cc index f4bf888bab4e92dd940714ef1b7aeee9242eb817..3048693fb870d7032fb690570d7e31e17001507a 100644 --- a/paddle/cuda/src/hl_math.cc +++ b/paddle/cuda/src/hl_math.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/src/hl_perturbation_util.cu b/paddle/cuda/src/hl_perturbation_util.cu index a10d06f8a97cd8c807d173d8a8c29ac698b26bd5..2a945bcdb87fe49c121890128ef77b084ebe8e60 100644 --- a/paddle/cuda/src/hl_perturbation_util.cu +++ b/paddle/cuda/src/hl_perturbation_util.cu @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/src/hl_table_apply.cu b/paddle/cuda/src/hl_table_apply.cu index 52ee4610edf670dc339e0ece66d58153c0164499..61edbe3ccc7028fd8779c4119f33c4cb5afe0564 100644 --- a/paddle/cuda/src/hl_table_apply.cu +++ b/paddle/cuda/src/hl_table_apply.cu @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/src/hl_time.cc b/paddle/cuda/src/hl_time.cc index d52b2a1df07374f632def12eb52e10e10ca86028..7e5d7e8aaecbcdc61c1e5b5006a2958d4dc84460 100644 --- a/paddle/cuda/src/hl_time.cc +++ b/paddle/cuda/src/hl_time.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,10 +12,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include +#include "hl_time.h" #include +#include +#include #include -#include "hl_time.h" using std::chrono::high_resolution_clock; diff --git a/paddle/cuda/src/hl_top_k.cu b/paddle/cuda/src/hl_top_k.cu index ed74787b610ca13fb527348fb6ebcc68af0fefe8..f0ef0cc3c51f9e7935dc3c40f630e4d70960802a 100644 --- a/paddle/cuda/src/hl_top_k.cu +++ b/paddle/cuda/src/hl_top_k.cu @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/cuda/src/hl_warpctc_wrap.cc b/paddle/cuda/src/hl_warpctc_wrap.cc index 3d3bf461586740175e24fbc60b3503e035f6d224..9ae8bc0f220e143a5c59d8c3ead012a20369e7b9 100644 --- a/paddle/cuda/src/hl_warpctc_wrap.cc +++ b/paddle/cuda/src/hl_warpctc_wrap.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include #include "hl_warpctc_wrap.h" +#include #include "hl_dso_loader.h" #include "paddle/utils/Logging.h" diff --git a/paddle/gserver/activations/ActivationFunction.cpp b/paddle/gserver/activations/ActivationFunction.cpp index 220f220e0f2919ab69a164e6bf6265c3cbaa5494..f8c4bcac2f8eb41400659dc24ba81768e7ae3640 100644 --- a/paddle/gserver/activations/ActivationFunction.cpp +++ b/paddle/gserver/activations/ActivationFunction.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -15,13 +15,13 @@ limitations under the License. */ #include "ActivationFunction.h" #include -#include #include -#include +#include #include #include -#include "paddle/utils/ClassRegistrar.h" +#include #include "paddle/parameter/Argument.h" +#include "paddle/utils/ClassRegistrar.h" #include "paddle/utils/Logging.h" diff --git a/paddle/gserver/activations/ActivationFunction.h b/paddle/gserver/activations/ActivationFunction.h index e9ed5c619ab5e4dd9c52c0dac24478c2a57aa1bf..601e3b6c0cd401ec007e8cf51e44416f82832e58 100644 --- a/paddle/gserver/activations/ActivationFunction.h +++ b/paddle/gserver/activations/ActivationFunction.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/dataproviders/DataProvider.cpp b/paddle/gserver/dataproviders/DataProvider.cpp index e6cc4a246a8494d287f8638674f4ae213f38f657..0478256f9cd81f4a99eb0cbcbd1a5a21de5cf14b 100644 --- a/paddle/gserver/dataproviders/DataProvider.cpp +++ b/paddle/gserver/dataproviders/DataProvider.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,12 +14,12 @@ limitations under the License. */ #include "DataProvider.h" -#include "paddle/utils/Util.h" -#include "paddle/utils/StringUtil.h" -#include "paddle/utils/Logging.h" -#include #include +#include #include "ProtoDataProvider.h" +#include "paddle/utils/Logging.h" +#include "paddle/utils/StringUtil.h" +#include "paddle/utils/Util.h" namespace paddle { diff --git a/paddle/gserver/dataproviders/DataProvider.h b/paddle/gserver/dataproviders/DataProvider.h index 8247693822a2bdcda9d98029f45ab6224de168fe..9b7f7e36cedaa230ae0694d87cc033bd6fa6e652 100644 --- a/paddle/gserver/dataproviders/DataProvider.h +++ b/paddle/gserver/dataproviders/DataProvider.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,28 +14,28 @@ limitations under the License. */ #pragma once -#include -#include -#include -#include -#include #include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include "DataConfig.pb.h" +#include "paddle/math/Matrix.h" +#include "paddle/math/SparseMatrix.h" +#include "paddle/math/Vector.h" +#include "paddle/parameter/Argument.h" +#include "paddle/utils/ClassRegistrar.h" +#include "paddle/utils/Locks.h" #include "paddle/utils/Logging.h" #include "paddle/utils/Queue.h" -#include "paddle/utils/Locks.h" #include "paddle/utils/ThreadLocal.h" #include "paddle/utils/TypeDefs.h" -#include "paddle/math/Matrix.h" -#include "paddle/math/SparseMatrix.h" #include "paddle/utils/Util.h" -#include "paddle/math/Vector.h" -#include "DataConfig.pb.h" -#include "paddle/utils/ClassRegistrar.h" -#include "paddle/parameter/Argument.h" namespace paddle { /** diff --git a/paddle/gserver/dataproviders/DataProviderGroup.h b/paddle/gserver/dataproviders/DataProviderGroup.h index 6c178e29ee714a6bd7f58861d7cf15716fee848d..69ac2590b9cc8de95228fe2a83480e2c1e03db0a 100644 --- a/paddle/gserver/dataproviders/DataProviderGroup.h +++ b/paddle/gserver/dataproviders/DataProviderGroup.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/dataproviders/MultiDataProvider.cpp b/paddle/gserver/dataproviders/MultiDataProvider.cpp index 51fb1f26668c55dc1c2aecd5389f327e2569a52f..46fe053768e480c5f69f597c49f363cb966a4168 100644 --- a/paddle/gserver/dataproviders/MultiDataProvider.cpp +++ b/paddle/gserver/dataproviders/MultiDataProvider.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,10 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Util.h" #include "MultiDataProvider.h" -#include "paddle/utils/Logging.h" #include +#include "paddle/utils/Logging.h" +#include "paddle/utils/Util.h" namespace paddle { diff --git a/paddle/gserver/dataproviders/MultiDataProvider.h b/paddle/gserver/dataproviders/MultiDataProvider.h index 876467c04f074cf37e48fdfa9b24f236fcfe8ba1..4c8fb2cd0ddf5d3b6304445508195b5c95dd6ab2 100644 --- a/paddle/gserver/dataproviders/MultiDataProvider.h +++ b/paddle/gserver/dataproviders/MultiDataProvider.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/dataproviders/ProtoDataProvider.cpp b/paddle/gserver/dataproviders/ProtoDataProvider.cpp index 0a7ff802461f2ded0e6e842c088bddf218361f79..d16ecca2d977478e7e7f8819f3b5a5ea48e69b07 100644 --- a/paddle/gserver/dataproviders/ProtoDataProvider.cpp +++ b/paddle/gserver/dataproviders/ProtoDataProvider.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -13,14 +13,14 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "ProtoDataProvider.h" -#include "paddle/utils/Util.h" -#include "paddle/utils/StringUtil.h" #include #include #include +#include "paddle/utils/StringUtil.h" +#include "paddle/utils/Util.h" -#include "paddle/utils/Logging.h" #include "DataProviderGroup.h" +#include "paddle/utils/Logging.h" P_DEFINE_double(memory_threshold_on_load_data, 1.0, @@ -562,16 +562,16 @@ int64_t ProtoDataProvider::getNextBatchInternal(int64_t size, auto mat = cpuArguments[slot].value; mat->resize(size, dim); if (std::dynamic_pointer_cast(mat)) { - std::dynamic_pointer_cast(mat) - ->copyFrom(dataPos.data(), - slots_[slot].indices.data(), - slots_[slot].sparseNonValueData.data(), - HPPL_STREAM_1); + std::dynamic_pointer_cast(mat)->copyFrom( + dataPos.data(), + slots_[slot].indices.data(), + slots_[slot].sparseNonValueData.data(), + HPPL_STREAM_1); } else if (std::dynamic_pointer_cast(mat)) { - std::dynamic_pointer_cast(mat) - ->copyFrom(dataPos.data(), - slots_[slot].indices.data(), - slots_[slot].sparseNonValueData.data()); + std::dynamic_pointer_cast(mat)->copyFrom( + dataPos.data(), + slots_[slot].indices.data(), + slots_[slot].sparseNonValueData.data()); } else { LOG(FATAL) << "Not Supported"; } @@ -598,16 +598,16 @@ int64_t ProtoDataProvider::getNextBatchInternal(int64_t size, auto mat = cpuArguments[slot].value; mat->resize(size, dim); if (std::dynamic_pointer_cast(mat)) { - std::dynamic_pointer_cast(mat) - ->copyFrom(dataPos.data(), - slots_[slot].indices.data(), - slots_[slot].sparseFloatValueData.data(), - HPPL_STREAM_1); + std::dynamic_pointer_cast(mat)->copyFrom( + dataPos.data(), + slots_[slot].indices.data(), + slots_[slot].sparseFloatValueData.data(), + HPPL_STREAM_1); } else if (std::dynamic_pointer_cast(mat)) { - std::dynamic_pointer_cast(mat) - ->copyFrom(dataPos.data(), - slots_[slot].indices.data(), - slots_[slot].sparseFloatValueData.data()); + std::dynamic_pointer_cast(mat)->copyFrom( + dataPos.data(), + slots_[slot].indices.data(), + slots_[slot].sparseFloatValueData.data()); } else { LOG(FATAL) << "Not Supported"; } diff --git a/paddle/gserver/dataproviders/ProtoDataProvider.h b/paddle/gserver/dataproviders/ProtoDataProvider.h index ffdcc8fdc977f53e29dc9f03fa3cf7af56acb92f..7dd45e062248f20d24c633dd4e1c8b7eebcbfa1b 100644 --- a/paddle/gserver/dataproviders/ProtoDataProvider.h +++ b/paddle/gserver/dataproviders/ProtoDataProvider.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -16,8 +16,8 @@ limitations under the License. */ #include -#include "paddle/utils/Stat.h" #include "DataFormat.pb.h" +#include "paddle/utils/Stat.h" #include "DataProvider.h" #include "ProtoReader.h" diff --git a/paddle/gserver/dataproviders/ProtoReader.h b/paddle/gserver/dataproviders/ProtoReader.h index b8fca3cd7f3c5efaea35dc8e09f7ca0ec250830f..4e6f58a5292bec276994fde0764278d12d7ae9d5 100644 --- a/paddle/gserver/dataproviders/ProtoReader.h +++ b/paddle/gserver/dataproviders/ProtoReader.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -16,10 +16,10 @@ limitations under the License. */ #include -#include #include -#include #include +#include +#include namespace paddle { diff --git a/paddle/gserver/dataproviders/PyDataProvider.cpp b/paddle/gserver/dataproviders/PyDataProvider.cpp index bee6ca14a2ec3995a3b432fc5a39419a5dd8a8ce..5bdd55309c8bf8d5dcf84f5dcef2c5c85249a668 100644 --- a/paddle/gserver/dataproviders/PyDataProvider.cpp +++ b/paddle/gserver/dataproviders/PyDataProvider.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -13,10 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "PyDataProvider.h" -#include "paddle/utils/PythonUtil.h" #include -#include "paddle/utils/Util.h" #include "paddle/utils/Excepts.h" +#include "paddle/utils/PythonUtil.h" +#include "paddle/utils/Util.h" namespace paddle { @@ -316,16 +316,16 @@ void PyDataProvider::handleSparseNonValueSlot( auto mat = cpuArguments[slotIndex].value; mat->resize(slot.sampleNum, dim, slot.sampleNum, NO_VALUE, SPARSE_CSR); if (std::dynamic_pointer_cast(mat)) { - std::dynamic_pointer_cast(mat) - ->copyFrom(slot.sampleSequenceIdVec.data(), - slot.indices.data(), - slot.sparseNonValueData.data(), - HPPL_STREAM_1); + std::dynamic_pointer_cast(mat)->copyFrom( + slot.sampleSequenceIdVec.data(), + slot.indices.data(), + slot.sparseNonValueData.data(), + HPPL_STREAM_1); } else if (std::dynamic_pointer_cast(mat)) { - std::dynamic_pointer_cast(mat) - ->copyFrom(slot.sampleSequenceIdVec.data(), - slot.indices.data(), - slot.sparseNonValueData.data()); + std::dynamic_pointer_cast(mat)->copyFrom( + slot.sampleSequenceIdVec.data(), + slot.indices.data(), + slot.sparseNonValueData.data()); } else { LOG(FATAL) << "Not Supported"; } @@ -347,16 +347,16 @@ void PyDataProvider::handleSparseValueSlot( auto mat = cpuArguments[slotIndex].value; mat->resize(slot.sampleNum, dim, slot.sampleNum, FLOAT_VALUE, SPARSE_CSR); if (std::dynamic_pointer_cast(mat)) { - std::dynamic_pointer_cast(mat) - ->copyFrom(slot.sampleSequenceIdVec.data(), - slot.indices.data(), - slot.sparseFloatValueData.data(), - HPPL_STREAM_DEFAULT); + std::dynamic_pointer_cast(mat)->copyFrom( + slot.sampleSequenceIdVec.data(), + slot.indices.data(), + slot.sparseFloatValueData.data(), + HPPL_STREAM_DEFAULT); } else if (std::dynamic_pointer_cast(mat)) { - std::dynamic_pointer_cast(mat) - ->copyFrom(slot.sampleSequenceIdVec.data(), - slot.indices.data(), - slot.sparseFloatValueData.data()); + std::dynamic_pointer_cast(mat)->copyFrom( + slot.sampleSequenceIdVec.data(), + slot.indices.data(), + slot.sparseFloatValueData.data()); } else { LOG(FATAL) << "Not Supported"; } diff --git a/paddle/gserver/dataproviders/PyDataProvider.h b/paddle/gserver/dataproviders/PyDataProvider.h index 6bb7c831fdd451abc5241199d6a4d1b1ad814517..1401c13a1e611fda3000ec4af826ba0e66a3998a 100644 --- a/paddle/gserver/dataproviders/PyDataProvider.h +++ b/paddle/gserver/dataproviders/PyDataProvider.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/dataproviders/PyDataProvider2.cpp b/paddle/gserver/dataproviders/PyDataProvider2.cpp index 967fc9026a39967477d606862e060b680512901a..460efc5adc6f017e91dc9daff6ab32312e4460c1 100644 --- a/paddle/gserver/dataproviders/PyDataProvider2.cpp +++ b/paddle/gserver/dataproviders/PyDataProvider2.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -15,18 +15,18 @@ limitations under the License. */ #ifndef PADDLE_NO_PYTHON #include +#include #include #include -#include #include -#include +#include #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION #include #include "DataProvider.h" -#include "paddle/utils/PythonUtil.h" #include "paddle/utils/Locks.h" +#include "paddle/utils/PythonUtil.h" #include "paddle/utils/Stat.h" namespace paddle { @@ -400,10 +400,9 @@ private: if (this->loadThread_) { // wait poolActualSize < poolSize; std::unique_lock l(mtx_); - pushCV_.wait(l, - [this, additionalBatchSize] { - return this->poolActualSize_ < poolSize_; - }); + pushCV_.wait(l, [this, additionalBatchSize] { + return this->poolActualSize_ < poolSize_; + }); } { @@ -529,12 +528,10 @@ public: // but, loading from cache, cache object should ensure // data pool ready. std::unique_lock l(mtx_); - pullCV_.wait(l, - [this, &size] { - return this->poolActualSize_ >= - std::max(size, this->minPoolSize_) || - callingContexts_.empty(); - }); + pullCV_.wait(l, [this, &size] { + return this->poolActualSize_ >= std::max(size, this->minPoolSize_) || + callingContexts_.empty(); + }); if (unittest::OnPoolFilled) { (*unittest::OnPoolFilled)(this->poolActualSize_); diff --git a/paddle/gserver/evaluators/CTCErrorEvaluator.cpp b/paddle/gserver/evaluators/CTCErrorEvaluator.cpp index 8f7d2fb80e9b6f2b4c83d90a04dab5219435d344..05aa6c012ae2bc0afcbaf23f8ff78b3c782d050c 100644 --- a/paddle/gserver/evaluators/CTCErrorEvaluator.cpp +++ b/paddle/gserver/evaluators/CTCErrorEvaluator.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/evaluators/ChunkEvaluator.cpp b/paddle/gserver/evaluators/ChunkEvaluator.cpp index 923e77fc9df919794902daed6113792e7f89a552..3d8af5bcd419e76fb2026eddc95dc409a33c9d92 100644 --- a/paddle/gserver/evaluators/ChunkEvaluator.cpp +++ b/paddle/gserver/evaluators/ChunkEvaluator.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/evaluators/Evaluator.cpp b/paddle/gserver/evaluators/Evaluator.cpp index f5df2b18dedde9022d04b034912e59be00f15413..7556d21e01e0314d3ee17fa37642081174ec41f3 100644 --- a/paddle/gserver/evaluators/Evaluator.cpp +++ b/paddle/gserver/evaluators/Evaluator.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Stat.h" #include "paddle/gserver/evaluators/Evaluator.h" +#include "paddle/utils/Stat.h" #include "paddle/gserver/gradientmachines/NeuralNetwork.h" @@ -842,9 +842,9 @@ void PnpairEvaluator::calc(std::vector& predictArray) { auto start = predictArray.begin(); while (start != predictArray.end()) { auto end = std::find_if( - start + 1, - predictArray.end(), - [=](const PredictionResult& x) { return x.queryid != start->queryid; }); + start + 1, predictArray.end(), [=](const PredictionResult& x) { + return x.queryid != start->queryid; + }); CHECK(end != start); stat(start - predictArray.begin(), end - predictArray.begin(), diff --git a/paddle/gserver/evaluators/Evaluator.h b/paddle/gserver/evaluators/Evaluator.h index 732abb6079523b1cce8d0727c94ef65581842b4c..5770847309670ef1856cfb9255fa847c24513b56 100644 --- a/paddle/gserver/evaluators/Evaluator.h +++ b/paddle/gserver/evaluators/Evaluator.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,11 +14,11 @@ limitations under the License. */ #pragma once -#include "paddle/pserver/ParameterClient2.h" -#include "paddle/utils/ClassRegistrar.h" +#include #include "ModelConfig.pb.h" #include "paddle/parameter/Argument.h" -#include +#include "paddle/pserver/ParameterClient2.h" +#include "paddle/utils/ClassRegistrar.h" namespace paddle { diff --git a/paddle/gserver/gradientmachines/GradientMachine.cpp b/paddle/gserver/gradientmachines/GradientMachine.cpp index 3761fda5f370e3b1aef0e394286c49d8ec831694..36ca05b919b136c162105cf4f1fb7705ae7ca7f3 100644 --- a/paddle/gserver/gradientmachines/GradientMachine.cpp +++ b/paddle/gserver/gradientmachines/GradientMachine.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,16 +14,16 @@ limitations under the License. */ #include "GradientMachine.h" -#include "paddle/utils/Logging.h" #include +#include "paddle/utils/Logging.h" -#include "hl_gpu.h" -#include "NeuralNetwork.h" -#include "ParallelNeuralNetwork.h" +#include "GradientMachineMode.h" #include "MultiGradientMachine.h" -#include "NeuralNetwork.h" #include "MultiNetwork.h" -#include "GradientMachineMode.h" +#include "NeuralNetwork.h" +#include "NeuralNetwork.h" +#include "ParallelNeuralNetwork.h" +#include "hl_gpu.h" namespace paddle { diff --git a/paddle/gserver/gradientmachines/GradientMachine.h b/paddle/gserver/gradientmachines/GradientMachine.h index 27cdf7f7890673673d5be63fecdd61d5d2a11447..579eca71d4cdd2545a3a8be1c7f1dacfdd5ef66b 100644 --- a/paddle/gserver/gradientmachines/GradientMachine.h +++ b/paddle/gserver/gradientmachines/GradientMachine.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -17,15 +17,15 @@ limitations under the License. */ #include #include -#include "paddle/math/Matrix.h" -#include "paddle/parameter/Parameter.h" -#include "paddle/parameter/ParameterUpdaterBase.h" -#include "paddle/utils/Thread.h" -#include "TrainerConfig.pb.h" #include "ModelConfig.pb.h" +#include "TrainerConfig.pb.h" #include "paddle/gserver/dataproviders/DataProvider.h" #include "paddle/gserver/evaluators/Evaluator.h" #include "paddle/gserver/layers/Layer.h" +#include "paddle/math/Matrix.h" +#include "paddle/parameter/Parameter.h" +#include "paddle/parameter/ParameterUpdaterBase.h" +#include "paddle/utils/Thread.h" namespace paddle { /** diff --git a/paddle/gserver/gradientmachines/GradientMachineMode.cpp b/paddle/gserver/gradientmachines/GradientMachineMode.cpp index 4a90a4a566ac9b9a5eb627a1b895151fb9e9cfc0..3583fb4de88acd1c68b1a1f56ea393bb630ba356 100644 --- a/paddle/gserver/gradientmachines/GradientMachineMode.cpp +++ b/paddle/gserver/gradientmachines/GradientMachineMode.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/gradientmachines/GradientMachineMode.h b/paddle/gserver/gradientmachines/GradientMachineMode.h index f2f55a70671858145572e4a5c0f1c4b609145f98..7bc885fe99ed3831aa111561dd1cd20d499d5e53 100644 --- a/paddle/gserver/gradientmachines/GradientMachineMode.h +++ b/paddle/gserver/gradientmachines/GradientMachineMode.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/gradientmachines/MultiGradientMachine.cpp b/paddle/gserver/gradientmachines/MultiGradientMachine.cpp index 148451f18dceb0c470dadab01ff91915f994c68f..a7324f55451e696176a040b470c2d3bdf9eaa392 100644 --- a/paddle/gserver/gradientmachines/MultiGradientMachine.cpp +++ b/paddle/gserver/gradientmachines/MultiGradientMachine.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/gradientmachines/MultiGradientMachine.h b/paddle/gserver/gradientmachines/MultiGradientMachine.h index 58c5486810cf280c48c62f2256480c1a4bb047bc..5f9855c4be869aa73aaebfc2e75ee51f050f2722 100644 --- a/paddle/gserver/gradientmachines/MultiGradientMachine.h +++ b/paddle/gserver/gradientmachines/MultiGradientMachine.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -18,9 +18,9 @@ limitations under the License. */ #include "GradientMachine.h" -#include "paddle/utils/Queue.h" -#include "paddle/utils/Locks.h" #include "hl_gpu.h" +#include "paddle/utils/Locks.h" +#include "paddle/utils/Queue.h" namespace paddle { diff --git a/paddle/gserver/gradientmachines/MultiNetwork.cpp b/paddle/gserver/gradientmachines/MultiNetwork.cpp index e5be19cad6b450850de4cc5776017b79d3243681..6eb3d8db962161ed4123b4ef4a4bb42147bfdf19 100644 --- a/paddle/gserver/gradientmachines/MultiNetwork.cpp +++ b/paddle/gserver/gradientmachines/MultiNetwork.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include #include "paddle/utils/Stat.h" #include "paddle/utils/Util.h" -#include #include "MultiNetwork.h" diff --git a/paddle/gserver/gradientmachines/MultiNetwork.h b/paddle/gserver/gradientmachines/MultiNetwork.h index 779a2267f55c8e1b5d120d9fd1e2a0d455cc5c59..89fbf32b4f90bceab60b8335c27b369806faaee1 100644 --- a/paddle/gserver/gradientmachines/MultiNetwork.h +++ b/paddle/gserver/gradientmachines/MultiNetwork.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/gradientmachines/NeuralNetwork.cpp b/paddle/gserver/gradientmachines/NeuralNetwork.cpp index 9932ea655ebdceb2eb1ae8920f4d320163d14262..ee36a87b9d848edcc37f89221141de3f939e1110 100644 --- a/paddle/gserver/gradientmachines/NeuralNetwork.cpp +++ b/paddle/gserver/gradientmachines/NeuralNetwork.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,15 +14,15 @@ limitations under the License. */ #include "paddle/utils/Util.h" -#include "paddle/utils/Logging.h" #include "paddle/utils/CustomStackTrace.h" +#include "paddle/utils/Logging.h" -#include "paddle/utils/Stat.h" -#include "hl_gpu.h" +#include "MultiNetwork.h" #include "NeuralNetwork.h" #include "RecurrentGradientMachine.h" -#include "MultiNetwork.h" +#include "hl_gpu.h" #include "paddle/gserver/layers/AgentLayer.h" +#include "paddle/utils/Stat.h" namespace paddle { void parameterInitNN(int paramId, diff --git a/paddle/gserver/gradientmachines/NeuralNetwork.h b/paddle/gserver/gradientmachines/NeuralNetwork.h index 55ef45c5eeddc770ec3bc8fd0055d561eaf3b754..384ca88f47ffb20ca7d16a276a190b063158d273 100644 --- a/paddle/gserver/gradientmachines/NeuralNetwork.h +++ b/paddle/gserver/gradientmachines/NeuralNetwork.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,18 +14,18 @@ limitations under the License. */ #pragma once -#include -#include #include +#include +#include -#include "paddle/utils/ClassRegistrar.h" -#include "paddle/parameter/Parameter.h" #include "ModelConfig.pb.h" +#include "paddle/gserver/dataproviders/DataProvider.h" #include "paddle/gserver/gradientmachines/GradientMachine.h" #include "paddle/gserver/layers/CostLayer.h" #include "paddle/gserver/layers/DataLayer.h" -#include "paddle/gserver/dataproviders/DataProvider.h" #include "paddle/gserver/layers/Layer.h" +#include "paddle/parameter/Parameter.h" +#include "paddle/utils/ClassRegistrar.h" namespace paddle { /* @@ -57,14 +57,13 @@ void parameterInitNN(int paramId, class NeuralNetwork : public GradientMachine { public: - virtual void init( - const ModelConfig& config, - ParamInitCallback callback = nullptr, - const std::vector& - parameterTypes = std::vector{PARAMETER_VALUE, - PARAMETER_GRADIENT, - PARAMETER_MOMENTUM}, - bool useGpu = FLAGS_use_gpu); + virtual void init(const ModelConfig& config, + ParamInitCallback callback = nullptr, + const std::vector& parameterTypes = + std::vector{PARAMETER_VALUE, + PARAMETER_GRADIENT, + PARAMETER_MOMENTUM}, + bool useGpu = FLAGS_use_gpu); /** * Connect two submodels and diff --git a/paddle/gserver/gradientmachines/ParallelNeuralNetwork.cpp b/paddle/gserver/gradientmachines/ParallelNeuralNetwork.cpp index 9dbf418c31b0969eef7477a22b6f1bf63dab9b03..980a5851a2734ce42b3417d16a37987dc5ed6b24 100644 --- a/paddle/gserver/gradientmachines/ParallelNeuralNetwork.cpp +++ b/paddle/gserver/gradientmachines/ParallelNeuralNetwork.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/gradientmachines/ParallelNeuralNetwork.h b/paddle/gserver/gradientmachines/ParallelNeuralNetwork.h index 71488bc3b7a52d851d0e3fb77c48f3fd36bdce83..8f445b1ded3eb8960dc06512dd3f80b00d284acc 100644 --- a/paddle/gserver/gradientmachines/ParallelNeuralNetwork.h +++ b/paddle/gserver/gradientmachines/ParallelNeuralNetwork.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -37,14 +37,13 @@ public: NeuralNetwork *rootNetwork = nullptr) : NeuralNetwork(subModelName, rootNetwork) {} - virtual void init( - const ModelConfig &config, - ParamInitCallback callback = nullptr, - const std::vector - ¶meterTypes = std::vector{PARAMETER_VALUE, - PARAMETER_GRADIENT, - PARAMETER_MOMENTUM}, - bool useGpu = FLAGS_use_gpu); + virtual void init(const ModelConfig &config, + ParamInitCallback callback = nullptr, + const std::vector ¶meterTypes = + std::vector{PARAMETER_VALUE, + PARAMETER_GRADIENT, + PARAMETER_MOMENTUM}, + bool useGpu = FLAGS_use_gpu); virtual void forward(const std::vector &inArgs, std::vector *outArgs, diff --git a/paddle/gserver/gradientmachines/RecurrentGradientMachine.cpp b/paddle/gserver/gradientmachines/RecurrentGradientMachine.cpp index 516b61757698923eb0fde1f3b1d28074cac10044..ee1c92bdf531d9e5cc4bbd63c4f6d91b32b8cee9 100644 --- a/paddle/gserver/gradientmachines/RecurrentGradientMachine.cpp +++ b/paddle/gserver/gradientmachines/RecurrentGradientMachine.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,17 +12,17 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Stat.h" -#include "paddle/utils/Util.h" -#include "paddle/utils/Flags.h" +#include "RecurrentGradientMachine.h" +#include #include +#include #include -#include #include -#include -#include "RecurrentGradientMachine.h" #include "NeuralNetwork.h" #include "paddle/gserver/layers/AgentLayer.h" +#include "paddle/utils/Flags.h" +#include "paddle/utils/Stat.h" +#include "paddle/utils/Util.h" P_DEFINE_string(diy_beam_search_prob_so, "", "the diy beam search cost so"); @@ -78,20 +78,22 @@ static inline SymbolType loadDiySymbol(const char* symbolName) { return reinterpret_cast(sym); } -static InitFunction __init__diy_prob_method([] { - std::string soName = FLAGS_diy_beam_search_prob_so; - if (!soName.empty()) { - gDiyProbHandle = dlopen(soName.c_str(), RTLD_LAZY); - CHECK(gDiyProbHandle) << "Cannot Open DIY Prob So " << soName; - atexit(exit_diy_prob); - gDiyProbMethod = - loadDiySymbol(DIY_CALC_PROB_SYMBOL_NAME); - gDiyProbStart = - loadDiySymbol(DIY_START_CALC_PROB_SYMBOL_NAME); - gDiyProbStop = - loadDiySymbol(DIY_FINISH_CALC_PROB_SYMBOL_NAME); - } -}, std::numeric_limits::max()); +static InitFunction __init__diy_prob_method( + [] { + std::string soName = FLAGS_diy_beam_search_prob_so; + if (!soName.empty()) { + gDiyProbHandle = dlopen(soName.c_str(), RTLD_LAZY); + CHECK(gDiyProbHandle) << "Cannot Open DIY Prob So " << soName; + atexit(exit_diy_prob); + gDiyProbMethod = + loadDiySymbol(DIY_CALC_PROB_SYMBOL_NAME); + gDiyProbStart = loadDiySymbol( + DIY_START_CALC_PROB_SYMBOL_NAME); + gDiyProbStop = loadDiySymbol( + DIY_FINISH_CALC_PROB_SYMBOL_NAME); + } + }, + std::numeric_limits::max()); class BeamSearchControlCallbacks { public: @@ -1281,10 +1283,9 @@ void RecurrentGradientMachine::beamSearch(size_t batchSize) { std::vector*> prefixes; prefixes.resize(paths.size()); std::transform( - paths.begin(), - paths.end(), - prefixes.begin(), - [](const Path& p) { return const_cast*>(&p.ids); }); + paths.begin(), paths.end(), prefixes.begin(), [](const Path& p) { + return const_cast*>(&p.ids); + }); beamSearchCtrlCallbacks_->beamSearchCandidateAdjust( prefixes, frames_[machineCur].get(), i); } diff --git a/paddle/gserver/gradientmachines/RecurrentGradientMachine.h b/paddle/gserver/gradientmachines/RecurrentGradientMachine.h index cb74a67e52f5f48d106b9fe93b1230a1675d3341..db7d8aff6d3150dd272a924c20e16bfe28d11442 100644 --- a/paddle/gserver/gradientmachines/RecurrentGradientMachine.h +++ b/paddle/gserver/gradientmachines/RecurrentGradientMachine.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,9 +14,9 @@ limitations under the License. */ #pragma once +#include #include "GradientMachine.h" #include "NeuralNetwork.h" -#include #include "paddle/utils/Locks.h" diff --git a/paddle/gserver/layers/AddtoLayer.cpp b/paddle/gserver/layers/AddtoLayer.cpp index 8a9aecfa19b815814a985183ee28344a6f4f9712..5338530113e8428ceff58a340394a3bbb21f644e 100644 --- a/paddle/gserver/layers/AddtoLayer.cpp +++ b/paddle/gserver/layers/AddtoLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/AddtoLayer.h b/paddle/gserver/layers/AddtoLayer.h index 883d186f3e63f3a60789c0a4f0e05db1202f3ec8..53d3f99cdd3439a1ba85f54526ca65005986c634 100644 --- a/paddle/gserver/layers/AddtoLayer.h +++ b/paddle/gserver/layers/AddtoLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/AgentLayer.cpp b/paddle/gserver/layers/AgentLayer.cpp index eb89281cb1c75cb9b0679bd40ed4cfd4e2224188..2d300290279d6aafc162f11dbc809537a308ca79 100644 --- a/paddle/gserver/layers/AgentLayer.cpp +++ b/paddle/gserver/layers/AgentLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/AgentLayer.h b/paddle/gserver/layers/AgentLayer.h index 0186653c0f26cd2b53fc6d96d0dfad09dab6fa5b..41683ad6712d5df710737cf71c600790fcc8786f 100644 --- a/paddle/gserver/layers/AgentLayer.h +++ b/paddle/gserver/layers/AgentLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/AverageLayer.cpp b/paddle/gserver/layers/AverageLayer.cpp index af64e15fe3ba68c62f164c45400f55fcaa937068..b8955ab04f209629c855ed66f8e8e9701b7224a3 100644 --- a/paddle/gserver/layers/AverageLayer.cpp +++ b/paddle/gserver/layers/AverageLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/AverageLayer.h b/paddle/gserver/layers/AverageLayer.h index 1edc2ace492c5b96da3255c7e93e257830789985..b3c4ecec8bc6f56b4563ee9f1ada91e4d8f2cbb5 100644 --- a/paddle/gserver/layers/AverageLayer.h +++ b/paddle/gserver/layers/AverageLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/BatchNormBaseLayer.cpp b/paddle/gserver/layers/BatchNormBaseLayer.cpp index fd534b2ac406d4c9a112c1098be84484f980f651..1ceaaaa206ee3cbc5421238574c7f310011ccaa5 100644 --- a/paddle/gserver/layers/BatchNormBaseLayer.cpp +++ b/paddle/gserver/layers/BatchNormBaseLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,10 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Stat.h" -#include "Layer.h" #include "BatchNormBaseLayer.h" #include "BatchNormalizationLayer.h" +#include "Layer.h" +#include "paddle/utils/Stat.h" #ifndef PADDLE_ONLY_CPU #include "CudnnBatchNormLayer.h" #endif diff --git a/paddle/gserver/layers/BatchNormBaseLayer.h b/paddle/gserver/layers/BatchNormBaseLayer.h index f956646a6dca7a5b053e5d034866b659d90539d0..75bda95de1472b08538b48072ddf9ea607b83299 100644 --- a/paddle/gserver/layers/BatchNormBaseLayer.h +++ b/paddle/gserver/layers/BatchNormBaseLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,8 +14,8 @@ limitations under the License. */ #pragma once -#include "paddle/utils/Stat.h" #include "Layer.h" +#include "paddle/utils/Stat.h" namespace paddle { diff --git a/paddle/gserver/layers/BatchNormalizationLayer.cpp b/paddle/gserver/layers/BatchNormalizationLayer.cpp index bdc20c9d81b1c321ff55ccdf4880f212d845fb53..e6a0624636380e0e8ed5e6ee5066fbcf0439f507 100644 --- a/paddle/gserver/layers/BatchNormalizationLayer.cpp +++ b/paddle/gserver/layers/BatchNormalizationLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/BatchNormalizationLayer.h b/paddle/gserver/layers/BatchNormalizationLayer.h index 36925a5ed2d56e4a5c58525cc238164f72bef40c..052c2077322be59f9d41966c1c8b6ab20c8f85bb 100644 --- a/paddle/gserver/layers/BatchNormalizationLayer.h +++ b/paddle/gserver/layers/BatchNormalizationLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,8 +14,8 @@ limitations under the License. */ #pragma once -#include "Layer.h" #include "BatchNormBaseLayer.h" +#include "Layer.h" namespace paddle { diff --git a/paddle/gserver/layers/BilinearInterpLayer.cpp b/paddle/gserver/layers/BilinearInterpLayer.cpp index 11028290dcd1015c1bc51d4c34655f527f55346d..1976cb00175d467ca0d94660d754264582bfe832 100644 --- a/paddle/gserver/layers/BilinearInterpLayer.cpp +++ b/paddle/gserver/layers/BilinearInterpLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/BilinearInterpLayer.h b/paddle/gserver/layers/BilinearInterpLayer.h index eba3c054fa8e7521e83d7c8dd1d87079a52b3967..4ff4b0ea793dc901d099bf73d55aa15463e62094 100644 --- a/paddle/gserver/layers/BilinearInterpLayer.h +++ b/paddle/gserver/layers/BilinearInterpLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/BlockExpandLayer.cpp b/paddle/gserver/layers/BlockExpandLayer.cpp index 17d77879b27be332a49eae4e476b776ec2f5c8e2..2bafeb92158c56efe32f90742807f0af07bda5af 100644 --- a/paddle/gserver/layers/BlockExpandLayer.cpp +++ b/paddle/gserver/layers/BlockExpandLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/BlockExpandLayer.h b/paddle/gserver/layers/BlockExpandLayer.h index 1496fb681acd7ca7190e43cce38c7eb347932d29..cc96fdd03fcac6925a16f0fb91045f065f74e803 100644 --- a/paddle/gserver/layers/BlockExpandLayer.h +++ b/paddle/gserver/layers/BlockExpandLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/CRFDecodingLayer.cpp b/paddle/gserver/layers/CRFDecodingLayer.cpp index 8986741dc307ba765707d6e5817a2e376b27828e..fdb46aba68e924480a6595b02c04ff4d1edd914d 100644 --- a/paddle/gserver/layers/CRFDecodingLayer.cpp +++ b/paddle/gserver/layers/CRFDecodingLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/CRFDecodingLayer.h b/paddle/gserver/layers/CRFDecodingLayer.h index 1914062011d3bceba2f8765fb3cfd2d29ca6d6e9..1fd444ad10e71df2bb6d8bdb839e6f02b33d647f 100644 --- a/paddle/gserver/layers/CRFDecodingLayer.h +++ b/paddle/gserver/layers/CRFDecodingLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/CRFLayer.cpp b/paddle/gserver/layers/CRFLayer.cpp index ed4f864ba9167129db1a3f56403940d9d7807a15..02b7aaf17e89d889ca0030f9de2b5d7431a28fd3 100644 --- a/paddle/gserver/layers/CRFLayer.cpp +++ b/paddle/gserver/layers/CRFLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/CRFLayer.h b/paddle/gserver/layers/CRFLayer.h index 21c7fc61e168cea438339db4e7abce59082fc58d..d21b32b68c1a40c814af3aa2c285612a5f938d79 100644 --- a/paddle/gserver/layers/CRFLayer.h +++ b/paddle/gserver/layers/CRFLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/CTCLayer.cpp b/paddle/gserver/layers/CTCLayer.cpp index be5d2c8c75d6eb2381a2c1758088de0eff462200..14ec851551848b0e8182909537a26d37a1286ac3 100644 --- a/paddle/gserver/layers/CTCLayer.cpp +++ b/paddle/gserver/layers/CTCLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/CTCLayer.h b/paddle/gserver/layers/CTCLayer.h index 18ba12583b5a22849f1ee849a3cce7249730fdaf..70d429bad656ade3c05256472d799ae72e128be5 100644 --- a/paddle/gserver/layers/CTCLayer.h +++ b/paddle/gserver/layers/CTCLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/ConcatenateLayer.cpp b/paddle/gserver/layers/ConcatenateLayer.cpp index 910eec8bbc10ef10f5dd4e4688eef5e87c21f506..d19adace7d58af16736fc2b6e536f5fd69a19863 100644 --- a/paddle/gserver/layers/ConcatenateLayer.cpp +++ b/paddle/gserver/layers/ConcatenateLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Stat.h" #include "Layer.h" #include "Projection.h" +#include "paddle/utils/Stat.h" namespace paddle { diff --git a/paddle/gserver/layers/ContextProjection.cpp b/paddle/gserver/layers/ContextProjection.cpp index 30dbf168fb6e439048e0168af572d1f20a303e79..7ac56e3a2ab2a2a7f2219b8bfd34c16a84c427c0 100644 --- a/paddle/gserver/layers/ContextProjection.cpp +++ b/paddle/gserver/layers/ContextProjection.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Stat.h" #include "ContextProjection.h" +#include "paddle/utils/Stat.h" namespace paddle { diff --git a/paddle/gserver/layers/ContextProjection.h b/paddle/gserver/layers/ContextProjection.h index 188dec0fb31bf468c76b9b922e0972c86e819a2d..2df43bd04fec868924b5d45f9def231a48ee7f04 100644 --- a/paddle/gserver/layers/ContextProjection.h +++ b/paddle/gserver/layers/ContextProjection.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/ConvBaseLayer.cpp b/paddle/gserver/layers/ConvBaseLayer.cpp index b5a2f8b8e10e6f81d06e9722c09c5d43b1620ad1..7b234dc2a6663dc677affcae7dc6306c104c1250 100644 --- a/paddle/gserver/layers/ConvBaseLayer.cpp +++ b/paddle/gserver/layers/ConvBaseLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Logging.h" #include "ConvBaseLayer.h" #include "paddle/math/MathUtils.h" +#include "paddle/utils/Logging.h" namespace paddle { bool ConvBaseLayer::init(const LayerMap& layerMap, diff --git a/paddle/gserver/layers/ConvBaseLayer.h b/paddle/gserver/layers/ConvBaseLayer.h index 85f57dbe0b7c9683ba0941ea0edc611f683cf1b4..aedf4100e32fa1294c361b6163c14eab7869b803 100644 --- a/paddle/gserver/layers/ConvBaseLayer.h +++ b/paddle/gserver/layers/ConvBaseLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/ConvOperator.cpp b/paddle/gserver/layers/ConvOperator.cpp index dc06c89dab2524d9b640bfd88f3b3f3ce0117711..f943410dee0dc2f3d356c9d7d8f61398fe2871c8 100644 --- a/paddle/gserver/layers/ConvOperator.cpp +++ b/paddle/gserver/layers/ConvOperator.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/math/Matrix.h" -#include "paddle/math/MathUtils.h" #include "Operator.h" +#include "paddle/math/MathUtils.h" +#include "paddle/math/Matrix.h" namespace paddle { diff --git a/paddle/gserver/layers/ConvProjection.cpp b/paddle/gserver/layers/ConvProjection.cpp index 5a68fb08da3d742fe6067a8be00b831230e6b0af..aa634b3287dedfae7b573e76270ac75e91418da8 100644 --- a/paddle/gserver/layers/ConvProjection.cpp +++ b/paddle/gserver/layers/ConvProjection.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Stat.h" #include "ConvProjection.h" +#include "paddle/utils/Stat.h" namespace paddle { diff --git a/paddle/gserver/layers/ConvProjection.h b/paddle/gserver/layers/ConvProjection.h index 779fe1455ade10ba55e32f4d9478d446b01b8a19..c32e5e1d3ab2f85feb6dd2fb5fbddd7482598e58 100644 --- a/paddle/gserver/layers/ConvProjection.h +++ b/paddle/gserver/layers/ConvProjection.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/ConvShiftLayer.cpp b/paddle/gserver/layers/ConvShiftLayer.cpp index 6e77c1f14e6a6896f6ef7c4042954b25bd58266a..9bfb1ab7a47b11a6793159aefcb4f9fa12b81a6b 100644 --- a/paddle/gserver/layers/ConvShiftLayer.cpp +++ b/paddle/gserver/layers/ConvShiftLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Logging.h" #include "Layer.h" #include "paddle/math/Matrix.h" +#include "paddle/utils/Logging.h" #include "paddle/utils/Stat.h" namespace paddle { diff --git a/paddle/gserver/layers/ConvexCombinationLayer.cpp b/paddle/gserver/layers/ConvexCombinationLayer.cpp index 7e1fef8bc600329ac62002dab7b91238b83b8023..3f4d77a2fe069f239db8cd099dd0d472d6ce3ccc 100644 --- a/paddle/gserver/layers/ConvexCombinationLayer.cpp +++ b/paddle/gserver/layers/ConvexCombinationLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Logging.h" #include "Layer.h" #include "paddle/math/Matrix.h" +#include "paddle/utils/Logging.h" #include "paddle/utils/Stat.h" namespace paddle { diff --git a/paddle/gserver/layers/CosSimLayer.cpp b/paddle/gserver/layers/CosSimLayer.cpp index 894cb5b0d8226cc3b4b60bac38801bf0a7ec6b6a..254120443dc3d41bf2422be2e88cb376d70c93d4 100644 --- a/paddle/gserver/layers/CosSimLayer.cpp +++ b/paddle/gserver/layers/CosSimLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/CosSimLayer.h b/paddle/gserver/layers/CosSimLayer.h index bc47998c11f267a1737ff82e8aa2958f6859bf86..5dcc5d8a5b4dc76cb6cea023a874049731a26516 100644 --- a/paddle/gserver/layers/CosSimLayer.h +++ b/paddle/gserver/layers/CosSimLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/CosSimVecMatLayer.cpp b/paddle/gserver/layers/CosSimVecMatLayer.cpp index 56d177da6458a590299fee5b24b8a9c935510916..ad490b0b8c4656c1eabf519233f2386b4b6e9417 100644 --- a/paddle/gserver/layers/CosSimVecMatLayer.cpp +++ b/paddle/gserver/layers/CosSimVecMatLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Logging.h" #include "Layer.h" #include "paddle/math/Matrix.h" +#include "paddle/utils/Logging.h" #include "paddle/utils/Stat.h" namespace paddle { diff --git a/paddle/gserver/layers/CostLayer.cpp b/paddle/gserver/layers/CostLayer.cpp index 5c839f2d6c4777c0b69fa95478648b286ae4c855..7e9519f6b3af50bf47b660b285c3593087f80271 100644 --- a/paddle/gserver/layers/CostLayer.cpp +++ b/paddle/gserver/layers/CostLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,11 +12,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include +#include "CostLayer.h" #include -#include "paddle/utils/Logging.h" #include -#include "CostLayer.h" +#include +#include "paddle/utils/Logging.h" #include "paddle/math/SparseMatrix.h" diff --git a/paddle/gserver/layers/CostLayer.h b/paddle/gserver/layers/CostLayer.h index 120ff9bd2d1b402e8ef2d074a84b76b0183dcab0..7f73bdb3f7d63ef1c8d76deb64f40d19d20f87c7 100644 --- a/paddle/gserver/layers/CostLayer.h +++ b/paddle/gserver/layers/CostLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/CudnnBatchNormLayer.cpp b/paddle/gserver/layers/CudnnBatchNormLayer.cpp index 6be62b1a25407a5340bb5cdd99745db5d33ec3da..09dac05a7ad7a80bd6b9e12e8f7f060310d516c8 100644 --- a/paddle/gserver/layers/CudnnBatchNormLayer.cpp +++ b/paddle/gserver/layers/CudnnBatchNormLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Stat.h" -#include "Layer.h" #include "CudnnBatchNormLayer.h" +#include "Layer.h" +#include "paddle/utils/Stat.h" namespace paddle { diff --git a/paddle/gserver/layers/CudnnBatchNormLayer.h b/paddle/gserver/layers/CudnnBatchNormLayer.h index 6220e77ceb5e248e5678c9170e85aff1cb40e1cd..b1e7d2082f1443313bfc858a17adfd737ecff98f 100644 --- a/paddle/gserver/layers/CudnnBatchNormLayer.h +++ b/paddle/gserver/layers/CudnnBatchNormLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,9 +14,9 @@ limitations under the License. */ #pragma once -#include "paddle/utils/Stat.h" -#include "Layer.h" #include "BatchNormBaseLayer.h" +#include "Layer.h" +#include "paddle/utils/Stat.h" namespace paddle { diff --git a/paddle/gserver/layers/CudnnConvLayer.cpp b/paddle/gserver/layers/CudnnConvLayer.cpp index 93c5565d2f401549959d6b067b05289592433a3a..978c2c1479c64ab2cdebaaff7394059b3d033ab6 100644 --- a/paddle/gserver/layers/CudnnConvLayer.cpp +++ b/paddle/gserver/layers/CudnnConvLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "CudnnConvLayer.h" #include "paddle/utils/Logging.h" #include "paddle/utils/Stat.h" -#include "CudnnConvLayer.h" namespace paddle { diff --git a/paddle/gserver/layers/CudnnConvLayer.h b/paddle/gserver/layers/CudnnConvLayer.h index 6cfbadfb53839d847b8b2bcf768da0f473ac05e5..b869c695bd753076c6501a1253fcad22139ccadf 100644 --- a/paddle/gserver/layers/CudnnConvLayer.h +++ b/paddle/gserver/layers/CudnnConvLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,10 +14,10 @@ limitations under the License. */ #pragma once +#include #include "ConvBaseLayer.h" -#include "paddle/math/Matrix.h" #include "Projection.h" -#include +#include "paddle/math/Matrix.h" namespace paddle { diff --git a/paddle/gserver/layers/CudnnPoolLayer.cpp b/paddle/gserver/layers/CudnnPoolLayer.cpp index 21d8e2579f77c98da1e30a205952fa53e02fb853..4adb2d4709e585a6fec052435c33714d6e3a3f0e 100644 --- a/paddle/gserver/layers/CudnnPoolLayer.cpp +++ b/paddle/gserver/layers/CudnnPoolLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,10 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "CudnnPoolLayer.h" +#include "paddle/math/Matrix.h" #include "paddle/utils/Logging.h" #include "paddle/utils/Stat.h" -#include "paddle/math/Matrix.h" -#include "CudnnPoolLayer.h" namespace paddle { diff --git a/paddle/gserver/layers/CudnnPoolLayer.h b/paddle/gserver/layers/CudnnPoolLayer.h index 6a6b28db961553506bcf5db206a65e1e9d90fe94..072b2f9513f4ef8aed03ecfa7a9014667bb2ce9e 100644 --- a/paddle/gserver/layers/CudnnPoolLayer.h +++ b/paddle/gserver/layers/CudnnPoolLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/DataLayer.cpp b/paddle/gserver/layers/DataLayer.cpp index 67c49230367d8597860e3c32df434a16944f5daa..66f0606a38cf597c2697ef1d9e9419ea0e94ef5a 100644 --- a/paddle/gserver/layers/DataLayer.cpp +++ b/paddle/gserver/layers/DataLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/DataLayer.h b/paddle/gserver/layers/DataLayer.h index da74702201bd3af3cd73ad51ef2579da97674bc6..d3bc97bb6cd0b8faf8ae108a0147d77854596e25 100644 --- a/paddle/gserver/layers/DataLayer.h +++ b/paddle/gserver/layers/DataLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/DataNormLayer.cpp b/paddle/gserver/layers/DataNormLayer.cpp index b398f3dbedc44eb422124a725aa745f684e821e3..afd532c949fbc4ada53d65a92c858b7c6a11a382 100644 --- a/paddle/gserver/layers/DataNormLayer.cpp +++ b/paddle/gserver/layers/DataNormLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/DataNormLayer.h b/paddle/gserver/layers/DataNormLayer.h index 1179d94fbbd4032c9275f0586de5b526eb21c095..b3043cffd210feaf9ddaed096de762aa7e2a6139 100644 --- a/paddle/gserver/layers/DataNormLayer.h +++ b/paddle/gserver/layers/DataNormLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/DotMulOperator.cpp b/paddle/gserver/layers/DotMulOperator.cpp index 9409493fdaaf0e84ab2e650e2c5e3db0c1fb1fbc..55dabd79d014a08f5a8bf3628483207984c917d0 100644 --- a/paddle/gserver/layers/DotMulOperator.cpp +++ b/paddle/gserver/layers/DotMulOperator.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/DotMulProjection.cpp b/paddle/gserver/layers/DotMulProjection.cpp index 862eeb6f01db04451afb8a91ecb2c04e0f796952..0a1ede3618cb7ae91d5f90fc6bac498c07acc38e 100644 --- a/paddle/gserver/layers/DotMulProjection.cpp +++ b/paddle/gserver/layers/DotMulProjection.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/EosIdCheckLayer.cpp b/paddle/gserver/layers/EosIdCheckLayer.cpp index 3a43705d263898bd407248b3d553185f7e40f798..fa53e2e4cfc8a220eeb2a637d7fe759f1744f9d5 100644 --- a/paddle/gserver/layers/EosIdCheckLayer.cpp +++ b/paddle/gserver/layers/EosIdCheckLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Logging.h" #include "Layer.h" +#include "paddle/utils/Logging.h" namespace paddle { /** diff --git a/paddle/gserver/layers/ExpandConvBaseLayer.cpp b/paddle/gserver/layers/ExpandConvBaseLayer.cpp index 3724609720c97b66d7d1779a0c892628c5d13a44..25948747fe93e65b77d8eef5ac4748c545f79e90 100644 --- a/paddle/gserver/layers/ExpandConvBaseLayer.cpp +++ b/paddle/gserver/layers/ExpandConvBaseLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/ExpandConvBaseLayer.h b/paddle/gserver/layers/ExpandConvBaseLayer.h index 5939d27e2a873308d710c1670a3aec843c3573ad..8445642217cf3e83441ddd9beec80f99faf946bc 100644 --- a/paddle/gserver/layers/ExpandConvBaseLayer.h +++ b/paddle/gserver/layers/ExpandConvBaseLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,9 +14,9 @@ limitations under the License. */ #pragma once +#include #include "ConvBaseLayer.h" #include "paddle/math/Matrix.h" -#include namespace paddle { diff --git a/paddle/gserver/layers/ExpandConvLayer.cpp b/paddle/gserver/layers/ExpandConvLayer.cpp index 0649289c1c671ae5952dd8db9d19f576da67409c..f9267b81a7d4264f5f43552e3d54a45e4b212e00 100644 --- a/paddle/gserver/layers/ExpandConvLayer.cpp +++ b/paddle/gserver/layers/ExpandConvLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "ExpandConvLayer.h" #include "paddle/utils/Logging.h" #include "paddle/utils/Stat.h" -#include "ExpandConvLayer.h" namespace paddle { diff --git a/paddle/gserver/layers/ExpandConvLayer.h b/paddle/gserver/layers/ExpandConvLayer.h index 82a9e88a4208ea98a97bd56ef2f9f38de4f0031e..de81a017e1bac38a5717e8c83a028f5408c0e084 100644 --- a/paddle/gserver/layers/ExpandConvLayer.h +++ b/paddle/gserver/layers/ExpandConvLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,9 +14,9 @@ limitations under the License. */ #pragma once -#include "paddle/math/Matrix.h" #include #include "ExpandConvBaseLayer.h" +#include "paddle/math/Matrix.h" namespace paddle { diff --git a/paddle/gserver/layers/ExpandConvTransLayer.cpp b/paddle/gserver/layers/ExpandConvTransLayer.cpp index 1132ab4f92000c96b22a295b360143d2f356ec5a..520586b13889790c94a3e29902a4ea0ee55e8555 100644 --- a/paddle/gserver/layers/ExpandConvTransLayer.cpp +++ b/paddle/gserver/layers/ExpandConvTransLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "ExpandConvTransLayer.h" #include "paddle/utils/Logging.h" #include "paddle/utils/Stat.h" -#include "ExpandConvTransLayer.h" /* The implementation of the convTransLayer is basically a swap of forward and * backward of the original convLayer. diff --git a/paddle/gserver/layers/ExpandConvTransLayer.h b/paddle/gserver/layers/ExpandConvTransLayer.h index 47efe3f65643fd17b86832fc240cda2e30d3fcc4..4a527d67995e255c65fea1f310551f8de5630030 100644 --- a/paddle/gserver/layers/ExpandConvTransLayer.h +++ b/paddle/gserver/layers/ExpandConvTransLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,9 +14,9 @@ limitations under the License. */ #pragma once -#include "paddle/math/Matrix.h" #include #include "ExpandConvBaseLayer.h" +#include "paddle/math/Matrix.h" namespace paddle { diff --git a/paddle/gserver/layers/ExpandLayer.cpp b/paddle/gserver/layers/ExpandLayer.cpp index 9290ce4f6d46c1237322549924ce1eb7754d2309..de5acfde05add701a1a71815b90522a11350fc9b 100644 --- a/paddle/gserver/layers/ExpandLayer.cpp +++ b/paddle/gserver/layers/ExpandLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/ExpandLayer.h b/paddle/gserver/layers/ExpandLayer.h index fbe0ced9b1754d72874071575b33f552ccf93cc6..5c636144235cdb3800aa921464985616f8ee9203 100644 --- a/paddle/gserver/layers/ExpandLayer.h +++ b/paddle/gserver/layers/ExpandLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/FeatureMapExpandLayer.cpp b/paddle/gserver/layers/FeatureMapExpandLayer.cpp index 97c8d143fe0d84c4e59e224962b53995ee50b844..d023074c52167554358d0d4df7ec40cfba9da2a6 100644 --- a/paddle/gserver/layers/FeatureMapExpandLayer.cpp +++ b/paddle/gserver/layers/FeatureMapExpandLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/FullMatrixProjection.cpp b/paddle/gserver/layers/FullMatrixProjection.cpp index 35a5cb5b7a450e7233b6dddbef58a2acccfb1608..9e72a33a3c6f443497192ff5d39b4d4ad4a02ec0 100644 --- a/paddle/gserver/layers/FullMatrixProjection.cpp +++ b/paddle/gserver/layers/FullMatrixProjection.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/FullMatrixProjection.h b/paddle/gserver/layers/FullMatrixProjection.h index ddb1e7b18c4f967383feb922ce89d13a452109b2..58499f2e1ee815b2e11b68fecdb06ed3abe24756 100644 --- a/paddle/gserver/layers/FullMatrixProjection.h +++ b/paddle/gserver/layers/FullMatrixProjection.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/FullyConnectedLayer.cpp b/paddle/gserver/layers/FullyConnectedLayer.cpp index 70c56499a7738c12db40bfd0ca5fec399d72f99b..89afe33c36697f8d57885043ed68cdf26576e358 100644 --- a/paddle/gserver/layers/FullyConnectedLayer.cpp +++ b/paddle/gserver/layers/FullyConnectedLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -13,11 +13,11 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "FullyConnectedLayer.h" +#include +#include +#include "paddle/math/SparseMatrix.h" #include "paddle/utils/Logging.h" #include "paddle/utils/Stat.h" -#include "paddle/math/SparseMatrix.h" -#include -#include namespace paddle { diff --git a/paddle/gserver/layers/FullyConnectedLayer.h b/paddle/gserver/layers/FullyConnectedLayer.h index e15e1236cdb75d1c41bbb993f86545334785909a..ccd584585c97cb679332cbd10d6f3a1306ca5a54 100644 --- a/paddle/gserver/layers/FullyConnectedLayer.h +++ b/paddle/gserver/layers/FullyConnectedLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/GatedRecurrentLayer.cpp b/paddle/gserver/layers/GatedRecurrentLayer.cpp index 495c2174f3e9afbee676622d53248c7f5aeea404..930d9a056164e7c677adb53b7b67901364da1309 100644 --- a/paddle/gserver/layers/GatedRecurrentLayer.cpp +++ b/paddle/gserver/layers/GatedRecurrentLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "Layer.h" #include "GatedRecurrentLayer.h" +#include "Layer.h" #include "paddle/utils/Stat.h" namespace paddle { @@ -386,8 +386,9 @@ void GatedRecurrentLayer::backwardBatch(int batchSize, MatrixPtr inputGrad) { { batchSize = outputGradTmp->getHeight(); gruValue.prevOutValue = - (n == 0 ? nullptr : (batchValue_->getBatchValue(n - 1, batchSize)) - ->getData()); + (n == 0 + ? nullptr + : (batchValue_->getBatchValue(n - 1, batchSize))->getData()); gruGrad.prevOutGrad = (n == 0 ? nullptr : (batchGrad_->getBatchValue(n - 1, batchSize))->getData()); diff --git a/paddle/gserver/layers/GatedRecurrentLayer.h b/paddle/gserver/layers/GatedRecurrentLayer.h index 3b8706a44e21e5a780c6423b65369dc5b695b59b..25770ce57fbaa4d16c9454d824800f2f0c7f957d 100644 --- a/paddle/gserver/layers/GatedRecurrentLayer.h +++ b/paddle/gserver/layers/GatedRecurrentLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,10 +14,10 @@ limitations under the License. */ #pragma once -#include "paddle/math/Matrix.h" -#include "SequenceToBatch.h" #include "GruCompute.h" #include "Layer.h" +#include "SequenceToBatch.h" +#include "paddle/math/Matrix.h" namespace paddle { diff --git a/paddle/gserver/layers/GetOutputLayer.cpp b/paddle/gserver/layers/GetOutputLayer.cpp index 01579d55fd9d0918b62ae0ddd9a7e90b4a697a13..b77fdbb30e11b72b0c7de765df173204aa0b6851 100644 --- a/paddle/gserver/layers/GetOutputLayer.cpp +++ b/paddle/gserver/layers/GetOutputLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/GruCompute.cpp b/paddle/gserver/layers/GruCompute.cpp index d9d423af448fd267b777ef57964dced3b7a09f63..06907768e98f4bad952706cffbbd65d1f86cc6df 100644 --- a/paddle/gserver/layers/GruCompute.cpp +++ b/paddle/gserver/layers/GruCompute.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Util.h" #include "GruCompute.h" #include "hl_recurrent_apply.cuh" +#include "paddle/utils/Util.h" namespace paddle { diff --git a/paddle/gserver/layers/GruCompute.cu b/paddle/gserver/layers/GruCompute.cu index 4a3cf6b1ca73cc72ff79835ac341cedda4cc94e2..d5e547dce347c824f959425551afea66dfd94e5a 100644 --- a/paddle/gserver/layers/GruCompute.cu +++ b/paddle/gserver/layers/GruCompute.cu @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/GruCompute.h b/paddle/gserver/layers/GruCompute.h index 58b5aacba0403f8d10e34b055f5a69ad5ffa4837..42c0019319ac9f20f9c3349fb2429c30f03d682b 100644 --- a/paddle/gserver/layers/GruCompute.h +++ b/paddle/gserver/layers/GruCompute.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,9 +14,9 @@ limitations under the License. */ #pragma once -#include "paddle/utils/TypeDefs.h" #include "ModelConfig.pb.h" #include "hl_gpu.h" +#include "paddle/utils/TypeDefs.h" namespace paddle { diff --git a/paddle/gserver/layers/GruStepLayer.cpp b/paddle/gserver/layers/GruStepLayer.cpp index 6c9b0c5771bec765d043cd654fbb30ba56f8c813..4a1006aa941f396c233a0cecfc38228f1f9fafe1 100644 --- a/paddle/gserver/layers/GruStepLayer.cpp +++ b/paddle/gserver/layers/GruStepLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "Layer.h" #include "GruCompute.h" +#include "Layer.h" #include "paddle/utils/Stat.h" namespace paddle { diff --git a/paddle/gserver/layers/HierarchicalSigmoidLayer.cpp b/paddle/gserver/layers/HierarchicalSigmoidLayer.cpp index 61bc77778501fb9421cd2a72459d35ac9f47a5cb..d62a8d846e5b347aa44ce1951c043d5813a5b3ff 100644 --- a/paddle/gserver/layers/HierarchicalSigmoidLayer.cpp +++ b/paddle/gserver/layers/HierarchicalSigmoidLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/HierarchicalSigmoidLayer.h b/paddle/gserver/layers/HierarchicalSigmoidLayer.h index 10762bc92687a3ea8debb7b9aa26a0cf0f94421c..70da3ac126e147387b20c5a97d0116a5a679e044 100644 --- a/paddle/gserver/layers/HierarchicalSigmoidLayer.h +++ b/paddle/gserver/layers/HierarchicalSigmoidLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/IdentityProjection.cpp b/paddle/gserver/layers/IdentityProjection.cpp index b38656c960f17b2c2c315eba70c61c328ed3e49a..f1d41a33d40f120d5de8b2bfe9cf3271eefa08be 100644 --- a/paddle/gserver/layers/IdentityProjection.cpp +++ b/paddle/gserver/layers/IdentityProjection.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Stat.h" #include "Projection.h" +#include "paddle/utils/Stat.h" namespace paddle { diff --git a/paddle/gserver/layers/InterpolationLayer.cpp b/paddle/gserver/layers/InterpolationLayer.cpp index b00bee235693d56aecfdc676647e102fe8d0ebfc..44fe1fb1fea4203a4a1cac67c581b13adda65966 100644 --- a/paddle/gserver/layers/InterpolationLayer.cpp +++ b/paddle/gserver/layers/InterpolationLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Logging.h" #include "Layer.h" #include "paddle/math/Matrix.h" +#include "paddle/utils/Logging.h" #include "paddle/utils/Stat.h" namespace paddle { diff --git a/paddle/gserver/layers/Layer.cpp b/paddle/gserver/layers/Layer.cpp index a83b0e9ab4f8320db02cacee42730b2b579c22fd..c9e121047b5fa1297cfca7c268205594f079e1e3 100644 --- a/paddle/gserver/layers/Layer.cpp +++ b/paddle/gserver/layers/Layer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,15 +14,15 @@ limitations under the License. */ #include "paddle/utils/Util.h" -#include "paddle/utils/Logging.h" #include "paddle/math/SparseMatrix.h" +#include "paddle/utils/Logging.h" #include "AddtoLayer.h" +#include "CRFLayer.h" #include "CosSimLayer.h" #include "CostLayer.h" -#include "ExpandConvLayer.h" -#include "CRFLayer.h" #include "DataLayer.h" +#include "ExpandConvLayer.h" #include "FullyConnectedLayer.h" #include "HierarchicalSigmoidLayer.h" #include "MaxLayer.h" diff --git a/paddle/gserver/layers/Layer.h b/paddle/gserver/layers/Layer.h index 3d427a1ac6e38f2bcd49195504d1086b83e3cdf3..172e558b82945296ef8a50d464c03efbfd597e0d 100644 --- a/paddle/gserver/layers/Layer.h +++ b/paddle/gserver/layers/Layer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,18 +14,18 @@ limitations under the License. */ #pragma once -#include -#include #include -#include "paddle/utils/ClassRegistrar.h" +#include +#include +#include "ModelConfig.pb.h" #include "paddle/math/CpuSparseMatrix.h" #include "paddle/parameter/Parameter.h" +#include "paddle/utils/ClassRegistrar.h" #include "paddle/utils/Util.h" -#include "ModelConfig.pb.h" -#include "paddle/gserver/activations/ActivationFunction.h" #include #include +#include "paddle/gserver/activations/ActivationFunction.h" /// Macro for registering a layer type. /// Example: REGISTER_LAYER(crf_error, CRFDecodingErrorLayer); diff --git a/paddle/gserver/layers/LinearChainCRF.cpp b/paddle/gserver/layers/LinearChainCRF.cpp index e2a4f69e717a9ce5e2ecf57d5002e4ac2267c9e2..af550c7a0154802a93bacccab500695bdad36542 100644 --- a/paddle/gserver/layers/LinearChainCRF.cpp +++ b/paddle/gserver/layers/LinearChainCRF.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include #include "LinearChainCRF.h" +#include namespace paddle { diff --git a/paddle/gserver/layers/LinearChainCRF.h b/paddle/gserver/layers/LinearChainCRF.h index 6368f2b9de2f993c6a113315be8d642784b04726..a905bf803dd5443ef8d4ad7702720a50a5220a9a 100644 --- a/paddle/gserver/layers/LinearChainCRF.h +++ b/paddle/gserver/layers/LinearChainCRF.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/LinearChainCTC.cpp b/paddle/gserver/layers/LinearChainCTC.cpp index 3368eb4d8a796eef367042f78b8c18d47bc1330e..cb2b249110dbd736a46a713480eca12e59cb391b 100644 --- a/paddle/gserver/layers/LinearChainCTC.cpp +++ b/paddle/gserver/layers/LinearChainCTC.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include #include "LinearChainCTC.h" +#include #include namespace paddle { diff --git a/paddle/gserver/layers/LinearChainCTC.h b/paddle/gserver/layers/LinearChainCTC.h index 0a93d2e9a6d0d697f5f081abe9fad69faac9b04b..737c9d5c3188f4499267bb9536e1a75ef4871f23 100644 --- a/paddle/gserver/layers/LinearChainCTC.h +++ b/paddle/gserver/layers/LinearChainCTC.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/LstmCompute.cpp b/paddle/gserver/layers/LstmCompute.cpp index 38057636edbea5d1d25d20740b16c319a653e42e..4c4297096423762355a5ee028cac252432cc1956 100644 --- a/paddle/gserver/layers/LstmCompute.cpp +++ b/paddle/gserver/layers/LstmCompute.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Util.h" -#include "hl_recurrent_apply.cuh" #include "LstmCompute.h" +#include "hl_recurrent_apply.cuh" +#include "paddle/utils/Util.h" namespace paddle { diff --git a/paddle/gserver/layers/LstmCompute.cu b/paddle/gserver/layers/LstmCompute.cu index af271d682f6f1077cd64e4ea77d1c3f207aff6f8..f75c0c40ccc833e35f8fe8f21c12b3d3f68d5eb6 100644 --- a/paddle/gserver/layers/LstmCompute.cu +++ b/paddle/gserver/layers/LstmCompute.cu @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/LstmCompute.h b/paddle/gserver/layers/LstmCompute.h index 97be7218f251f21a9a50c7f8ec28e7c487420a2f..140a4c6ecf5cfaf1045cec3ca2db5d4f2e54aca4 100644 --- a/paddle/gserver/layers/LstmCompute.h +++ b/paddle/gserver/layers/LstmCompute.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,9 +14,9 @@ limitations under the License. */ #pragma once -#include "paddle/utils/TypeDefs.h" #include "ModelConfig.pb.h" #include "hl_gpu.h" +#include "paddle/utils/TypeDefs.h" namespace paddle { diff --git a/paddle/gserver/layers/LstmLayer.cpp b/paddle/gserver/layers/LstmLayer.cpp index e70a20e5c0217288b795f647f3918911e3713ceb..452091eff42083537f37d89b8f8464851f2e36db 100644 --- a/paddle/gserver/layers/LstmLayer.cpp +++ b/paddle/gserver/layers/LstmLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -13,8 +13,8 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "LstmLayer.h" -#include "paddle/math/Matrix.h" #include "paddle/math/BaseMatrix.h" +#include "paddle/math/Matrix.h" #include "paddle/utils/Stat.h" P_DECLARE_bool(prev_batch_state); diff --git a/paddle/gserver/layers/LstmLayer.h b/paddle/gserver/layers/LstmLayer.h index 5b936ff44ef1bc26850c5051f4d5561529002cd4..f49df2c412f05f74da455d41cdf7c9bd4b9ec2e2 100644 --- a/paddle/gserver/layers/LstmLayer.h +++ b/paddle/gserver/layers/LstmLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -15,10 +15,10 @@ limitations under the License. */ #pragma once #include "Layer.h" -#include "paddle/math/Matrix.h" -#include "paddle/math/BaseMatrix.h" -#include "SequenceToBatch.h" #include "LstmCompute.h" +#include "SequenceToBatch.h" +#include "paddle/math/BaseMatrix.h" +#include "paddle/math/Matrix.h" namespace paddle { /** diff --git a/paddle/gserver/layers/LstmStepLayer.cpp b/paddle/gserver/layers/LstmStepLayer.cpp index e7a8d519f2dc5eade613f3ad1981434ae8d59b7c..5fc6474b8653f4c7dac284e11d88f803405169a3 100644 --- a/paddle/gserver/layers/LstmStepLayer.cpp +++ b/paddle/gserver/layers/LstmStepLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/MDLstmLayer.cpp b/paddle/gserver/layers/MDLstmLayer.cpp index 93f52c1c314105f9d0b2530218d43045224df948..1243c12889542103f65b427da8f549e852773c5c 100644 --- a/paddle/gserver/layers/MDLstmLayer.cpp +++ b/paddle/gserver/layers/MDLstmLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -13,8 +13,8 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "LstmLayer.h" -#include "paddle/math/Matrix.h" #include "paddle/math/BaseMatrix.h" +#include "paddle/math/Matrix.h" namespace paddle { @@ -318,7 +318,7 @@ void MDLstmLayer::forward(PassType passType) { CHECK_EQ(starts[numSequences], batchSize); int* dimsData = input.cpuSequenceDims->getData(); - CHECK_EQ(int(input.cpuSequenceDims->getSize()), numDims_ * numSequences); + CHECK_EQ(int(input.cpuSequenceDims->getSize()), numDims_* numSequences); for (int i = 0; i < numSequences; i++) { std::vector dims; diff --git a/paddle/gserver/layers/MaxIdLayer.cpp b/paddle/gserver/layers/MaxIdLayer.cpp index 22670fa1210e1199266cb16a1f08826c3010a84e..80555f3f7b324100c059c3356a4a2e462bc6face 100644 --- a/paddle/gserver/layers/MaxIdLayer.cpp +++ b/paddle/gserver/layers/MaxIdLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/MaxLayer.cpp b/paddle/gserver/layers/MaxLayer.cpp index 42bc6bb815232ff8dfa6b49ebf47b10c252e28c5..23629e1986834f0195685cb1ec35358209de6a5b 100644 --- a/paddle/gserver/layers/MaxLayer.cpp +++ b/paddle/gserver/layers/MaxLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/MaxLayer.h b/paddle/gserver/layers/MaxLayer.h index 74df0b8b576c8ea1eef56d465e8c4ceee5019fdb..472ee0ccca196250f4b81fc1e921aaee5f352b7e 100644 --- a/paddle/gserver/layers/MaxLayer.h +++ b/paddle/gserver/layers/MaxLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/MaxOutLayer.cpp b/paddle/gserver/layers/MaxOutLayer.cpp index b7f1b98041355624edbc1b480868079887264467..3a86a95321d8843338267df374dae169271410f5 100644 --- a/paddle/gserver/layers/MaxOutLayer.cpp +++ b/paddle/gserver/layers/MaxOutLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -13,8 +13,8 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "MaxOutLayer.h" -#include "hl_gpu.h" #include "hl_cnn.h" +#include "hl_gpu.h" namespace paddle { diff --git a/paddle/gserver/layers/MaxOutLayer.h b/paddle/gserver/layers/MaxOutLayer.h index 9011a5c332b17a2f697380b1afb40ad9de504b91..59c2245e0d6490d4f8e1b77b1c88267747aaa63a 100644 --- a/paddle/gserver/layers/MaxOutLayer.h +++ b/paddle/gserver/layers/MaxOutLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/MixedLayer.cpp b/paddle/gserver/layers/MixedLayer.cpp index 1392188fcae715734d96b1402924515fa3618965..2525b1984b80a4200923c007d3021d468745133e 100644 --- a/paddle/gserver/layers/MixedLayer.cpp +++ b/paddle/gserver/layers/MixedLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Stat.h" #include "MixedLayer.h" +#include "paddle/utils/Stat.h" namespace paddle { diff --git a/paddle/gserver/layers/MixedLayer.h b/paddle/gserver/layers/MixedLayer.h index 271e0c2538d3b7239a5d54ec43180dddff569b76..9655a152c7bc96fb3941fcbd9db4ff71a59e4ebe 100644 --- a/paddle/gserver/layers/MixedLayer.h +++ b/paddle/gserver/layers/MixedLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -15,8 +15,8 @@ limitations under the License. */ #pragma once #include "Layer.h" -#include "Projection.h" #include "Operator.h" +#include "Projection.h" namespace paddle { diff --git a/paddle/gserver/layers/MultinomialSampler.cpp b/paddle/gserver/layers/MultinomialSampler.cpp index e85dca72d3162d857e768221e970fe8e3951ae9c..0b285ed20f7ad86575aad3f5cbe710108fd75733 100644 --- a/paddle/gserver/layers/MultinomialSampler.cpp +++ b/paddle/gserver/layers/MultinomialSampler.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/MultinomialSampler.h b/paddle/gserver/layers/MultinomialSampler.h index 59683d2ee29924e76ca11eb43fbd8cd175c3c357..6e50f8738e316a0bbc3dac1b715af1ec1288145f 100644 --- a/paddle/gserver/layers/MultinomialSampler.h +++ b/paddle/gserver/layers/MultinomialSampler.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/MultiplexLayer.cpp b/paddle/gserver/layers/MultiplexLayer.cpp index c681eb0623ab7b8426fe34ce6817a3f5f4ad8246..d09720c5255747df11d4d7367f67a245e63e6846 100644 --- a/paddle/gserver/layers/MultiplexLayer.cpp +++ b/paddle/gserver/layers/MultiplexLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Logging.h" #include "Layer.h" #include "paddle/math/Matrix.h" +#include "paddle/utils/Logging.h" #include "paddle/utils/Stat.h" namespace paddle { diff --git a/paddle/gserver/layers/NCELayer.cpp b/paddle/gserver/layers/NCELayer.cpp index 50b29cdea5a352093c0508995da4cf3e2afcc995..540db46545ef03010d6138954070283ec32e5577 100644 --- a/paddle/gserver/layers/NCELayer.cpp +++ b/paddle/gserver/layers/NCELayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/NormLayer.cpp b/paddle/gserver/layers/NormLayer.cpp index 445a1a0c52ed65a6321a265b158388f2d59e4722..3db0af2515ee9f64aa6c0b0a441e88562d9e398e 100644 --- a/paddle/gserver/layers/NormLayer.cpp +++ b/paddle/gserver/layers/NormLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Logging.h" #include "NormLayer.h" #include "NormProjectionLayer.h" +#include "paddle/utils/Logging.h" namespace paddle { REGISTER_LAYER_CREATE_FUNC(norm, &NormLayer::create); diff --git a/paddle/gserver/layers/NormLayer.h b/paddle/gserver/layers/NormLayer.h index fcc57849d6b86df8f175184451a0fd459ce9ec28..86255b231b1eee578e81f31d76fd66bb845b10b7 100644 --- a/paddle/gserver/layers/NormLayer.h +++ b/paddle/gserver/layers/NormLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -16,8 +16,8 @@ limitations under the License. */ #include #include "Layer.h" -#include "paddle/math/Matrix.h" #include "NormLayer.h" +#include "paddle/math/Matrix.h" namespace paddle { diff --git a/paddle/gserver/layers/NormProjectionLayer.cpp b/paddle/gserver/layers/NormProjectionLayer.cpp index da36cc2c9913796b65c451a5c4928143168a1104..934fc31e0acf96263654f4d74a1a4394578986cc 100644 --- a/paddle/gserver/layers/NormProjectionLayer.cpp +++ b/paddle/gserver/layers/NormProjectionLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "NormProjectionLayer.h" #include "paddle/utils/Logging.h" #include "paddle/utils/Stat.h" -#include "NormProjectionLayer.h" namespace paddle { size_t CMRProjectionNormLayer::getSize() { diff --git a/paddle/gserver/layers/NormProjectionLayer.h b/paddle/gserver/layers/NormProjectionLayer.h index b42e98ab0941e59a38bb1cfa73f49682dbef942c..4f7b638334afe3832e03537486f3ffc4dbbdcd9d 100644 --- a/paddle/gserver/layers/NormProjectionLayer.h +++ b/paddle/gserver/layers/NormProjectionLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,9 +14,9 @@ limitations under the License. */ #pragma once +#include #include "NormLayer.h" #include "paddle/math/Matrix.h" -#include namespace paddle { diff --git a/paddle/gserver/layers/Operator.cpp b/paddle/gserver/layers/Operator.cpp index b89c4740142e377f0cbbe755377f37baac270552..a638933914fc489a1d2e4fea9d6144d76cc50cdf 100644 --- a/paddle/gserver/layers/Operator.cpp +++ b/paddle/gserver/layers/Operator.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/Operator.h b/paddle/gserver/layers/Operator.h index ff6558dc73b8d60f3b4a3d87c9d28c650c8f2987..6fd331382f243039fa38b2762b2d5edede60d868 100644 --- a/paddle/gserver/layers/Operator.h +++ b/paddle/gserver/layers/Operator.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,11 +14,11 @@ limitations under the License. */ #pragma once -#include "paddle/parameter/Parameter.h" #include "ModelConfig.pb.h" +#include "paddle/parameter/Parameter.h" -#include "paddle/parameter/Argument.h" #include "Layer.h" +#include "paddle/parameter/Argument.h" namespace paddle { diff --git a/paddle/gserver/layers/OuterProdLayer.cpp b/paddle/gserver/layers/OuterProdLayer.cpp index 9b24a4f440c9e1fc3b4e73a7234c791fff045ea9..cf9a008318e9d8dd50d1f401576082c07680f6c4 100644 --- a/paddle/gserver/layers/OuterProdLayer.cpp +++ b/paddle/gserver/layers/OuterProdLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Logging.h" #include "Layer.h" #include "paddle/math/Matrix.h" +#include "paddle/utils/Logging.h" #include "paddle/utils/Stat.h" namespace paddle { diff --git a/paddle/gserver/layers/ParameterReluLayer.cpp b/paddle/gserver/layers/ParameterReluLayer.cpp index cd3bffa2e1d01ef8367c39c20c8e6f366c583b68..836c1981ba1843ec280d64799cd3ac0d1d03f374 100644 --- a/paddle/gserver/layers/ParameterReluLayer.cpp +++ b/paddle/gserver/layers/ParameterReluLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/ParameterReluLayer.h b/paddle/gserver/layers/ParameterReluLayer.h index 029c09381f0e13de111ef30c4574d2255abfd018..a82497fc01ca1f63719a905c7545911a7e05289b 100644 --- a/paddle/gserver/layers/ParameterReluLayer.h +++ b/paddle/gserver/layers/ParameterReluLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/PoolLayer.cpp b/paddle/gserver/layers/PoolLayer.cpp index 511dfd87c12551c91e8864364dbf1a1085a989b6..96d5c54accc047b685502a178de2d290f3158731 100644 --- a/paddle/gserver/layers/PoolLayer.cpp +++ b/paddle/gserver/layers/PoolLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Logging.h" #include "PoolLayer.h" #include "PoolProjectionLayer.h" +#include "paddle/utils/Logging.h" #ifndef PADDLE_ONLY_CPU #include "CudnnPoolLayer.h" #endif diff --git a/paddle/gserver/layers/PoolLayer.h b/paddle/gserver/layers/PoolLayer.h index 59be295a538b007993e77f85f079f78a8b881eca..318b89d7c2bce896d183eba8c48c230d962918a5 100644 --- a/paddle/gserver/layers/PoolLayer.h +++ b/paddle/gserver/layers/PoolLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,10 +14,10 @@ limitations under the License. */ #pragma once +#include #include "Layer.h" -#include "paddle/math/Matrix.h" #include "paddle/math/MathUtils.h" -#include +#include "paddle/math/Matrix.h" namespace paddle { diff --git a/paddle/gserver/layers/PoolProjection.cpp b/paddle/gserver/layers/PoolProjection.cpp index 1b227c8084991e4bbf1e380881a6018fe01e9180..d90b438448eb72e72e22e9a91a3cbcd84ac7e6cb 100644 --- a/paddle/gserver/layers/PoolProjection.cpp +++ b/paddle/gserver/layers/PoolProjection.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/PoolProjection.h b/paddle/gserver/layers/PoolProjection.h index 9c3191bd80061c13b645c2a107eaa723e2495032..9a75f465f6fbb2f2a928b0e36fcfbe0e510d7b3a 100644 --- a/paddle/gserver/layers/PoolProjection.h +++ b/paddle/gserver/layers/PoolProjection.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/PoolProjectionLayer.cpp b/paddle/gserver/layers/PoolProjectionLayer.cpp index aabc60af197af30a367c0f933276116ba316bd34..ed5011ab8990620acb12f3ca6c488ce403336d45 100644 --- a/paddle/gserver/layers/PoolProjectionLayer.cpp +++ b/paddle/gserver/layers/PoolProjectionLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "PoolProjectionLayer.h" #include "paddle/utils/Logging.h" #include "paddle/utils/Stat.h" -#include "PoolProjectionLayer.h" namespace paddle { diff --git a/paddle/gserver/layers/PoolProjectionLayer.h b/paddle/gserver/layers/PoolProjectionLayer.h index 777b6f39e7cc4ebaa7078ce3378b2688363245e8..3dc6af2f0e9fb1a12eca7bc0c531a2e7b151fb8a 100644 --- a/paddle/gserver/layers/PoolProjectionLayer.h +++ b/paddle/gserver/layers/PoolProjectionLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/PowerLayer.cpp b/paddle/gserver/layers/PowerLayer.cpp index dbe70a1d8785e971c592ca109e8f795a2c257812..64fecab5b08354ceea8b290b78eede72d24a98a2 100644 --- a/paddle/gserver/layers/PowerLayer.cpp +++ b/paddle/gserver/layers/PowerLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Logging.h" #include "Layer.h" #include "paddle/math/Matrix.h" +#include "paddle/utils/Logging.h" #include "paddle/utils/Stat.h" namespace paddle { diff --git a/paddle/gserver/layers/PrintLayer.cpp b/paddle/gserver/layers/PrintLayer.cpp index 95be7b34cb106665d2465630233fca6b34d71e79..ac7f658864fee6812ea89d1dbd84ad4db94e3035 100644 --- a/paddle/gserver/layers/PrintLayer.cpp +++ b/paddle/gserver/layers/PrintLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/Projection.cpp b/paddle/gserver/layers/Projection.cpp index c7eb4b644281ff6e7b58201c41888d3a8967f419..974b3cf059fff24de2b5f4cdcf6f9c05ceedee8d 100644 --- a/paddle/gserver/layers/Projection.cpp +++ b/paddle/gserver/layers/Projection.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/Projection.h b/paddle/gserver/layers/Projection.h index 798503113d761091d1a1bdf9e4ec70e0c2c3b3a4..8cd8042479eafdbd6b8dac03b63b344fcf9526b1 100644 --- a/paddle/gserver/layers/Projection.h +++ b/paddle/gserver/layers/Projection.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/RecurrentLayer.cpp b/paddle/gserver/layers/RecurrentLayer.cpp index 08453e21b8ff27138f9fa44ac834b54eb94c0688..9f3bf76a2dcf42b0ede0f21a241e83de39c5944b 100644 --- a/paddle/gserver/layers/RecurrentLayer.cpp +++ b/paddle/gserver/layers/RecurrentLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -13,9 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "Layer.h" -#include "paddle/utils/Stat.h" #include "SequenceToBatch.h" #include "paddle/utils/CommandLineParser.h" +#include "paddle/utils/Stat.h" P_DEFINE_bool(rnn_use_batch, false, "Using the batch method for calculation."); diff --git a/paddle/gserver/layers/RecurrentLayerGroup.cpp b/paddle/gserver/layers/RecurrentLayerGroup.cpp index a5443975da4ab6ecb302087fe71b018154d439b8..af8dd61d84e2e53ca26dc054d0516e62ab7aa216 100644 --- a/paddle/gserver/layers/RecurrentLayerGroup.cpp +++ b/paddle/gserver/layers/RecurrentLayerGroup.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/gserver/layers/Layer.h" #include +#include "paddle/gserver/layers/Layer.h" #include "paddle/gserver/gradientmachines/RecurrentGradientMachine.h" #include "paddle/utils/Stat.h" diff --git a/paddle/gserver/layers/ResizeLayer.cpp b/paddle/gserver/layers/ResizeLayer.cpp index 3c478a33e350cf0e901381890e3df1496893f4db..7fcb3adea01b9d16394ee90b751b10902dc3a190 100644 --- a/paddle/gserver/layers/ResizeLayer.cpp +++ b/paddle/gserver/layers/ResizeLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -13,8 +13,8 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "Layer.h" -#include "paddle/math/Matrix.h" #include "paddle/math/BaseMatrix.h" +#include "paddle/math/Matrix.h" namespace paddle { /** diff --git a/paddle/gserver/layers/SamplingIdLayer.cpp b/paddle/gserver/layers/SamplingIdLayer.cpp index b39c9948b53118b51090059fc554e76f94316f81..59ff5d41b529099277375cd5e1b498f3331c3b0a 100644 --- a/paddle/gserver/layers/SamplingIdLayer.cpp +++ b/paddle/gserver/layers/SamplingIdLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/ScalingLayer.cpp b/paddle/gserver/layers/ScalingLayer.cpp index 71570810f9576df74940968426c09ae421881ba6..7f0084be6b57f5ce8245609e64c744c1a049a925 100644 --- a/paddle/gserver/layers/ScalingLayer.cpp +++ b/paddle/gserver/layers/ScalingLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Logging.h" #include "Layer.h" #include "paddle/math/Matrix.h" +#include "paddle/utils/Logging.h" #include "paddle/utils/Stat.h" namespace paddle { diff --git a/paddle/gserver/layers/ScalingProjection.cpp b/paddle/gserver/layers/ScalingProjection.cpp index 7999d02d384a06b900fbfa2c8bb271660b7fe008..ddb8c8711018ad9c92ef2f3bf26325aa5bffef89 100644 --- a/paddle/gserver/layers/ScalingProjection.cpp +++ b/paddle/gserver/layers/ScalingProjection.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/SelectiveFullyConnectedLayer.cpp b/paddle/gserver/layers/SelectiveFullyConnectedLayer.cpp index 4dfa2c179dafe0d8dcc6766fbafeae129edcc49a..9200a01eee3be8ab61b6181ec337b2c3c70c5966 100644 --- a/paddle/gserver/layers/SelectiveFullyConnectedLayer.cpp +++ b/paddle/gserver/layers/SelectiveFullyConnectedLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -13,11 +13,11 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "SelectiveFullyConnectedLayer.h" +#include +#include +#include "paddle/math/SparseMatrix.h" #include "paddle/utils/Logging.h" #include "paddle/utils/Stat.h" -#include "paddle/math/SparseMatrix.h" -#include -#include namespace paddle { diff --git a/paddle/gserver/layers/SelectiveFullyConnectedLayer.h b/paddle/gserver/layers/SelectiveFullyConnectedLayer.h index 9f92ae060521bd7852b67d45649d1cd0792961d4..bdf9a4652cc71710d1d33e8b085c5aec28f6f806 100644 --- a/paddle/gserver/layers/SelectiveFullyConnectedLayer.h +++ b/paddle/gserver/layers/SelectiveFullyConnectedLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/SequenceConcatLayer.cpp b/paddle/gserver/layers/SequenceConcatLayer.cpp index bd72ba3d167d99b5d3fdd047d6b1bfab611b3232..069bc26e602ff7d925b4115d12388b6716676b29 100644 --- a/paddle/gserver/layers/SequenceConcatLayer.cpp +++ b/paddle/gserver/layers/SequenceConcatLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Logging.h" #include "Layer.h" #include "paddle/math/Matrix.h" +#include "paddle/utils/Logging.h" #include "paddle/utils/Stat.h" namespace paddle { diff --git a/paddle/gserver/layers/SequenceLastInstanceLayer.cpp b/paddle/gserver/layers/SequenceLastInstanceLayer.cpp index 0e9531eabb4b389b762e235ec01d5f16c88cd4a1..4bfce766c769f4be2e5cc7bf691d539b1d307a47 100644 --- a/paddle/gserver/layers/SequenceLastInstanceLayer.cpp +++ b/paddle/gserver/layers/SequenceLastInstanceLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/SequencePoolLayer.cpp b/paddle/gserver/layers/SequencePoolLayer.cpp index c9f19b7d3b66b3ac031135c04a96ffe27245aa01..35260ca912d5d0e00213ffb7074bd8963da265da 100644 --- a/paddle/gserver/layers/SequencePoolLayer.cpp +++ b/paddle/gserver/layers/SequencePoolLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Logging.h" #include "SequencePoolLayer.h" +#include "paddle/utils/Logging.h" namespace paddle { diff --git a/paddle/gserver/layers/SequencePoolLayer.h b/paddle/gserver/layers/SequencePoolLayer.h index 669af80e1d447a9150b450f9fca4456c89ed2c36..aa9c132586e55d0f6bccec1689db60145ca2d43f 100644 --- a/paddle/gserver/layers/SequencePoolLayer.h +++ b/paddle/gserver/layers/SequencePoolLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/SequenceReshapeLayer.cpp b/paddle/gserver/layers/SequenceReshapeLayer.cpp index 5ca9b8b300161688817234909f2b875801d90995..23924b0490851ad3c3c74d77e7abd8b0af8fc234 100644 --- a/paddle/gserver/layers/SequenceReshapeLayer.cpp +++ b/paddle/gserver/layers/SequenceReshapeLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Logging.h" #include "Layer.h" #include "paddle/math/Matrix.h" +#include "paddle/utils/Logging.h" #include "paddle/utils/Stat.h" namespace paddle { diff --git a/paddle/gserver/layers/SequenceToBatch.cpp b/paddle/gserver/layers/SequenceToBatch.cpp index 04402db9c8af2f51f30a09cbf1e9c4023fe3e531..5fa7b6f4881b9582b540a5b1bfe849220cc2a4ea 100644 --- a/paddle/gserver/layers/SequenceToBatch.cpp +++ b/paddle/gserver/layers/SequenceToBatch.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,11 +12,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include -#include #include "SequenceToBatch.h" -#include #include +#include +#include +#include namespace paddle { diff --git a/paddle/gserver/layers/SequenceToBatch.h b/paddle/gserver/layers/SequenceToBatch.h index 6bc12f207ee3fadbd2a75ca5a5dbb7ce199cc99b..17e735a135cba8b43caf0ed9e06bb53903b5cd6a 100644 --- a/paddle/gserver/layers/SequenceToBatch.h +++ b/paddle/gserver/layers/SequenceToBatch.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -13,8 +13,8 @@ See the License for the specific language governing permissions and limitations under the License. */ #pragma once -#include "paddle/math/Vector.h" #include "paddle/math/Matrix.h" +#include "paddle/math/Vector.h" namespace paddle { diff --git a/paddle/gserver/layers/SlopeInterceptLayer.cpp b/paddle/gserver/layers/SlopeInterceptLayer.cpp index dd6ffcd50b01cfa56ee9fbc428ffc2cb9b73ce17..b678f414b6d76fa26818cb379fb0f0fb8fc7ec09 100644 --- a/paddle/gserver/layers/SlopeInterceptLayer.cpp +++ b/paddle/gserver/layers/SlopeInterceptLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Logging.h" #include "Layer.h" #include "paddle/math/Matrix.h" +#include "paddle/utils/Logging.h" #include "paddle/utils/Stat.h" namespace paddle { diff --git a/paddle/gserver/layers/SpatialPyramidPoolLayer.cpp b/paddle/gserver/layers/SpatialPyramidPoolLayer.cpp index dce660a5bca792e99a16e187aaa4aa10187830ac..14fe88ff8a5a1440ad1c98850e571f84813fec3e 100644 --- a/paddle/gserver/layers/SpatialPyramidPoolLayer.cpp +++ b/paddle/gserver/layers/SpatialPyramidPoolLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/SpatialPyramidPoolLayer.h b/paddle/gserver/layers/SpatialPyramidPoolLayer.h index 79db574d99bdb1137e6a55244c382f9c894239c8..32e88cf141a667d9dffbe7dcba46e9fde721f9e7 100644 --- a/paddle/gserver/layers/SpatialPyramidPoolLayer.h +++ b/paddle/gserver/layers/SpatialPyramidPoolLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/SubSequenceLayer.cpp b/paddle/gserver/layers/SubSequenceLayer.cpp index 664f9e13c055df08552974048428326644b69a6e..c52fbee26232ad6eb09f84315a57c73e6aa02eb0 100644 --- a/paddle/gserver/layers/SubSequenceLayer.cpp +++ b/paddle/gserver/layers/SubSequenceLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,10 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Logging.h" #include "Layer.h" #include "paddle/math/Matrix.h" #include "paddle/math/Vector.h" +#include "paddle/utils/Logging.h" #include "paddle/utils/Stat.h" namespace paddle { diff --git a/paddle/gserver/layers/SumToOneNormLayer.cpp b/paddle/gserver/layers/SumToOneNormLayer.cpp index bcf39168408d2bac50c17d0e22ed747cf0b33d80..aa99b49380d3682ccf3d89220c0c68f22e458271 100644 --- a/paddle/gserver/layers/SumToOneNormLayer.cpp +++ b/paddle/gserver/layers/SumToOneNormLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Logging.h" #include "Layer.h" #include "paddle/math/Matrix.h" +#include "paddle/utils/Logging.h" #include "paddle/utils/Stat.h" namespace paddle { diff --git a/paddle/gserver/layers/TableProjection.cpp b/paddle/gserver/layers/TableProjection.cpp index 2bc0d329d9605850ecdce6b4a87351579493d834..270acdd34baa2ba5d68718598cab5c3928cc1e9a 100644 --- a/paddle/gserver/layers/TableProjection.cpp +++ b/paddle/gserver/layers/TableProjection.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/TableProjection.h b/paddle/gserver/layers/TableProjection.h index 97c672508a009735a9a8f9980b715881c1f824a2..fb6c0e17c2da181aab23a1860fef993dd254955d 100644 --- a/paddle/gserver/layers/TableProjection.h +++ b/paddle/gserver/layers/TableProjection.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/TensorLayer.cpp b/paddle/gserver/layers/TensorLayer.cpp index 03586cc6ff3d148a63af33d89b85d565e2198057..642eb1bdd31c0c16f251dd7afda1ae0a61c0872e 100644 --- a/paddle/gserver/layers/TensorLayer.cpp +++ b/paddle/gserver/layers/TensorLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/TensorLayer.h b/paddle/gserver/layers/TensorLayer.h index 9ac651de4d99a23a12394c674bda827e935749b9..ac38ffb620570320497446a6825ca2273b73facc 100644 --- a/paddle/gserver/layers/TensorLayer.h +++ b/paddle/gserver/layers/TensorLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/TransLayer.cpp b/paddle/gserver/layers/TransLayer.cpp index 53a24d4cc4633898cff1b56f5a377959a38f6354..d1fa90f38415c53bd1c56df4a6c4be0508004bc6 100644 --- a/paddle/gserver/layers/TransLayer.cpp +++ b/paddle/gserver/layers/TransLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Logging.h" #include "TransLayer.h" +#include "paddle/utils/Logging.h" namespace paddle { REGISTER_LAYER(trans, TransLayer); diff --git a/paddle/gserver/layers/TransLayer.h b/paddle/gserver/layers/TransLayer.h index 25b091f9f414ead5048cd65cfc16b67ae1387ad9..b43fa1ebfb003226daed724b4ede3006545e8b07 100644 --- a/paddle/gserver/layers/TransLayer.h +++ b/paddle/gserver/layers/TransLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,9 +14,9 @@ limitations under the License. */ #pragma once +#include #include "Layer.h" #include "paddle/math/Matrix.h" -#include namespace paddle { /** diff --git a/paddle/gserver/layers/TransposedFullMatrixProjection.cpp b/paddle/gserver/layers/TransposedFullMatrixProjection.cpp index c883283f782352e674d0fcf0369e8491e31d60ff..3f7ff0488207564e3ebbd5a467f42b46af3b31ff 100644 --- a/paddle/gserver/layers/TransposedFullMatrixProjection.cpp +++ b/paddle/gserver/layers/TransposedFullMatrixProjection.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Stat.h" #include "Projection.h" +#include "paddle/utils/Stat.h" namespace paddle { diff --git a/paddle/gserver/layers/ValidationLayer.cpp b/paddle/gserver/layers/ValidationLayer.cpp index 0fee4bd2463ac86dfcb5ecc0b5e75564d86971d2..5127bcaba336b72dc76c832892e057724aeb3471 100644 --- a/paddle/gserver/layers/ValidationLayer.cpp +++ b/paddle/gserver/layers/ValidationLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,12 +12,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include #include #include +#include -#include "paddle/utils/Logging.h" #include "ValidationLayer.h" +#include "paddle/utils/Logging.h" namespace paddle { diff --git a/paddle/gserver/layers/ValidationLayer.h b/paddle/gserver/layers/ValidationLayer.h index eef9c80a7b11f5e2b6d1b028f4d2eff9102d6c28..471055429d34bee591cf7e66cd28221a8ebd83ed 100644 --- a/paddle/gserver/layers/ValidationLayer.h +++ b/paddle/gserver/layers/ValidationLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -15,8 +15,8 @@ limitations under the License. */ #pragma once #include -#include "paddle/gserver/evaluators/Evaluator.h" #include "Layer.h" +#include "paddle/gserver/evaluators/Evaluator.h" P_DECLARE_int32(trainer_id); diff --git a/paddle/gserver/layers/WarpCTCLayer.cpp b/paddle/gserver/layers/WarpCTCLayer.cpp index e68363a1b2bb389fa6591daed0f31f78ff4585b1..23ca5257b6d2c8c6e88ad4bb92de6dc3f18fafe3 100644 --- a/paddle/gserver/layers/WarpCTCLayer.cpp +++ b/paddle/gserver/layers/WarpCTCLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/layers/WarpCTCLayer.h b/paddle/gserver/layers/WarpCTCLayer.h index 1b0f5ba267ae593a0c967233967eac0deef04eb0..3d9ae9249af66dd085f5b6bb7a3c09d8b2276a24 100644 --- a/paddle/gserver/layers/WarpCTCLayer.h +++ b/paddle/gserver/layers/WarpCTCLayer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/tests/LayerGradUtil.cpp b/paddle/gserver/tests/LayerGradUtil.cpp index 47575169172832cd3f95a53ed6e4dcb87a5b7a4b..dffc24936faa2d855ae2eb762efbcc1c0f545943 100644 --- a/paddle/gserver/tests/LayerGradUtil.cpp +++ b/paddle/gserver/tests/LayerGradUtil.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/tests/LayerGradUtil.h b/paddle/gserver/tests/LayerGradUtil.h index a061c7fc533ff2c639ceda4db6d89a33fd3f0435..62ac2d160fd916c5bb114341a442eac7df114c99 100644 --- a/paddle/gserver/tests/LayerGradUtil.h +++ b/paddle/gserver/tests/LayerGradUtil.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -13,9 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #pragma once -#include "paddle/trainer/Trainer.h" -#include "paddle/gserver/layers/DataLayer.h" #include "ModelConfig.pb.h" +#include "paddle/gserver/layers/DataLayer.h" +#include "paddle/trainer/Trainer.h" #include "TestUtil.h" using namespace std; // NOLINT diff --git a/paddle/gserver/tests/TestUtil.cpp b/paddle/gserver/tests/TestUtil.cpp index 84d516683c18551765d707f26cc7003ba3432c7f..e656da5b8f7c0f9ebbc094c0e1548423ea060f50 100644 --- a/paddle/gserver/tests/TestUtil.cpp +++ b/paddle/gserver/tests/TestUtil.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,8 +14,8 @@ limitations under the License. */ #include "TestUtil.h" -#include "paddle/utils/CommandLineParser.h" #include "paddle/math/SparseMatrix.h" +#include "paddle/utils/CommandLineParser.h" P_DEFINE_int32(fixed_seq_length, 0, "Produce some sequence of fixed length"); @@ -63,8 +63,8 @@ MatrixPtr makeRandomSparseMatrix(size_t height, std::dynamic_pointer_cast(mat)->copyFrom( ids.data(), indices.data(), data.data(), HPPL_STREAM_DEFAULT); } else { - std::dynamic_pointer_cast(mat) - ->copyFrom(ids.data(), indices.data(), data.data()); + std::dynamic_pointer_cast(mat)->copyFrom( + ids.data(), indices.data(), data.data()); } return mat; } else { @@ -80,8 +80,8 @@ MatrixPtr makeRandomSparseMatrix(size_t height, std::dynamic_pointer_cast(mat)->copyFrom( ids.data(), indices.data(), data.data(), HPPL_STREAM_DEFAULT); } else { - std::dynamic_pointer_cast(mat) - ->copyFrom(ids.data(), indices.data(), data.data()); + std::dynamic_pointer_cast(mat)->copyFrom( + ids.data(), indices.data(), data.data()); } return mat; } diff --git a/paddle/gserver/tests/TestUtil.h b/paddle/gserver/tests/TestUtil.h index 000f8884e8681db8f4d2a2d6454791958b964f92..ec86469aebbafbf5406a21e6825eda6c105a6b9d 100644 --- a/paddle/gserver/tests/TestUtil.h +++ b/paddle/gserver/tests/TestUtil.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/tests/__init__.py b/paddle/gserver/tests/__init__.py index c90af2ee000d46a032984ee23559e7e99b49ddad..f662d6826321eb840739382558f76327d27b5847 100644 --- a/paddle/gserver/tests/__init__.py +++ b/paddle/gserver/tests/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/gserver/tests/concat_dotmul_a.conf b/paddle/gserver/tests/concat_dotmul_a.conf index 52340596b9b7d3a8a1872b1933f9913bf041ee78..db02ca7e80de63618a7abf7b3673840627cd8c93 100644 --- a/paddle/gserver/tests/concat_dotmul_a.conf +++ b/paddle/gserver/tests/concat_dotmul_a.conf @@ -1,5 +1,5 @@ #edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/gserver/tests/concat_dotmul_b.conf b/paddle/gserver/tests/concat_dotmul_b.conf index 68859867bf3b101a3682f2f841de53c0ade85792..5e64970e4440a4f1d8c9282faa486963b3515a9d 100644 --- a/paddle/gserver/tests/concat_dotmul_b.conf +++ b/paddle/gserver/tests/concat_dotmul_b.conf @@ -1,5 +1,5 @@ #edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/gserver/tests/concat_fullmatrix_a.conf b/paddle/gserver/tests/concat_fullmatrix_a.conf index 35bafc58ac3d7aef505ab1220ac2a2d840852f9d..940d1efc58fe9c21028c1b1e31c46648ab518cbe 100644 --- a/paddle/gserver/tests/concat_fullmatrix_a.conf +++ b/paddle/gserver/tests/concat_fullmatrix_a.conf @@ -1,5 +1,5 @@ #edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/gserver/tests/concat_fullmatrix_b.conf b/paddle/gserver/tests/concat_fullmatrix_b.conf index 00a957d97d591ffaa0e4ebdaaf7bc1c779f632fd..931e5b38efa019e1f0afbd59a00d4115a4aab67a 100644 --- a/paddle/gserver/tests/concat_fullmatrix_b.conf +++ b/paddle/gserver/tests/concat_fullmatrix_b.conf @@ -1,5 +1,5 @@ #edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/gserver/tests/concat_table_a.conf b/paddle/gserver/tests/concat_table_a.conf index a8ff70f883318676b5bd295c217105ca4b98edff..047cb44d156daa93ba50cc259144217990685055 100644 --- a/paddle/gserver/tests/concat_table_a.conf +++ b/paddle/gserver/tests/concat_table_a.conf @@ -1,5 +1,5 @@ #edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/gserver/tests/concat_table_b.conf b/paddle/gserver/tests/concat_table_b.conf index 95d7c10f7b0cd66e38f60c282e4f67ebf3b7cafb..c666ab994276721b66884e59fe89e816d086df8b 100644 --- a/paddle/gserver/tests/concat_table_b.conf +++ b/paddle/gserver/tests/concat_table_b.conf @@ -1,5 +1,5 @@ #edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/gserver/tests/img_conv_a.conf b/paddle/gserver/tests/img_conv_a.conf index 20c89b875e84e10144e99cd1546146bfad8b057f..3ad15c64fe5b793768f5a108f4ce60d15fd5da4a 100644 --- a/paddle/gserver/tests/img_conv_a.conf +++ b/paddle/gserver/tests/img_conv_a.conf @@ -1,5 +1,5 @@ #edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/gserver/tests/img_conv_b.conf b/paddle/gserver/tests/img_conv_b.conf index 19b99c77fdebc45d1a8b1e071987386574b1acb2..e68008155e97256e4bc865016a507c96995bd2eb 100644 --- a/paddle/gserver/tests/img_conv_b.conf +++ b/paddle/gserver/tests/img_conv_b.conf @@ -1,5 +1,5 @@ #edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/gserver/tests/img_conv_c.conf b/paddle/gserver/tests/img_conv_c.conf index fea332f6d1b2c9681c3b9d0bb3c15ea8b1895d24..4598ffbdb2f1452cacaf9715409263922828bcb0 100644 --- a/paddle/gserver/tests/img_conv_c.conf +++ b/paddle/gserver/tests/img_conv_c.conf @@ -1,5 +1,5 @@ #edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/gserver/tests/img_pool_a.conf b/paddle/gserver/tests/img_pool_a.conf index 9bd046b533de8200e6c945d1752ce240508b6338..afd271055d974734fc589a51401542b4bed99534 100644 --- a/paddle/gserver/tests/img_pool_a.conf +++ b/paddle/gserver/tests/img_pool_a.conf @@ -1,5 +1,5 @@ #edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/gserver/tests/img_pool_b.conf b/paddle/gserver/tests/img_pool_b.conf index 6ea9649b3f1eaf72686fcf8a157ef9d75c662e46..e8deb9edbe755c1bcf8ea0180125ff7c470b0e0a 100644 --- a/paddle/gserver/tests/img_pool_b.conf +++ b/paddle/gserver/tests/img_pool_b.conf @@ -1,5 +1,5 @@ #edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/gserver/tests/pyDataProvider.py b/paddle/gserver/tests/pyDataProvider.py index 91863b4175b1a58cb7d475732f293f32a3a6ed5a..7235a239439b7544805d1bd06dfb1a72c2e0e937 100644 --- a/paddle/gserver/tests/pyDataProvider.py +++ b/paddle/gserver/tests/pyDataProvider.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/gserver/tests/pyDataProvider/trainer.conf b/paddle/gserver/tests/pyDataProvider/trainer.conf index 7957814c010d259ac9d98766a273b38d591d1375..7d910df20d4077a6645c42e418816cfaeb28d7e5 100644 --- a/paddle/gserver/tests/pyDataProvider/trainer.conf +++ b/paddle/gserver/tests/pyDataProvider/trainer.conf @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/gserver/tests/rnn_data_provider.py b/paddle/gserver/tests/rnn_data_provider.py index 715ac08a42d05cec9c7f4b09a0447d44835d417d..3afd45c72f4dd071ddca569caac8716fe102299b 100644 --- a/paddle/gserver/tests/rnn_data_provider.py +++ b/paddle/gserver/tests/rnn_data_provider.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/gserver/tests/sequenceGen.py b/paddle/gserver/tests/sequenceGen.py index fab876fd30da0a80774d06028ae2321e12354d59..fd725727c04677b5ea8918f6721f0c007e80915d 100644 --- a/paddle/gserver/tests/sequenceGen.py +++ b/paddle/gserver/tests/sequenceGen.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -33,10 +33,10 @@ def process(settings, file_name): label, comment = line.strip().split('\t') label = int(''.join(label.split())) words = comment.split() - word_slot = [ + words = [ settings.word_dict[w] for w in words if w in settings.word_dict ] - yield word_slot, label + yield words, label ## for hierarchical sequence network @@ -52,20 +52,20 @@ def hook2(settings, dict_file, **kwargs): @provider(init_hook=hook2, should_shuffle=False) def process2(settings, file_name): with open(file_name) as fdata: - label_list = [] - word_slot_list = [] + labels = [] + sentences = [] for line in fdata: if (len(line)) > 1: label, comment = line.strip().split('\t') label = int(''.join(label.split())) words = comment.split() - word_slot = [ + words = [ settings.word_dict[w] for w in words if w in settings.word_dict ] - label_list.append(label) - word_slot_list.append(word_slot) + labels.append(label) + sentences.append(words) else: - yield word_slot_list, label_list - label_list = [] - word_slot_list = [] + yield sentences, labels + labels = [] + sentences = [] diff --git a/paddle/gserver/tests/sequence_layer_group.conf b/paddle/gserver/tests/sequence_layer_group.conf index 087aa96ccb5a7fc2b6d4f5ce81de4e820580570a..68d150d553588c864de56ce1e6f283cc42fbbf2f 100644 --- a/paddle/gserver/tests/sequence_layer_group.conf +++ b/paddle/gserver/tests/sequence_layer_group.conf @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/gserver/tests/sequence_nest_layer_group.conf b/paddle/gserver/tests/sequence_nest_layer_group.conf index 93a0f6da7905c0b00cf70296143ded2d4431e430..88cb42798baff79fa6a86ef11dabf1781575c0b4 100644 --- a/paddle/gserver/tests/sequence_nest_layer_group.conf +++ b/paddle/gserver/tests/sequence_nest_layer_group.conf @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/gserver/tests/sequence_nest_rnn.conf b/paddle/gserver/tests/sequence_nest_rnn.conf index 93b08eb2f8746d514e35b49e5261e4fa9fa681e6..2873a599669b4281a53cd71e8bb56f0d18c26b5a 100644 --- a/paddle/gserver/tests/sequence_nest_rnn.conf +++ b/paddle/gserver/tests/sequence_nest_rnn.conf @@ -1,5 +1,5 @@ #edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -55,9 +55,8 @@ def outer_step(x): input=x) last = last_seq(input=inner_rnn_output, name="outer_rnn_state") - # "return last" should also work. But currently RecurrentGradientMachine - # does not handle it, and will report error: In hierachical RNN, all out - # links should be from sequences now. + # "return last" won't work, because recurrent_group only support the input + # sequence type is same as return sequence type. return inner_rnn_output out = recurrent_group( diff --git a/paddle/gserver/tests/sequence_nest_rnn_multi_input.conf b/paddle/gserver/tests/sequence_nest_rnn_multi_input.conf index 0614958b4719ddb2098dc495c4a6c615f2628457..ad14a2c927c89c9b480af5ad565c37e8b2e54469 100644 --- a/paddle/gserver/tests/sequence_nest_rnn_multi_input.conf +++ b/paddle/gserver/tests/sequence_nest_rnn_multi_input.conf @@ -1,5 +1,5 @@ #edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/gserver/tests/sequence_nest_rnn_multi_unequalength_inputs.conf b/paddle/gserver/tests/sequence_nest_rnn_multi_unequalength_inputs.conf deleted file mode 100644 index d0b9450f4b9f9659fdd606503b6bc1ea45338c76..0000000000000000000000000000000000000000 --- a/paddle/gserver/tests/sequence_nest_rnn_multi_unequalength_inputs.conf +++ /dev/null @@ -1,106 +0,0 @@ -#edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from paddle.trainer_config_helpers import * - -######################## data source ################################ -define_py_data_sources2(train_list='gserver/tests/Sequence/dummy.list', - test_list=None, - module='rnn_data_provider', - obj='process_unequalength_subseq') - - -settings(batch_size=2, learning_rate=0.01) -######################## network configure ################################ -dict_dim = 10 -word_dim = 8 -hidden_dim = 8 -label_dim = 2 - -speaker1 = data_layer(name="word1", size=dict_dim) -speaker2 = data_layer(name="word2", size=dict_dim) - -emb1 = embedding_layer(input=speaker1, size=word_dim) -emb2 = embedding_layer(input=speaker2, size=word_dim) - -# This hierachical RNN is designed to be equivalent to the simple RNN in -# sequence_rnn_multi_unequalength_inputs.conf - -def outer_step(x1, x2): - outer_mem1 = memory(name = "outer_rnn_state1", size = hidden_dim) - outer_mem2 = memory(name = "outer_rnn_state2", size = hidden_dim) - def inner_step1(y): - inner_mem = memory(name = 'inner_rnn_state_' + y.name, - size = hidden_dim, - boot_layer = outer_mem1) - out = fc_layer(input = [y, inner_mem], - size = hidden_dim, - act = TanhActivation(), - bias_attr = True, - name = 'inner_rnn_state_' + y.name) - return out - - def inner_step2(y): - inner_mem = memory(name = 'inner_rnn_state_' + y.name, - size = hidden_dim, - boot_layer = outer_mem2) - out = fc_layer(input = [y, inner_mem], - size = hidden_dim, - act = TanhActivation(), - bias_attr = True, - name = 'inner_rnn_state_' + y.name) - return out - - encoder1 = recurrent_group( - step = inner_step1, - name = 'inner1', - input = x1) - - encoder2 = recurrent_group( - step = inner_step2, - name = 'inner2', - input = x2) - - sentence_last_state1 = last_seq(input = encoder1, name = 'outer_rnn_state1') - sentence_last_state2_ = last_seq(input = encoder2, name = 'outer_rnn_state2') - - encoder1_expand = expand_layer(input = sentence_last_state1, - expand_as = encoder2) - - return [encoder1_expand, encoder2] - - -encoder1_rep, encoder2_rep = recurrent_group( - name="outer", - step=outer_step, - input=[SubsequenceInput(emb1), SubsequenceInput(emb2)], - targetInlink=emb2) - -encoder1_last = last_seq(input = encoder1_rep) -encoder1_expandlast = expand_layer(input = encoder1_last, - expand_as = encoder2_rep) -context = mixed_layer(input = [identity_projection(encoder1_expandlast), - identity_projection(encoder2_rep)], - size = hidden_dim) - -rep = last_seq(input=context) -prob = fc_layer(size=label_dim, - input=rep, - act=SoftmaxActivation(), - bias_attr=True) - -outputs(classification_cost(input=prob, - label=data_layer(name="label", size=label_dim))) - diff --git a/paddle/gserver/tests/sequence_nest_rnn_multi_unequalength_inputs.py b/paddle/gserver/tests/sequence_nest_rnn_multi_unequalength_inputs.py new file mode 100644 index 0000000000000000000000000000000000000000..7303d088043d5096a3491d3b3b32b231bde09a0a --- /dev/null +++ b/paddle/gserver/tests/sequence_nest_rnn_multi_unequalength_inputs.py @@ -0,0 +1,98 @@ +# edit-mode: -*- python -*- +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from paddle.trainer_config_helpers import * + +######################## data source ################################ +define_py_data_sources2( + train_list='gserver/tests/Sequence/dummy.list', + test_list=None, + module='rnn_data_provider', + obj='process_unequalength_subseq') + +settings(batch_size=2, learning_rate=0.01) +######################## network configure ################################ +dict_dim = 10 +word_dim = 8 +hidden_dim = 8 +label_dim = 2 + +speaker1 = data_layer(name="word1", size=dict_dim) +speaker2 = data_layer(name="word2", size=dict_dim) + +emb1 = embedding_layer(input=speaker1, size=word_dim) +emb2 = embedding_layer(input=speaker2, size=word_dim) + + +# This hierarchical RNN is designed to be equivalent to the simple RNN in +# sequence_rnn_multi_unequalength_inputs.conf +def outer_step(x1, x2): + index = [0] + + def inner_step(ipt): + index[0] += 1 + i = index[0] + outer_mem = memory(name="outer_rnn_state_%d" % i, size=hidden_dim) + + def inner_step_impl(y): + inner_mem = memory( + name="inner_rnn_state_" + y.name, + size=hidden_dim, + boot_layer=outer_mem) + out = fc_layer( + input=[y, inner_mem], + size=hidden_dim, + act=TanhActivation(), + bias_attr=True, + name='inner_rnn_state_' + y.name) + return out + + encoder = recurrent_group( + step=inner_step_impl, name='inner_%d' % i, input=ipt) + last = last_seq(name="outer_rnn_state_%d" % i, input=encoder) + return encoder, last + + encoder1, sentence_last_state1 = inner_step(ipt=x1) + encoder2, sentence_last_state2 = inner_step(ipt=x2) + + encoder1_expand = expand_layer( + input=sentence_last_state1, expand_as=encoder2) + + return [encoder1_expand, encoder2] + + +encoder1_rep, encoder2_rep = recurrent_group( + name="outer", + step=outer_step, + input=[SubsequenceInput(emb1), SubsequenceInput(emb2)], + targetInlink=emb2) + +encoder1_last = last_seq(input=encoder1_rep) +encoder1_expandlast = expand_layer(input=encoder1_last, expand_as=encoder2_rep) +context = mixed_layer( + input=[ + identity_projection(encoder1_expandlast), + identity_projection(encoder2_rep) + ], + size=hidden_dim) + +rep = last_seq(input=context) +prob = fc_layer( + size=label_dim, input=rep, act=SoftmaxActivation(), bias_attr=True) + +outputs( + classification_cost( + input=prob, label=data_layer( + name="label", size=label_dim))) diff --git a/paddle/gserver/tests/sequence_rnn.conf b/paddle/gserver/tests/sequence_rnn.conf index 3294c2c3fc431c9d07aad0ba4620ec97a435fd91..1084edfe708c3348d40b67e270f64d8cda3cee0f 100644 --- a/paddle/gserver/tests/sequence_rnn.conf +++ b/paddle/gserver/tests/sequence_rnn.conf @@ -1,5 +1,5 @@ #edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/gserver/tests/sequence_rnn_multi_input.conf b/paddle/gserver/tests/sequence_rnn_multi_input.conf index 51881e21d971bbebeceeab1a7c4954e50e3a5e60..40d031741573251aa94d2a0f355470c53c51de7e 100644 --- a/paddle/gserver/tests/sequence_rnn_multi_input.conf +++ b/paddle/gserver/tests/sequence_rnn_multi_input.conf @@ -1,5 +1,5 @@ #edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/gserver/tests/sequence_rnn_multi_unequalength_inputs.conf b/paddle/gserver/tests/sequence_rnn_multi_unequalength_inputs.py similarity index 50% rename from paddle/gserver/tests/sequence_rnn_multi_unequalength_inputs.conf rename to paddle/gserver/tests/sequence_rnn_multi_unequalength_inputs.py index 28b1cb98cf132fb74b08d440be44d68c6cf3ffae..786a0c6d780e4e8deadb35e52901e42dae67a281 100644 --- a/paddle/gserver/tests/sequence_rnn_multi_unequalength_inputs.conf +++ b/paddle/gserver/tests/sequence_rnn_multi_unequalength_inputs.py @@ -1,5 +1,5 @@ #edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,11 +16,11 @@ from paddle.trainer_config_helpers import * ######################## data source ################################ -define_py_data_sources2(train_list='gserver/tests/Sequence/dummy.list', - test_list=None, - module='rnn_data_provider', - obj='process_unequalength_seq') - +define_py_data_sources2( + train_list='gserver/tests/Sequence/dummy.list', + test_list=None, + module='rnn_data_provider', + obj='process_unequalength_seq') settings(batch_size=2, learning_rate=0.01) ######################## network configure ################################ @@ -38,38 +38,40 @@ emb2 = embedding_layer(input=speaker2, size=word_dim) # This hierachical RNN is designed to be equivalent to the RNN in # sequence_nest_rnn_multi_unequalength_inputs.conf + def step(x1, x2): - def calrnn(y): - mem = memory(name = 'rnn_state_' + y.name, size = hidden_dim) - out = fc_layer(input = [y, mem], - size = hidden_dim, - act = TanhActivation(), - bias_attr = True, - name = 'rnn_state_' + y.name) - return out - - encoder1 = calrnn(x1) - encoder2 = calrnn(x2) - return [encoder1, encoder2] + def calrnn(y): + mem = memory(name='rnn_state_' + y.name, size=hidden_dim) + out = fc_layer( + input=[y, mem], + size=hidden_dim, + act=TanhActivation(), + bias_attr=True, + name='rnn_state_' + y.name) + return out + + encoder1 = calrnn(x1) + encoder2 = calrnn(x2) + return [encoder1, encoder2] + encoder1_rep, encoder2_rep = recurrent_group( - name="stepout", - step=step, - input=[emb1, emb2]) + name="stepout", step=step, input=[emb1, emb2]) -encoder1_last = last_seq(input = encoder1_rep) -encoder1_expandlast = expand_layer(input = encoder1_last, - expand_as = encoder2_rep) -context = mixed_layer(input = [identity_projection(encoder1_expandlast), - identity_projection(encoder2_rep)], - size = hidden_dim) +encoder1_last = last_seq(input=encoder1_rep) +encoder1_expandlast = expand_layer(input=encoder1_last, expand_as=encoder2_rep) +context = mixed_layer( + input=[ + identity_projection(encoder1_expandlast), + identity_projection(encoder2_rep) + ], + size=hidden_dim) rep = last_seq(input=context) -prob = fc_layer(size=label_dim, - input=rep, - act=SoftmaxActivation(), - bias_attr=True) - -outputs(classification_cost(input=prob, - label=data_layer(name="label", size=label_dim))) +prob = fc_layer( + size=label_dim, input=rep, act=SoftmaxActivation(), bias_attr=True) +outputs( + classification_cost( + input=prob, label=data_layer( + name="label", size=label_dim))) diff --git a/paddle/gserver/tests/test_ActivationGrad.cpp b/paddle/gserver/tests/test_ActivationGrad.cpp index e54c5109e71de1a41ec2bda2af4a19745acbbc83..20a6126d0b69f71eecc439854c8f97f94ec53de5 100644 --- a/paddle/gserver/tests/test_ActivationGrad.cpp +++ b/paddle/gserver/tests/test_ActivationGrad.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -13,14 +13,14 @@ See the License for the specific language governing permissions and limitations under the License. */ #include -#include #include -#include "paddle/gserver/layers/DataLayer.h" +#include #include "ModelConfig.pb.h" +#include "paddle/gserver/layers/DataLayer.h" #include "paddle/trainer/Trainer.h" -#include "TestUtil.h" #include "LayerGradUtil.h" +#include "TestUtil.h" using namespace paddle; // NOLINT using namespace std; // NOLINT diff --git a/paddle/gserver/tests/test_BatchNorm.cpp b/paddle/gserver/tests/test_BatchNorm.cpp index 0cb6f58dc000bd0fb408e6f3a3aa4ff4240adf26..3bd4e321b7d073055ea8e9d97020379276de8cdf 100644 --- a/paddle/gserver/tests/test_BatchNorm.cpp +++ b/paddle/gserver/tests/test_BatchNorm.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -13,16 +13,16 @@ See the License for the specific language governing permissions and limitations under the License. */ #include -#include #include -#include "paddle/gserver/layers/DataLayer.h" +#include #include "ModelConfig.pb.h" +#include "paddle/gserver/layers/DataLayer.h" +#include "paddle/gserver/layers/ExpandConvTransLayer.h" #include "paddle/trainer/Trainer.h" #include "paddle/utils/GlobalConstants.h" -#include "paddle/gserver/layers/ExpandConvTransLayer.h" -#include "TestUtil.h" #include "LayerGradUtil.h" +#include "TestUtil.h" using namespace paddle; // NOLINT using namespace std; // NOLINT @@ -35,80 +35,87 @@ P_DECLARE_bool(prev_batch_state); // Test that the batchNormLayer can be followed by a ConvLayer TEST(Layer, batchNorm) { - FLAGS_use_gpu = false; - TestConfig configBN; - const int CHANNELS = 6272; - const int IMG_SIZE = 1; - configBN.layerConfig.set_type("batch_norm"); - configBN.layerConfig.set_name("bn"); - configBN.layerConfig.set_size(CHANNELS * IMG_SIZE * IMG_SIZE); - configBN.layerConfig.set_active_type("relu"); - configBN.biasSize = CHANNELS; - configBN.inputDefs.push_back({INPUT_DATA, "layer_0", + FLAGS_use_gpu = false; + TestConfig configBN; + const int CHANNELS = 6272; + const int IMG_SIZE = 1; + configBN.layerConfig.set_type("batch_norm"); + configBN.layerConfig.set_name("bn"); + configBN.layerConfig.set_size(CHANNELS * IMG_SIZE * IMG_SIZE); + configBN.layerConfig.set_active_type("relu"); + configBN.biasSize = CHANNELS; + configBN.inputDefs.push_back({INPUT_DATA, + "layer_0", /* dim= */ IMG_SIZE * IMG_SIZE * CHANNELS, /* paraSize= */ CHANNELS}); - configBN.inputDefs.push_back({INPUT_DATA, "layer_1_running_mean", - 1, CHANNELS}); - configBN.inputDefs.back().isStatic = true; - configBN.inputDefs.push_back({INPUT_DATA, "layer_2_running_var", - 1, CHANNELS}); - configBN.inputDefs.back().isStatic = true; - - LayerInputConfig* input = configBN.layerConfig.add_inputs(); - configBN.layerConfig.add_inputs(); - configBN.layerConfig.add_inputs(); - - ImageConfig* img_conf = input->mutable_image_conf(); - img_conf->set_channels(CHANNELS); - img_conf->set_img_size(IMG_SIZE); - - // Setting up conv-layer config - TestConfig config; - config.biasSize = 64; - config.layerConfig.set_type("exconv"); - config.layerConfig.set_num_filters(64); - config.layerConfig.set_partial_sum(1); - config.layerConfig.set_shared_biases(true); - - config.inputDefs.push_back({INPUT_DATA, "bn", 6272, 204800}); - input = config.layerConfig.add_inputs(); - ConvConfig* conv = input->mutable_conv_conf(); - conv->set_filter_size(5); - conv->set_filter_size_y(5); - conv->set_channels(128); - conv->set_padding(1); - conv->set_padding_y(1); - conv->set_stride(2); - conv->set_stride_y(2); - conv->set_groups(1); - conv->set_filter_channels(conv->channels() / conv->groups()); - conv->set_img_size(7); - conv->set_output_x(3); - config.layerConfig.set_size(conv->output_x() * conv->output_x() * - config.layerConfig.num_filters()); - config.layerConfig.set_name("conv"); - - // data layer initialize - std::vector dataLayers; - LayerMap layerMap; - vector datas; - initDataLayer(configBN, &dataLayers, &datas, &layerMap, "batch_norm", - 100, false, false); - // test layer initialize - std::vector parameters; - LayerPtr bnLayer; - initTestLayer(configBN, &layerMap, ¶meters, &bnLayer); - - std::vector parameters2; - LayerPtr convLayer; - initTestLayer(config, &layerMap, ¶meters2, &convLayer); - - bnLayer->forward(PASS_GC); - convLayer->forward(PASS_GC); - - CHECK_EQ(convLayer->getOutputValue()->getHeight(), 100); - CHECK_EQ(convLayer->getOutputValue()->getWidth(), 576); + configBN.inputDefs.push_back( + {INPUT_DATA, "layer_1_running_mean", 1, CHANNELS}); + configBN.inputDefs.back().isStatic = true; + configBN.inputDefs.push_back( + {INPUT_DATA, "layer_2_running_var", 1, CHANNELS}); + configBN.inputDefs.back().isStatic = true; + + LayerInputConfig* input = configBN.layerConfig.add_inputs(); + configBN.layerConfig.add_inputs(); + configBN.layerConfig.add_inputs(); + + ImageConfig* img_conf = input->mutable_image_conf(); + img_conf->set_channels(CHANNELS); + img_conf->set_img_size(IMG_SIZE); + + // Setting up conv-layer config + TestConfig config; + config.biasSize = 64; + config.layerConfig.set_type("exconv"); + config.layerConfig.set_num_filters(64); + config.layerConfig.set_partial_sum(1); + config.layerConfig.set_shared_biases(true); + + config.inputDefs.push_back({INPUT_DATA, "bn", 6272, 204800}); + input = config.layerConfig.add_inputs(); + ConvConfig* conv = input->mutable_conv_conf(); + conv->set_filter_size(5); + conv->set_filter_size_y(5); + conv->set_channels(128); + conv->set_padding(1); + conv->set_padding_y(1); + conv->set_stride(2); + conv->set_stride_y(2); + conv->set_groups(1); + conv->set_filter_channels(conv->channels() / conv->groups()); + conv->set_img_size(7); + conv->set_output_x(3); + config.layerConfig.set_size(conv->output_x() * conv->output_x() * + config.layerConfig.num_filters()); + config.layerConfig.set_name("conv"); + + // data layer initialize + std::vector dataLayers; + LayerMap layerMap; + vector datas; + initDataLayer(configBN, + &dataLayers, + &datas, + &layerMap, + "batch_norm", + 100, + false, + false); + // test layer initialize + std::vector parameters; + LayerPtr bnLayer; + initTestLayer(configBN, &layerMap, ¶meters, &bnLayer); + + std::vector parameters2; + LayerPtr convLayer; + initTestLayer(config, &layerMap, ¶meters2, &convLayer); + + bnLayer->forward(PASS_GC); + convLayer->forward(PASS_GC); + + CHECK_EQ(convLayer->getOutputValue()->getHeight(), 100); + CHECK_EQ(convLayer->getOutputValue()->getWidth(), 576); } int main(int argc, char** argv) { diff --git a/paddle/gserver/tests/test_ConvTrans.cpp b/paddle/gserver/tests/test_ConvTrans.cpp index f3efdfb428d14435fbfced6cfef3b7dadd8ff5a9..83100e3bec7e61c7d7751754ace760729e9adb27 100644 --- a/paddle/gserver/tests/test_ConvTrans.cpp +++ b/paddle/gserver/tests/test_ConvTrans.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -13,17 +13,17 @@ See the License for the specific language governing permissions and limitations under the License. */ #include -#include #include -#include "paddle/gserver/layers/DataLayer.h" +#include #include "ModelConfig.pb.h" -#include "paddle/trainer/Trainer.h" -#include "paddle/utils/GlobalConstants.h" +#include "paddle/gserver/layers/DataLayer.h" #include "paddle/gserver/layers/ExpandConvTransLayer.h" #include "paddle/math/MathUtils.h" +#include "paddle/trainer/Trainer.h" +#include "paddle/utils/GlobalConstants.h" -#include "TestUtil.h" #include "LayerGradUtil.h" +#include "TestUtil.h" using namespace paddle; // NOLINT using namespace std; // NOLINT diff --git a/paddle/gserver/tests/test_ConvUnify.cpp b/paddle/gserver/tests/test_ConvUnify.cpp index 5acf02bea0e407c38cb68bcd0ae325f6af78f788..02763406a34da16da52fa0247c6c469c2418a914 100644 --- a/paddle/gserver/tests/test_ConvUnify.cpp +++ b/paddle/gserver/tests/test_ConvUnify.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -13,17 +13,17 @@ See the License for the specific language governing permissions and limitations under the License. */ #include -#include #include -#include "paddle/gserver/layers/DataLayer.h" +#include #include "ModelConfig.pb.h" -#include "paddle/trainer/Trainer.h" -#include "paddle/utils/GlobalConstants.h" +#include "paddle/gserver/layers/DataLayer.h" #include "paddle/gserver/layers/ExpandConvTransLayer.h" #include "paddle/math/MathUtils.h" +#include "paddle/trainer/Trainer.h" +#include "paddle/utils/GlobalConstants.h" -#include "TestUtil.h" #include "LayerGradUtil.h" +#include "TestUtil.h" using namespace paddle; // NOLINT using namespace std; // NOLINT @@ -36,10 +36,17 @@ P_DECLARE_bool(prev_batch_state); // Do one forward pass of convTrans layer and check to see if its output // matches the given result -MatrixPtr doOneConvTest(size_t imgSize, size_t output_x, size_t stride, - size_t padding, size_t filter_size, size_t channel, - size_t numfilters, size_t groups, MatrixPtr& inputData, - real* param, bool useGpu) { +MatrixPtr doOneConvTest(size_t imgSize, + size_t output_x, + size_t stride, + size_t padding, + size_t filter_size, + size_t channel, + size_t numfilters, + size_t groups, + MatrixPtr& inputData, + real* param, + bool useGpu) { TestConfig config; config.biasSize = numfilters; if (useGpu) { @@ -51,11 +58,10 @@ MatrixPtr doOneConvTest(size_t imgSize, size_t output_x, size_t stride, config.layerConfig.set_partial_sum(1); config.layerConfig.set_shared_biases(true); - size_t weightSize = channel* filter_size * filter_size * - config.layerConfig.num_filters() / groups; - config.inputDefs.push_back({INPUT_DATA, "layer_0", - imgSize * imgSize * channel, - weightSize}); + size_t weightSize = channel * filter_size * filter_size * + config.layerConfig.num_filters() / groups; + config.inputDefs.push_back( + {INPUT_DATA, "layer_0", imgSize * imgSize * channel, weightSize}); LayerInputConfig* input = config.layerConfig.add_inputs(); ConvConfig* conv = input->mutable_conv_conf(); conv->set_filter_size(filter_size); @@ -66,7 +72,7 @@ MatrixPtr doOneConvTest(size_t imgSize, size_t output_x, size_t stride, conv->set_stride(stride); conv->set_stride_y(stride); conv->set_groups(groups); - conv->set_filter_channels(channel/groups); + conv->set_filter_channels(channel / groups); conv->set_img_size(imgSize); conv->set_output_x(output_x); @@ -77,8 +83,8 @@ MatrixPtr doOneConvTest(size_t imgSize, size_t output_x, size_t stride, std::vector dataLayers; LayerMap layerMap; vector datas; - initDataLayer(config, &dataLayers, &datas, &layerMap, "conv", - 1, false, useGpu); + initDataLayer( + config, &dataLayers, &datas, &layerMap, "conv", 1, false, useGpu); dataLayers[0]->getOutputValue()->zeroMem(); dataLayers[0]->getOutputValue()->copyFrom(*inputData); @@ -88,106 +94,124 @@ MatrixPtr doOneConvTest(size_t imgSize, size_t output_x, size_t stride, initTestLayer(config, &layerMap, ¶meters, &convLayer); convLayer->getBiasParameter()->zeroMem(); convLayer->getParameters()[0]->zeroMem(); - convLayer->getParameters()[0]->getBuf(PARAMETER_VALUE)->copyFrom(param, - weightSize); + convLayer->getParameters()[0] + ->getBuf(PARAMETER_VALUE) + ->copyFrom(param, weightSize); convLayer->forward(PASS_GC); return convLayer->getOutputValue(); } TEST(Layer, convParaUnified) { - #ifndef PADDLE_ONLY_CPU - MatrixPtr input, resultCpu, resultGpu; - input = Matrix::create(1, 4 * 4, false, false); - float inputData[] = {1, 2, 3, 4, - 5, 6, 7, 8, - 9, 10, 11, 12, - 13, 14, 15, 16}; - float param[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, - 9, 8, 7, 6, 5, 4, 3, 2, 1}; - - input->setData(inputData); - - resultCpu = doOneConvTest(/* imgSize */ 4, - /* output_x */ 2, - /* stride */ 1, - /* padding */ 0, - /* filter_size */ 3, - /*channel*/ 1, - /*numfilters*/ 2, - /*groups*/ 1, - input, param, false); - - resultGpu = doOneConvTest(/* imgSize */ 4, - /* output_x */ 2, - /* stride */ 1, - /* padding */ 0, - /* filter_size */ 3, - /*channel*/ 1, - /*numfilters*/ 2, - /*groups*/ 1, - input, param, true); - checkMatrixEqual(resultCpu, resultGpu); - - input = Matrix::create(1, 3 * 3 * 2, false, false); - float inputData2[] = {1, 2, 3, - 4, 5, 6, - 7, 8, 9, - - 10, 11, 12, - 13, 14, 15, - 16, 17, 18}; - float param2[] = {1, 2, 3, 4, 5, 6, 7, 8, - 8, 7, 6, 5, 4, 3, 2, 1}; - - input->setData(inputData2); - - resultCpu = doOneConvTest(/* imgSize */ 3, - /* output_x */ 2, - /* stride */ 1, - /* padding */ 0, - /* filter_size */ 2, - /*channel*/ 2, - /*numfilters*/ 2, - /*groups*/ 1, - input, param2, false); - - resultGpu = doOneConvTest(/* imgSize */ 3, - /* output_x */ 2, - /* stride */ 1, - /* padding */ 0, - /* filter_size */ 2, - /*channel*/ 2, - /*numfilters*/ 2, - /*groups*/ 1, - input, param2, true); - checkMatrixEqual(resultCpu, resultGpu); - - - float param3[] = {1, 2, 3, 4, - 4, 3, 2, 1}; - - resultCpu = doOneConvTest(/* imgSize */ 3, - /* output_x */ 2, - /* stride */ 1, - /* padding */ 0, - /* filter_size */ 2, - /*channel*/ 2, - /*numfilters*/ 2, - /*groups*/ 2, - input, param3, false); - - resultGpu = doOneConvTest(/* imgSize */ 3, - /* output_x */ 2, - /* stride */ 1, - /* padding */ 0, - /* filter_size */ 2, - /*channel*/ 2, - /*numfilters*/ 2, - /*groups*/ 2, - input, param3, true); - checkMatrixEqual(resultCpu, resultGpu); - #endif +#ifndef PADDLE_ONLY_CPU + MatrixPtr input, resultCpu, resultGpu; + input = Matrix::create(1, 4 * 4, false, false); + float inputData[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; + float param[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 8, 7, 6, 5, 4, 3, 2, 1}; + + input->setData(inputData); + + resultCpu = doOneConvTest(/* imgSize */ 4, + /* output_x */ 2, + /* stride */ 1, + /* padding */ 0, + /* filter_size */ 3, + /*channel*/ 1, + /*numfilters*/ 2, + /*groups*/ 1, + input, + param, + false); + + resultGpu = doOneConvTest(/* imgSize */ 4, + /* output_x */ 2, + /* stride */ 1, + /* padding */ 0, + /* filter_size */ 3, + /*channel*/ 1, + /*numfilters*/ 2, + /*groups*/ 1, + input, + param, + true); + checkMatrixEqual(resultCpu, resultGpu); + + input = Matrix::create(1, 3 * 3 * 2, false, false); + float inputData2[] = {1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18}; + float param2[] = {1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1}; + + input->setData(inputData2); + + resultCpu = doOneConvTest(/* imgSize */ 3, + /* output_x */ 2, + /* stride */ 1, + /* padding */ 0, + /* filter_size */ 2, + /*channel*/ 2, + /*numfilters*/ 2, + /*groups*/ 1, + input, + param2, + false); + + resultGpu = doOneConvTest(/* imgSize */ 3, + /* output_x */ 2, + /* stride */ 1, + /* padding */ 0, + /* filter_size */ 2, + /*channel*/ 2, + /*numfilters*/ 2, + /*groups*/ 1, + input, + param2, + true); + checkMatrixEqual(resultCpu, resultGpu); + + float param3[] = {1, 2, 3, 4, 4, 3, 2, 1}; + + resultCpu = doOneConvTest(/* imgSize */ 3, + /* output_x */ 2, + /* stride */ 1, + /* padding */ 0, + /* filter_size */ 2, + /*channel*/ 2, + /*numfilters*/ 2, + /*groups*/ 2, + input, + param3, + false); + + resultGpu = doOneConvTest(/* imgSize */ 3, + /* output_x */ 2, + /* stride */ 1, + /* padding */ 0, + /* filter_size */ 2, + /*channel*/ 2, + /*numfilters*/ 2, + /*groups*/ 2, + input, + param3, + true); + checkMatrixEqual(resultCpu, resultGpu); +#endif } int main(int argc, char** argv) { diff --git a/paddle/gserver/tests/test_Evaluator.cpp b/paddle/gserver/tests/test_Evaluator.cpp index be639ea09380d02ed8251874bf690fc3596bddf2..7a930aebcf4ae7ab163c497d4d9545fdcf4f8eb5 100644 --- a/paddle/gserver/tests/test_Evaluator.cpp +++ b/paddle/gserver/tests/test_Evaluator.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -15,8 +15,8 @@ limitations under the License. */ #include #include #include "ModelConfig.pb.h" -#include "paddle/trainer/Trainer.h" #include "TestUtil.h" +#include "paddle/trainer/Trainer.h" using namespace paddle; // NOLINT using namespace std; // NOLINT diff --git a/paddle/gserver/tests/test_LayerGrad.cpp b/paddle/gserver/tests/test_LayerGrad.cpp index 099e96aa6c7439adc76248fcbb88cf24e7496ed4..9f8b197df554a67ebcdd3cff2c5d7d91bfc1932d 100644 --- a/paddle/gserver/tests/test_LayerGrad.cpp +++ b/paddle/gserver/tests/test_LayerGrad.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -17,8 +17,8 @@ limitations under the License. */ #include #include "ModelConfig.pb.h" #include "paddle/gserver/layers/DataLayer.h" -#include "paddle/trainer/Trainer.h" #include "paddle/math/MathUtils.h" +#include "paddle/trainer/Trainer.h" #include "LayerGradUtil.h" #include "TestUtil.h" diff --git a/paddle/gserver/tests/test_LinearChainCRF.cpp b/paddle/gserver/tests/test_LinearChainCRF.cpp index 913d6ed7511a0c3c7c0b40e1fbdb48a17b51b1b2..330adee8f77f495dab6a13190aaca6a3a5f86b2c 100644 --- a/paddle/gserver/tests/test_LinearChainCRF.cpp +++ b/paddle/gserver/tests/test_LinearChainCRF.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/tests/test_MultinomialSampler.cpp b/paddle/gserver/tests/test_MultinomialSampler.cpp index 3fc099adbdb6cb562c4bfc419b777ef534bdfed7..eadf40ade091ae8b3e19d7dc6c999288e8e88c1b 100644 --- a/paddle/gserver/tests/test_MultinomialSampler.cpp +++ b/paddle/gserver/tests/test_MultinomialSampler.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -20,8 +20,8 @@ limitations under the License. */ #undef PADDLE_DISABLE_TIMER #include "paddle/utils/Stat.h" -#include "paddle/utils/Util.h" #include "paddle/gserver/layers/MultinomialSampler.h" +#include "paddle/utils/Util.h" using namespace paddle; // NOLINT using namespace std; // NOLINT diff --git a/paddle/gserver/tests/test_NetworkCompare.cpp b/paddle/gserver/tests/test_NetworkCompare.cpp index 71ed3bc4b6fb44a74868da2f95597c1967206bd4..baa55aa0252cb63db7c4aa92cf9b6933199273fa 100644 --- a/paddle/gserver/tests/test_NetworkCompare.cpp +++ b/paddle/gserver/tests/test_NetworkCompare.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -13,14 +13,14 @@ See the License for the specific language governing permissions and limitations under the License. */ #undef PADDLE_DISABLE_TIMER +#include #include -#include #include -#include +#include +#include "TestUtil.h" #include "paddle/trainer/Trainer.h" #include "paddle/utils/Stat.h" -#include "TestUtil.h" using namespace paddle; // NOLINT using namespace std; // NOLINT diff --git a/paddle/gserver/tests/test_ProtoDataProvider.cpp b/paddle/gserver/tests/test_ProtoDataProvider.cpp index 01070bc1cb3023bc0321f0a8e867b8abd7030e08..d421b6e2f2536e266883508ff29cbec731c9d7e3 100644 --- a/paddle/gserver/tests/test_ProtoDataProvider.cpp +++ b/paddle/gserver/tests/test_ProtoDataProvider.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -17,8 +17,8 @@ limitations under the License. */ #include -#include "paddle/utils/Util.h" #include "paddle/gserver/dataproviders/ProtoDataProvider.h" +#include "paddle/utils/Util.h" #include "TestUtil.h" diff --git a/paddle/gserver/tests/test_PyDataProvider.cpp b/paddle/gserver/tests/test_PyDataProvider.cpp index 802f9aa4cb558f48fe55d7d7d5c882d25925bb32..0f264ecf91837f6681f0577b93be7e35be268c04 100644 --- a/paddle/gserver/tests/test_PyDataProvider.cpp +++ b/paddle/gserver/tests/test_PyDataProvider.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/tests/test_PyDataProvider2.cpp b/paddle/gserver/tests/test_PyDataProvider2.cpp index 6674e6b87c6acdda78416eb1f8bf015e642b967f..436318d35634f4ba46781a125ace110551029439 100644 --- a/paddle/gserver/tests/test_PyDataProvider2.cpp +++ b/paddle/gserver/tests/test_PyDataProvider2.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/gserver/tests/test_PyDataProvider2.py b/paddle/gserver/tests/test_PyDataProvider2.py index bf23c52fd78455c8ca7e480aa87438ee04ab2a74..f7b540013e76f03878a88ebd593a9af6f0ef16c8 100644 --- a/paddle/gserver/tests/test_PyDataProvider2.py +++ b/paddle/gserver/tests/test_PyDataProvider2.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/gserver/tests/test_RecurrentGradientMachine.cpp b/paddle/gserver/tests/test_RecurrentGradientMachine.cpp index 80d713dac03a42b370d50ebb17d089e9be2f17ff..a351667d8b18b734022820a777c551bb11a243bf 100644 --- a/paddle/gserver/tests/test_RecurrentGradientMachine.cpp +++ b/paddle/gserver/tests/test_RecurrentGradientMachine.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -13,12 +13,12 @@ See the License for the specific language governing permissions and limitations under the License. */ #include -#include -#include -#include +#include #include #include -#include +#include +#include +#include P_DECLARE_int32(seed); @@ -45,10 +45,9 @@ public: auto p = const_cast(this); auto& params = p->getGradientMachine()->getParameters(); return std::accumulate( - params.begin(), - params.end(), - 0UL, - [](size_t a, const ParameterPtr& p) { return a + p->getSize(); }); + params.begin(), params.end(), 0UL, [](size_t a, const ParameterPtr& p) { + return a + p->getSize(); + }); } }; @@ -148,8 +147,8 @@ TEST(RecurrentGradientMachine, rnn_multi_input) { TEST(RecurrentGradientMachine, rnn_multi_unequalength_input) { for (bool useGpu : {false, true}) { - test("gserver/tests/sequence_rnn_multi_unequalength_inputs.conf", - "gserver/tests/sequence_nest_rnn_multi_unequalength_inputs.conf", + test("gserver/tests/sequence_rnn_multi_unequalength_inputs.py", + "gserver/tests/sequence_nest_rnn_multi_unequalength_inputs.py", 1e-6, useGpu); } diff --git a/paddle/gserver/tests/test_RecurrentLayer.cpp b/paddle/gserver/tests/test_RecurrentLayer.cpp index 0643cec38b3a5d96de64438c7342f827fde808a9..cd96ca7c848afd7a2aa38df3343bee102aa5e83a 100644 --- a/paddle/gserver/tests/test_RecurrentLayer.cpp +++ b/paddle/gserver/tests/test_RecurrentLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -13,11 +13,11 @@ See the License for the specific language governing permissions and limitations under the License. */ #include -#include #include +#include +#include "ModelConfig.pb.h" #include "paddle/gserver/layers/DataLayer.h" #include "paddle/gserver/layers/Layer.h" -#include "ModelConfig.pb.h" #include "TestUtil.h" @@ -220,8 +220,8 @@ TEST(Layer, RecurrentLayer) { } #define protected public -#include "paddle/gserver/layers/LstmLayer.h" #include "paddle/gserver/layers/GatedRecurrentLayer.h" +#include "paddle/gserver/layers/LstmLayer.h" template class TestRecurrentLayer { public: diff --git a/paddle/gserver/tests/test_SelectiveFCLayer.cpp b/paddle/gserver/tests/test_SelectiveFCLayer.cpp index 204b03332ff5bba3b9f3e5d98050942d6f0f390f..4f3a95a535b0a47df88ac5ba7a367d25e57e5f74 100644 --- a/paddle/gserver/tests/test_SelectiveFCLayer.cpp +++ b/paddle/gserver/tests/test_SelectiveFCLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,17 +12,17 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include +#include #include +#include #include #include -#include -#include -#include +#include "ModelConfig.pb.h" #include "paddle/gserver/layers/DataLayer.h" -#include "paddle/gserver/layers/Layer.h" #include "paddle/gserver/layers/FullyConnectedLayer.h" +#include "paddle/gserver/layers/Layer.h" #include "paddle/gserver/layers/SelectiveFullyConnectedLayer.h" -#include "ModelConfig.pb.h" #include "paddle/math/CpuSparseMatrix.h" #include "paddle/trainer/Trainer.h" diff --git a/paddle/gserver/tests/test_WarpCTCLayer.cpp b/paddle/gserver/tests/test_WarpCTCLayer.cpp index 2dd83db345132501a8947644a1319a4f197d754e..700425412cebe8416f900fa702503db98722c0ee 100644 --- a/paddle/gserver/tests/test_WarpCTCLayer.cpp +++ b/paddle/gserver/tests/test_WarpCTCLayer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,11 +14,11 @@ limitations under the License. */ #include #include -#include "paddle/gserver/layers/Layer.h" -#include "paddle/gserver/layers/DataLayer.h" +#include "ModelConfig.pb.h" #include "paddle/gserver/layers/CTCLayer.h" +#include "paddle/gserver/layers/DataLayer.h" +#include "paddle/gserver/layers/Layer.h" #include "paddle/gserver/layers/WarpCTCLayer.h" -#include "ModelConfig.pb.h" #include "TestUtil.h" diff --git a/paddle/math/Allocator.h b/paddle/math/Allocator.h index cba8b37289b53b7d75c64a6a95c9e3900b193902..666a8b8368e3e2ebc522902c176d7491d2920d2a 100644 --- a/paddle/math/Allocator.h +++ b/paddle/math/Allocator.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,8 +14,8 @@ limitations under the License. */ #pragma once -#include #include +#include #include "hl_gpu.h" #include "paddle/utils/Logging.h" diff --git a/paddle/math/BaseMatrix.cu b/paddle/math/BaseMatrix.cu index 05faeff2e41225fd2a6bb3f1b6491c812a440655..0a0d92d1ae65f5b6020eb71fe2a6db5a3c625d9c 100644 --- a/paddle/math/BaseMatrix.cu +++ b/paddle/math/BaseMatrix.cu @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/math/BaseMatrix.h b/paddle/math/BaseMatrix.h index f4576985b8a9d46a25ee3e4ad96fa152a40875d3..2933c20fbad930248c41969d88d45cf397b9dcf8 100644 --- a/paddle/math/BaseMatrix.h +++ b/paddle/math/BaseMatrix.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -13,10 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #pragma once -#include #include -#include "paddle/utils/TypeDefs.h" +#include #include "TensorExpression.h" +#include "paddle/utils/TypeDefs.h" namespace paddle { diff --git a/paddle/math/CpuSparseMatrix.cpp b/paddle/math/CpuSparseMatrix.cpp index ad3f8e64efd37c27c7f462dd7c8311577a05a391..b5d5b6ef615829fc1e24ccd417e2f0b3312f072d 100644 --- a/paddle/math/CpuSparseMatrix.cpp +++ b/paddle/math/CpuSparseMatrix.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,12 +12,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "hl_gpu.h" #include "CpuSparseMatrix.h" #include "SparseMatrix.h" +#include "float.h" +#include "hl_gpu.h" #include "paddle/math/MathUtils.h" #include "paddle/utils/Util.h" -#include "float.h" namespace paddle { @@ -656,9 +656,9 @@ void CpuSparseMatrix::trimFrom(const CpuSparseMatrix& src) { if (format_ == SPARSE_CSR) { int* srcCols = src.getCols(); size_t numLessWidth = - std::count_if(srcCols, - srcCols + src.getElementCnt(), - [this](size_t n) { return n < this->width_; }); + std::count_if(srcCols, srcCols + src.getElementCnt(), [this](size_t n) { + return n < this->width_; + }); resize(height_, width_, numLessWidth, valueType_, format_); rows_[0] = 0; size_t index = 0; diff --git a/paddle/math/CpuSparseMatrix.h b/paddle/math/CpuSparseMatrix.h index 50f3c1569a431fa746f1014b834eb48fb9fb76b6..9676f8864f845e8ab75467c8ca6b6e7e68945d96 100644 --- a/paddle/math/CpuSparseMatrix.h +++ b/paddle/math/CpuSparseMatrix.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/math/ExecViaCpu.h b/paddle/math/ExecViaCpu.h index 67fb6c0cda6f46ddf4547b9ec9faaa8931c75eed..1e03cc5f45a96f20e49482fdfc8eba5c7124fe00 100644 --- a/paddle/math/ExecViaCpu.h +++ b/paddle/math/ExecViaCpu.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/math/MathFunctions.cpp b/paddle/math/MathFunctions.cpp index 1217163beecf19c2af215e3d4c72db644cd74b51..d7aa1184872d5a6129becca1f6e282776c9dbe15 100644 --- a/paddle/math/MathFunctions.cpp +++ b/paddle/math/MathFunctions.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -13,8 +13,8 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "MathFunctions.h" -#include "hl_matrix_ops.cuh" #include "hl_matrix_apply.cuh" +#include "hl_matrix_ops.cuh" namespace paddle { diff --git a/paddle/math/MathFunctions.h b/paddle/math/MathFunctions.h index 0741c456780e36c6b87dd44d89ffc601ac928f31..c8559eefd8378450fc18c2ba821c65b39c8cc046 100644 --- a/paddle/math/MathFunctions.h +++ b/paddle/math/MathFunctions.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/math/MathUtils.cpp b/paddle/math/MathUtils.cpp index 878e0b8723025e75f7838e981517f58a3dcb5424..5bbc3e4e3725f186373072440a93f967178e0b27 100644 --- a/paddle/math/MathUtils.cpp +++ b/paddle/math/MathUtils.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,8 +14,8 @@ limitations under the License. */ #include "MathUtils.h" #include -#include "paddle/utils/Logging.h" #include "Vector.h" +#include "paddle/utils/Logging.h" namespace paddle { diff --git a/paddle/math/MathUtils.h b/paddle/math/MathUtils.h index 907116c00281bfcf34c6652564f55a37c3f47a8c..f2b298013877d59e1fa0eca4feb09e4f6608fdf5 100644 --- a/paddle/math/MathUtils.h +++ b/paddle/math/MathUtils.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/math/Matrix.cpp b/paddle/math/Matrix.cpp index b70b47a5fcc72edea8fa5a680c4af962ea0f4ae9..c69e074a76399db923a5c64243f1d3690858810d 100644 --- a/paddle/math/Matrix.cpp +++ b/paddle/math/Matrix.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/math/Matrix.h b/paddle/math/Matrix.h index 5de78bb84c3e046b3a60cdb0b8ffe2e6384adc92..4342ca52a3d6677bea312531cd562895621218c5 100644 --- a/paddle/math/Matrix.h +++ b/paddle/math/Matrix.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ limitations under the License. */ #pragma once +#include #include #include -#include #include "paddle/utils/Logging.h" #include "paddle/utils/ThreadLocal.h" #include +#include "BaseMatrix.h" #include "MemoryHandle.h" -#include "paddle/utils/TypeDefs.h" #include "Vector.h" #include "paddle/utils/ThreadLocal.h" -#include "BaseMatrix.h" +#include "paddle/utils/TypeDefs.h" namespace paddle { diff --git a/paddle/math/MatrixBitCode.cpp b/paddle/math/MatrixBitCode.cpp index ac5b10c7bd56bb34393ac8abb98900351afc2e41..cea912d3ca02715c203814d13529aadfd9d3b7fb 100644 --- a/paddle/math/MatrixBitCode.cpp +++ b/paddle/math/MatrixBitCode.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,10 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Logging.h" -#include "paddle/utils/Util.h" #include "Matrix.h" #include "hl_gpu.h" +#include "paddle/utils/Logging.h" +#include "paddle/utils/Util.h" namespace paddle { diff --git a/paddle/math/MemoryHandle.cpp b/paddle/math/MemoryHandle.cpp index 9101957fc6c221bed4aa8e0c76b4c6735e50fd2d..84afb5944c3ea4aa3b8f44646b23d18b2903281b 100644 --- a/paddle/math/MemoryHandle.cpp +++ b/paddle/math/MemoryHandle.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include #include "MemoryHandle.h" +#include #include "Storage.h" namespace paddle { diff --git a/paddle/math/MemoryHandle.h b/paddle/math/MemoryHandle.h index f12635d5d4b6ff7204d4d3e8d6f07d438c0ce1e8..0828d377c90c9fc93b79078ffed0d0b911b99c04 100644 --- a/paddle/math/MemoryHandle.h +++ b/paddle/math/MemoryHandle.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/math/PoolAllocator.cpp b/paddle/math/PoolAllocator.cpp index 2c150949dd4eca08824401685beecc19142cbd76..4282c7243a801c4116885cfa91d78c635e49ea94 100644 --- a/paddle/math/PoolAllocator.cpp +++ b/paddle/math/PoolAllocator.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/math/PoolAllocator.h b/paddle/math/PoolAllocator.h index 5d33b453127a5aaa355ba8c569baf1eefe931c96..c06efa9ac77a5659b242d039c38455e2ee9b0db6 100644 --- a/paddle/math/PoolAllocator.h +++ b/paddle/math/PoolAllocator.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,11 +14,11 @@ limitations under the License. */ #pragma once +#include #include #include -#include #include -#include +#include #include "Allocator.h" namespace paddle { diff --git a/paddle/math/SIMDFunctions.cpp b/paddle/math/SIMDFunctions.cpp index 1fb156f29bbb586b6251f961bb4fd5f4d5da0737..95219debf50e57407b668d315b91141d259fc779 100644 --- a/paddle/math/SIMDFunctions.cpp +++ b/paddle/math/SIMDFunctions.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/math/SIMDFunctions.h b/paddle/math/SIMDFunctions.h index ac82f109104d7c21f346f909984306de105c0fd4..9b0a8719b287a2b88e966484090974586d64521f 100644 --- a/paddle/math/SIMDFunctions.h +++ b/paddle/math/SIMDFunctions.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/math/SparseMatrix.cpp b/paddle/math/SparseMatrix.cpp index 2b0bff9535d5a9ba4a47def4d6f964c799325535..9154503c2132a740aaa42f90eb7061156403ac00 100644 --- a/paddle/math/SparseMatrix.cpp +++ b/paddle/math/SparseMatrix.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,13 +12,13 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "SparseMatrix.h" #include +#include #include #include "hl_gpu.h" -#include "SparseMatrix.h" -#include "paddle/utils/Util.h" #include "hl_top_k.h" -#include +#include "paddle/utils/Util.h" namespace paddle { @@ -537,11 +537,9 @@ void GpuSparseMatrix::transpose(MatrixPtr matTrans, bool memAlloc) { dataVec.emplace_back( rows.getData()[i], cols_full.getData()[i], value.getData()[i]); } - std::sort(dataVec.begin(), - dataVec.end(), - [](Element a, Element b) { - return a.row < b.row || (a.row == b.row && a.col < b.col); - }); + std::sort(dataVec.begin(), dataVec.end(), [](Element a, Element b) { + return a.row < b.row || (a.row == b.row && a.col < b.col); + }); /*get sorted data, row index, and col index, put them in the right place*/ cols.resize(height_ + 1); diff --git a/paddle/math/SparseMatrix.h b/paddle/math/SparseMatrix.h index 175ef54b858b7f8f31f45796d733af81a9d67066..bd96a3301ded2fd89bd31b94f42b0cb4718cbcb7 100644 --- a/paddle/math/SparseMatrix.h +++ b/paddle/math/SparseMatrix.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,8 +14,8 @@ limitations under the License. */ #pragma once #include -#include "Matrix.h" #include "CpuSparseMatrix.h" +#include "Matrix.h" namespace paddle { diff --git a/paddle/math/SparseRowMatrix.cpp b/paddle/math/SparseRowMatrix.cpp index 100827e321effb3240c024b4d16da2d0524a2b1c..3091743123af03561f91dfb8b03e65087310ce64 100644 --- a/paddle/math/SparseRowMatrix.cpp +++ b/paddle/math/SparseRowMatrix.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/math/SparseRowMatrix.h b/paddle/math/SparseRowMatrix.h index 56f113a3614e2e22809abbdaa708557ed3344464..badb4b9c1cce4d93c24aac47c8ed742c4d7d38fa 100644 --- a/paddle/math/SparseRowMatrix.h +++ b/paddle/math/SparseRowMatrix.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,10 +14,10 @@ limitations under the License. */ #pragma once -#include #include -#include "paddle/utils/CommandLineParser.h" +#include #include "Matrix.h" +#include "paddle/utils/CommandLineParser.h" #include "paddle/utils/Util.h" P_DECLARE_bool(allow_inefficient_sparse_update); diff --git a/paddle/math/Storage.cpp b/paddle/math/Storage.cpp index 57ea5c926647d21a82c87fc262e2999e45e7534f..f9a2c12cd539ab4785847a58d3fedfc384e05232 100644 --- a/paddle/math/Storage.cpp +++ b/paddle/math/Storage.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Util.h" -#include "Allocator.h" #include "Storage.h" +#include "Allocator.h" +#include "paddle/utils/Util.h" P_DEFINE_int32(pool_limit_size, 536870912, diff --git a/paddle/math/Storage.h b/paddle/math/Storage.h index 725de247e64c26ccf80a83bce70989f5c3c4fe45..06a66b5f14643153f82a1596096fc28d3e47e3fd 100644 --- a/paddle/math/Storage.h +++ b/paddle/math/Storage.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -16,8 +16,8 @@ limitations under the License. */ #include #include -#include "paddle/utils/Locks.h" #include "PoolAllocator.h" +#include "paddle/utils/Locks.h" namespace paddle { diff --git a/paddle/math/TensorApply.h b/paddle/math/TensorApply.h index 8b2a9a7cd2b3388b991d7d1b05ac9104a092e5e0..11c7acb44129a3b5bf680a4b5f9ff465d44b0965 100644 --- a/paddle/math/TensorApply.h +++ b/paddle/math/TensorApply.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/math/TensorAssign.h b/paddle/math/TensorAssign.h index 03f7048d2d0576eaa0f759f913c35dc223ca336d..943fb5649e4f1b791ab38479ca61c3fe11fc698e 100644 --- a/paddle/math/TensorAssign.h +++ b/paddle/math/TensorAssign.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/math/TensorEvaluate.h b/paddle/math/TensorEvaluate.h index 39981246f021f4185c6c70b15f08907468764397..9de2099b850d1723fe085eeed97c5b141629eec1 100644 --- a/paddle/math/TensorEvaluate.h +++ b/paddle/math/TensorEvaluate.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -15,8 +15,8 @@ limitations under the License. */ #pragma once #include -#include "paddle/utils/Logging.h" #include "hl_base.h" +#include "paddle/utils/Logging.h" namespace paddle { diff --git a/paddle/math/TensorExpression.h b/paddle/math/TensorExpression.h index b28ea2be1d90b2e8e71a72e07913d15ccfade456..9bd789e8c511f33d8415e421281e99eb10fc63fe 100644 --- a/paddle/math/TensorExpression.h +++ b/paddle/math/TensorExpression.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -13,11 +13,11 @@ See the License for the specific language governing permissions and limitations under the License. */ #pragma once -#include #include -#include "paddle/utils/TypeDefs.h" -#include "paddle/utils/Logging.h" +#include #include "hl_tensor_ops.h" +#include "paddle/utils/Logging.h" +#include "paddle/utils/TypeDefs.h" namespace paddle { diff --git a/paddle/math/TrainingAlgorithmOp.cu b/paddle/math/TrainingAlgorithmOp.cu index d8d9c793fba0cb09503885de925a9844c9c0f554..72ff077270382d52bfcd340cc64d9abf49d1705d 100644 --- a/paddle/math/TrainingAlgorithmOp.cu +++ b/paddle/math/TrainingAlgorithmOp.cu @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/math/TrainingAlgorithmOp.h b/paddle/math/TrainingAlgorithmOp.h index 68eb98a93e423fa064168bc930cea1b62b7c62d0..881a8d72d888083ad87a536c127009d68c51076e 100644 --- a/paddle/math/TrainingAlgorithmOp.h +++ b/paddle/math/TrainingAlgorithmOp.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,8 +14,8 @@ limitations under the License. */ #pragma once -#include "paddle/utils/Logging.h" #include "BaseMatrix.h" +#include "paddle/utils/Logging.h" namespace paddle { diff --git a/paddle/math/Vector.cpp b/paddle/math/Vector.cpp index b2ade83138428a510e6be1bfa82290008e4167d0..eaa1cdce305c2f9d7a517e9e8c8606dc1f70780b 100644 --- a/paddle/math/Vector.cpp +++ b/paddle/math/Vector.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,17 +12,17 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Util.h" #include "Vector.h" +#include "paddle/utils/Util.h" #include -#include "paddle/utils/Logging.h" -#include "paddle/utils/ThreadLocal.h" -#include "paddle/utils/Thread.h" -#include "paddle/utils/Flags.h" #include "Matrix.h" #include "hl_gpu.h" #include "hl_table_apply.h" +#include "paddle/utils/Flags.h" +#include "paddle/utils/Logging.h" +#include "paddle/utils/Thread.h" +#include "paddle/utils/ThreadLocal.h" namespace paddle { @@ -754,8 +754,7 @@ void ParallelCpuVectorT::exec(SyncThreadPool::JobFunc func) { } template -CpuGpuVectorT::CpuGpuVectorT(size_t size, bool useGpu) - : sync_(nullptr) { +CpuGpuVectorT::CpuGpuVectorT(size_t size, bool useGpu) : sync_(nullptr) { if (!useGpu) { cpuVectorT_ = std::make_shared>(size); } else { diff --git a/paddle/math/Vector.h b/paddle/math/Vector.h index bcd8ff3fa3c1b1298e7b028eb405bc2a7476533c..8a24103bd4107035c8068c24ec3be6ec06957112 100644 --- a/paddle/math/Vector.h +++ b/paddle/math/Vector.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,15 +14,15 @@ limitations under the License. */ #pragma once -#include #include +#include #include -#include "MemoryHandle.h" -#include "paddle/utils/TypeDefs.h" #include "BaseMatrix.h" +#include "MemoryHandle.h" #include "paddle/utils/Thread.h" +#include "paddle/utils/TypeDefs.h" namespace paddle { diff --git a/paddle/math/tests/OriginalOptimizerApi.h b/paddle/math/tests/OriginalOptimizerApi.h index fe4d1ae54296b65d690b0a667fbf18023bee05cd..0188372771d97942a0761c673d40d040528ff59a 100644 --- a/paddle/math/tests/OriginalOptimizerApi.h +++ b/paddle/math/tests/OriginalOptimizerApi.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,8 +14,8 @@ limitations under the License. */ #pragma once -#include "paddle/utils/GlobalConstants.h" #include "paddle/math/Vector.h" +#include "paddle/utils/GlobalConstants.h" using namespace paddle; // NOLINT diff --git a/paddle/math/tests/PerfUtils.h b/paddle/math/tests/PerfUtils.h index c32f4c634a691d5d747157d1d6d50406fdb99c3b..9c6a63ce6c03c0db993d4bb52fe536e82ba2d726 100644 --- a/paddle/math/tests/PerfUtils.h +++ b/paddle/math/tests/PerfUtils.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/math/tests/TensorCheck.h b/paddle/math/tests/TensorCheck.h index 956bcf61a455dea6fdded823cd2fdd4801b0771a..5bc4a03067a75527fa30e5bb5526f93dc7b9fdcc 100644 --- a/paddle/math/tests/TensorCheck.h +++ b/paddle/math/tests/TensorCheck.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/math/tests/TestUtils.h b/paddle/math/tests/TestUtils.h index 2edb07de0144ba194cd18e644fbc93efcbe4837a..c3020961880484a7944f8cc61377a4f08122e403 100644 --- a/paddle/math/tests/TestUtils.h +++ b/paddle/math/tests/TestUtils.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -40,9 +40,9 @@ limitations under the License. */ */ #include +#include "TensorCheck.h" #include "paddle/math/Matrix.h" #include "paddle/math/SparseMatrix.h" -#include "TensorCheck.h" namespace autotest { diff --git a/paddle/math/tests/test_Allocator.cpp b/paddle/math/tests/test_Allocator.cpp index 084322a1caf579cf6237b41c51efa220c6f2d5a2..33e0952efedddec16acf6153209e14f18fd48134 100644 --- a/paddle/math/tests/test_Allocator.cpp +++ b/paddle/math/tests/test_Allocator.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -13,11 +13,11 @@ See the License for the specific language governing permissions and limitations under the License. */ #include -#include "paddle/utils/Util.h" #include "paddle/utils/Logging.h" +#include "paddle/utils/Util.h" #define private public -#include "paddle/math/MemoryHandle.h" #include "paddle/math/Allocator.h" +#include "paddle/math/MemoryHandle.h" #include "paddle/math/PoolAllocator.h" using namespace paddle; // NOLINT diff --git a/paddle/math/tests/test_BaseMatrix.cpp b/paddle/math/tests/test_BaseMatrix.cpp index f8c795a63918c5d52c8b92fad2d487c6e9f6df05..cc7c1e7eb2734605cb278a4b97cab22bdba1594e 100644 --- a/paddle/math/tests/test_BaseMatrix.cpp +++ b/paddle/math/tests/test_BaseMatrix.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -20,8 +20,8 @@ limitations under the License. */ */ #include -#include "paddle/math/BaseMatrix.h" #include "TestUtils.h" +#include "paddle/math/BaseMatrix.h" using paddle::BaseMatrix; using paddle::Matrix; diff --git a/paddle/math/tests/test_CpuGpuVector.cpp b/paddle/math/tests/test_CpuGpuVector.cpp index 7b50b020cda9315c48b897cdab82675c625094ef..624fa20ca58bca3f16fa567487bbaa5d9656e1b1 100644 --- a/paddle/math/tests/test_CpuGpuVector.cpp +++ b/paddle/math/tests/test_CpuGpuVector.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,10 +14,10 @@ limitations under the License. */ #ifndef PADDLE_ONLY_CPU -#include "paddle/utils/Util.h" +#include #include "paddle/math/Vector.h" +#include "paddle/utils/Util.h" #include "test_matrixUtil.h" -#include using namespace paddle; // NOLINT diff --git a/paddle/math/tests/test_ExecViaCpu.cpp b/paddle/math/tests/test_ExecViaCpu.cpp index b3eca19a7291d2b71b801793f824c1087a3ded27..27216ddb58eccd7fd52e121e795baf463ea69f51 100644 --- a/paddle/math/tests/test_ExecViaCpu.cpp +++ b/paddle/math/tests/test_ExecViaCpu.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,10 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include #include -#include +#include #include +#include #include "paddle/math/SparseMatrix.h" using namespace paddle; // NOLINT diff --git a/paddle/math/tests/test_FPException.cpp b/paddle/math/tests/test_FPException.cpp index f996e0daddd3ef41e195de48640631a979a87192..6aa5891bce922c00cbb4f69a511fb3c42d53f319 100644 --- a/paddle/math/tests/test_FPException.cpp +++ b/paddle/math/tests/test_FPException.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/math/tests/test_GpuProfiler.cpp b/paddle/math/tests/test_GpuProfiler.cpp index c3542b7834224e2fa6fe323a1fbe8ea1e7cd68de..d490078d909e7940e83a6f461f9386eeda02f53c 100644 --- a/paddle/math/tests/test_GpuProfiler.cpp +++ b/paddle/math/tests/test_GpuProfiler.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,12 +14,12 @@ limitations under the License. */ #ifndef PADDLE_ONLY_CPU -#include "paddle/utils/Util.h" -#include "paddle/math/Matrix.h" -#include "paddle/math/SparseMatrix.h" #include #include "paddle/gserver/tests/TestUtil.h" +#include "paddle/math/Matrix.h" +#include "paddle/math/SparseMatrix.h" #include "paddle/utils/Stat.h" +#include "paddle/utils/Util.h" using namespace paddle; // NOLINT using namespace std; // NOLINT @@ -52,7 +52,9 @@ void MatrixCheckErr(const Matrix& matrix1, const Matrix& matrix2) { EXPECT_EQ(count, 0) << "There are " << count << " different element."; } -void testBilinearFwdBwd(int numSamples, int imgSizeH, int imgSizeW, +void testBilinearFwdBwd(int numSamples, + int imgSizeH, + int imgSizeW, int channels) { int inWidth = imgSizeH * imgSizeW * channels; int outWidth = 2 * imgSizeH * 2 * imgSizeW * channels; @@ -73,10 +75,22 @@ void testBilinearFwdBwd(int numSamples, int imgSizeH, int imgSizeW, { // nvprof: GPU Proflier REGISTER_GPU_PROFILER("testBilinearFwdBwd"); - target->bilinearForward(*input, imgSizeH, imgSizeW, - 2 * imgSizeH, 2 * imgSizeW, channels, ratioH, ratioW); - targetGpu->bilinearForward(*inputGpu, imgSizeH, imgSizeW, - 2 * imgSizeH, 2 * imgSizeW, channels, ratioH, ratioW); + target->bilinearForward(*input, + imgSizeH, + imgSizeW, + 2 * imgSizeH, + 2 * imgSizeW, + channels, + ratioH, + ratioW); + targetGpu->bilinearForward(*inputGpu, + imgSizeH, + imgSizeW, + 2 * imgSizeH, + 2 * imgSizeW, + channels, + ratioH, + ratioW); } // check @@ -88,8 +102,8 @@ void testBilinearFwdBwd(int numSamples, int imgSizeH, int imgSizeW, MatrixPtr inputGpuGrad = GpuMatrix::create(numSamples, inWidth, false, true); MatrixPtr targetGrad = CpuMatrix::create(numSamples, outWidth, false, false); - MatrixPtr targetGpuGrad = GpuMatrix::create(numSamples, outWidth, false, - true); + MatrixPtr targetGpuGrad = + GpuMatrix::create(numSamples, outWidth, false, true); MatrixPtr targetCheckGrad = CpuMatrix::create(numSamples, inWidth, false, false); @@ -98,10 +112,22 @@ void testBilinearFwdBwd(int numSamples, int imgSizeH, int imgSizeW, inputGpuGrad->copyFrom(*inputGrad); targetGpuGrad->copyFrom(*targetGrad); - inputGrad->bilinearBackward(*targetGrad, 2 * imgSizeH, 2 * imgSizeW, - imgSizeH, imgSizeW, channels, ratioH, ratioW); - inputGpuGrad->bilinearBackward(*targetGpuGrad, 2 * imgSizeH, 2 * imgSizeW, - imgSizeH, imgSizeW, channels, ratioH, ratioW); + inputGrad->bilinearBackward(*targetGrad, + 2 * imgSizeH, + 2 * imgSizeW, + imgSizeH, + imgSizeW, + channels, + ratioH, + ratioW); + inputGpuGrad->bilinearBackward(*targetGpuGrad, + 2 * imgSizeH, + 2 * imgSizeW, + imgSizeH, + imgSizeW, + channels, + ratioH, + ratioW); // check targetCheckGrad->copyFrom(*inputGpuGrad); @@ -116,8 +142,9 @@ TEST(Profiler, testBilinearFwdBwd) { // nvprof: GPU Proflier REGISTER_GPU_PROFILER("testBilinearFwdBwd"); // Paddle built-in timer - REGISTER_TIMER_INFO("testBilinearFwdBwd", - "numSamples = 10, channels = 16, imgSizeX = 64, imgSizeY = 64"); + REGISTER_TIMER_INFO( + "testBilinearFwdBwd", + "numSamples = 10, channels = 16, imgSizeX = 64, imgSizeY = 64"); testBilinearFwdBwd(numSamples, imgSize, imgSize, channels); } globalStat.printAllStatus(); @@ -128,8 +155,9 @@ int main(int argc, char** argv) { initMain(argc, argv); // nvprof: GPU Proflier - REGISTER_GPU_PROFILER("RecursiveProfilingTest", - "numSamples = 10, channels = 16, imgSizeX = 64, imgSizeY = 64"); + REGISTER_GPU_PROFILER( + "RecursiveProfilingTest", + "numSamples = 10, channels = 16, imgSizeX = 64, imgSizeY = 64"); return RUN_ALL_TESTS(); } diff --git a/paddle/math/tests/test_Matrix.cpp b/paddle/math/tests/test_Matrix.cpp index edc9d74103240ff3790a4baf2ae796cab4aca55b..adb5fbd9fa30d810a25a2eb11f6d57474c1304c7 100644 --- a/paddle/math/tests/test_Matrix.cpp +++ b/paddle/math/tests/test_Matrix.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/math/tests/test_SIMDFunctions.cpp b/paddle/math/tests/test_SIMDFunctions.cpp index 8405b96fc2b915e2e1a5676ab5e3f25b4acde75a..f62843310d886ba7d449e793066b19a7cc7bd5a9 100644 --- a/paddle/math/tests/test_SIMDFunctions.cpp +++ b/paddle/math/tests/test_SIMDFunctions.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -17,10 +17,10 @@ limitations under the License. */ #include -#include -#include #include +#include #include +#include #include #include diff --git a/paddle/math/tests/test_SparseMatrix.cpp b/paddle/math/tests/test_SparseMatrix.cpp index 3788218aab100d4ad683e85149a9513e54ca2480..88b75b6d83612c56a598cf1b301bd38f888e1cce 100644 --- a/paddle/math/tests/test_SparseMatrix.cpp +++ b/paddle/math/tests/test_SparseMatrix.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/math/tests/test_Tensor.cu b/paddle/math/tests/test_Tensor.cu index 8fa402055a6fa5963101b9e7b5c9d266161c9f78..1859b9fc13576b6f1d0bc13b43f7e7a2ef6030c9 100644 --- a/paddle/math/tests/test_Tensor.cu +++ b/paddle/math/tests/test_Tensor.cu @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/math/tests/test_TrainingAlgorithm.cpp b/paddle/math/tests/test_TrainingAlgorithm.cpp index b40c8d9dae5fc573d8696a853c74e48f5293b234..1bf6a0cc43ea16c955b1b1cd7ef61d2e7100726a 100644 --- a/paddle/math/tests/test_TrainingAlgorithm.cpp +++ b/paddle/math/tests/test_TrainingAlgorithm.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -13,11 +13,11 @@ See the License for the specific language governing permissions and limitations under the License. */ #include -#include "paddle/utils/Util.h" -#include "paddle/math/TrainingAlgorithmOp.h" #include "OriginalOptimizerApi.h" -#include "TensorCheck.h" #include "PerfUtils.h" +#include "TensorCheck.h" +#include "paddle/math/TrainingAlgorithmOp.h" +#include "paddle/utils/Util.h" using namespace paddle; // NOLINT diff --git a/paddle/math/tests/test_batchTranspose.cpp b/paddle/math/tests/test_batchTranspose.cpp index a9596992b2b1fced417c048600b05b39882b2bf2..9925e24dc14294ec70806ffd9cc496ea01beaa43 100644 --- a/paddle/math/tests/test_batchTranspose.cpp +++ b/paddle/math/tests/test_batchTranspose.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "test_matrixUtil.h" #include "hl_batch_transpose.h" +#include "test_matrixUtil.h" using namespace paddle; // NOLINT diff --git a/paddle/math/tests/test_lazyAssign.cu b/paddle/math/tests/test_lazyAssign.cu index 52dfdacffe3b915db07eb04bad7b8d45c7ccf44e..16541edb54b807d4e1690d4ae63fd44459e2d726 100644 --- a/paddle/math/tests/test_lazyAssign.cu +++ b/paddle/math/tests/test_lazyAssign.cu @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/math/tests/test_matrixCompare.cpp b/paddle/math/tests/test_matrixCompare.cpp index 0883066947ae67cd55c2c505eef72168f3139b8d..62de5b25e4cc803d9ccc605fba29a1d29a3ea69c 100644 --- a/paddle/math/tests/test_matrixCompare.cpp +++ b/paddle/math/tests/test_matrixCompare.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -16,13 +16,13 @@ limitations under the License. */ /// This unittest checks GpuMatrix/CpuMatrix get same result, so disable when /// only cpu version. -#include "paddle/utils/Util.h" -#include "paddle/math/Matrix.h" -#include "paddle/math/SparseMatrix.h" #include +#include "TensorCheck.h" #include "paddle/gserver/tests/TestUtil.h" +#include "paddle/math/Matrix.h" +#include "paddle/math/SparseMatrix.h" #include "paddle/utils/Stat.h" -#include "TensorCheck.h" +#include "paddle/utils/Util.h" using namespace paddle; // NOLINT using namespace std; // NOLINT diff --git a/paddle/math/tests/test_matrixUtil.h b/paddle/math/tests/test_matrixUtil.h index 5300e7168b9dc61b65e64346424e65c11665cf99..9aa74b15193723970d80b5d1a4e0ac95341cd45a 100644 --- a/paddle/math/tests/test_matrixUtil.h +++ b/paddle/math/tests/test_matrixUtil.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/math/tests/test_perturbation.cpp b/paddle/math/tests/test_perturbation.cpp index 837c2f47ba05a04988431e14cb6bc2490f42d32e..60ebae015381a3901c14d0cd4c1225e54ac5726f 100644 --- a/paddle/math/tests/test_perturbation.cpp +++ b/paddle/math/tests/test_perturbation.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,10 +14,10 @@ limitations under the License. */ #ifndef PADDLE_ONLY_CPU -#include +#include #include +#include #include -#include #include "hl_cuda.h" #include "hl_perturbation_util.cuh" diff --git a/paddle/math/tests/test_sparseMatrixCompare.cpp b/paddle/math/tests/test_sparseMatrixCompare.cpp index d7aa20eb984417ff3907b078a263c5651d6209d3..6f6de238bacaade85d728b7d773145326229015a 100644 --- a/paddle/math/tests/test_sparseMatrixCompare.cpp +++ b/paddle/math/tests/test_sparseMatrixCompare.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -17,10 +17,10 @@ limitations under the License. */ // so disable when /// only cpu version. -#include "paddle/utils/Util.h" +#include #include "paddle/math/Matrix.h" +#include "paddle/utils/Util.h" #include "test_matrixUtil.h" -#include using namespace paddle; // NOLINT using namespace std; // NOLINT diff --git a/paddle/parameter/Argument.cpp b/paddle/parameter/Argument.cpp index 0f414b4463b6993ca7bf0bc1eafebbbf9f1a8e00..e91daa371768e6f7f3846f95027cc6320926052c 100644 --- a/paddle/parameter/Argument.cpp +++ b/paddle/parameter/Argument.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -551,11 +551,10 @@ void Argument::getSeqInfo(std::vector* seqInfo) const { } seqInfo->push_back(info); } - std::sort(seqInfo->begin(), - seqInfo->end(), - [](const SeqInfo& a, const SeqInfo& b) { - return a.topLevelLength > b.topLevelLength; - }); + std::sort( + seqInfo->begin(), seqInfo->end(), [](const SeqInfo& a, const SeqInfo& b) { + return a.topLevelLength > b.topLevelLength; + }); } void Argument::checkSubset() const { diff --git a/paddle/parameter/Argument.h b/paddle/parameter/Argument.h index 2b20122debf935562d36f29d872e8ef3243111e0..afd2de0202bf0f14ec3d4c5b856455a3488e41f6 100644 --- a/paddle/parameter/Argument.h +++ b/paddle/parameter/Argument.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -18,9 +18,9 @@ limitations under the License. */ #include "paddle/math/Matrix.h" #include "paddle/math/Vector.h" +#include "paddle/parameter/Parameter.h" #include "paddle/utils/Locks.h" #include "paddle/utils/Util.h" -#include "paddle/parameter/Parameter.h" namespace paddle { diff --git a/paddle/parameter/AverageOptimizer.cpp b/paddle/parameter/AverageOptimizer.cpp index 593594761ed57495b92a30a8f3e8e86cdb45bfce..e51ca5652090e6fba5e2070fc8f8c1d10e9ecc7a 100644 --- a/paddle/parameter/AverageOptimizer.cpp +++ b/paddle/parameter/AverageOptimizer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/parameter/AverageOptimizer.h b/paddle/parameter/AverageOptimizer.h index ccc2612608db574274f3e0acaacec7f9eb404223..9fd3f75baa6dd54620e7e7a93f14deb598999cf4 100644 --- a/paddle/parameter/AverageOptimizer.h +++ b/paddle/parameter/AverageOptimizer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/parameter/FirstOrderOptimizer.cpp b/paddle/parameter/FirstOrderOptimizer.cpp index 9e363fb20d11928fb0fa303d4ad8231fb399307b..630f15c8cfbe6cca16094d0eb6677702339aa730 100644 --- a/paddle/parameter/FirstOrderOptimizer.cpp +++ b/paddle/parameter/FirstOrderOptimizer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,10 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Util.h" -#include "paddle/utils/Flags.h" -#include "paddle/math/TrainingAlgorithmOp.h" #include "FirstOrderOptimizer.h" +#include "paddle/math/TrainingAlgorithmOp.h" +#include "paddle/utils/Flags.h" +#include "paddle/utils/Util.h" #include diff --git a/paddle/parameter/FirstOrderOptimizer.h b/paddle/parameter/FirstOrderOptimizer.h index a9a2ffdd41310d1927df012be8328d0e4bd3af0f..095019b74f4f667991a0d4c5d5511e371889539f 100644 --- a/paddle/parameter/FirstOrderOptimizer.h +++ b/paddle/parameter/FirstOrderOptimizer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/parameter/LearningRateScheduler.cpp b/paddle/parameter/LearningRateScheduler.cpp index a7412500ccfa05707286f0ad493ad8280eee1cbc..66448b2c5f6f440c3a7fdec2bd552d8dc7d0927f 100644 --- a/paddle/parameter/LearningRateScheduler.cpp +++ b/paddle/parameter/LearningRateScheduler.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/parameter/LearningRateScheduler.h b/paddle/parameter/LearningRateScheduler.h index e987c3dcde120b8c88d58de7a18ee5c6db85bb5c..53b9dba446e1c5908c1b990b026e6fbd4d8fd260 100644 --- a/paddle/parameter/LearningRateScheduler.h +++ b/paddle/parameter/LearningRateScheduler.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/parameter/OptimizerFunctions.cpp b/paddle/parameter/OptimizerFunctions.cpp index 6fd7964347644214533007dc1e11e6fa45ee9ea6..a4af1b470585937827305100e3fbf603e67c8241 100644 --- a/paddle/parameter/OptimizerFunctions.cpp +++ b/paddle/parameter/OptimizerFunctions.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/parameter/OptimizerFunctions.h b/paddle/parameter/OptimizerFunctions.h index a5f8b2c56942720335c0df6c9d71fd4e15494600..4f7370b6baf2b92469e73d54ecb25a23d73c3506 100644 --- a/paddle/parameter/OptimizerFunctions.h +++ b/paddle/parameter/OptimizerFunctions.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/parameter/OptimizerWithRegularizer.cpp b/paddle/parameter/OptimizerWithRegularizer.cpp index 5381e7bef3b177884d85671ef6e3dfbc0de1d5ed..85f13c8bc08c534224a1a8365d541737980b439f 100644 --- a/paddle/parameter/OptimizerWithRegularizer.cpp +++ b/paddle/parameter/OptimizerWithRegularizer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/parameter/OptimizerWithRegularizer.h b/paddle/parameter/OptimizerWithRegularizer.h index ebe23c7397f6d3f14976422342953e493a6fbee1..0e1c444d280886866c3b153988b1887a43c161c6 100644 --- a/paddle/parameter/OptimizerWithRegularizer.h +++ b/paddle/parameter/OptimizerWithRegularizer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/parameter/ParallelParameter.cpp b/paddle/parameter/ParallelParameter.cpp index 99b20a59ca2a8b4a84a5bcbd0fab135ac54de61c..cea77e5b1787c25ecb9ccd42e948bf90973fd4cb 100644 --- a/paddle/parameter/ParallelParameter.cpp +++ b/paddle/parameter/ParallelParameter.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Logging.h" #include +#include "paddle/utils/Logging.h" #include "ParallelParameter.h" diff --git a/paddle/parameter/ParallelParameter.h b/paddle/parameter/ParallelParameter.h index 2b65321fe201ae166dbbd6629e9a0ab0c6481699..417e386dc74d308a6c0aefa2640f0f37de8dbf1f 100644 --- a/paddle/parameter/ParallelParameter.h +++ b/paddle/parameter/ParallelParameter.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -16,19 +16,19 @@ limitations under the License. */ #include +#include +#include #include #include #include -#include -#include #include "hl_gpu.h" -#include "paddle/utils/Flags.h" -#include "paddle/utils/Locks.h" +#include "paddle/math/Vector.h" #include "paddle/parameter/Parameter.h" #include "paddle/parameter/ParameterUpdateFunctions.h" +#include "paddle/utils/Flags.h" +#include "paddle/utils/Locks.h" #include "paddle/utils/TypeDefs.h" -#include "paddle/math/Vector.h" #include "ParameterConfig.pb.h" diff --git a/paddle/parameter/Parameter.cpp b/paddle/parameter/Parameter.cpp index 7e37bf225ba25e8bae269cf45b69ce418a54d1a3..986ae1539b6ef7745e94be6101e94b40c287be94 100644 --- a/paddle/parameter/Parameter.cpp +++ b/paddle/parameter/Parameter.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,19 +12,19 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "Parameter.h" #include -#include "paddle/math/MathUtils.h" #include "AverageOptimizer.h" #include "FirstOrderOptimizer.h" -#include "Parameter.h" -#include "paddle/utils/Logging.h" #include "OptimizerFunctions.h" #include "OptimizerWithRegularizer.h" #include "ParameterUpdateFunctions.h" -#include "paddle/math/SparseRowMatrix.h" -#include "paddle/math/CpuSparseMatrix.h" #include "hl_gpu.h" +#include "paddle/math/CpuSparseMatrix.h" +#include "paddle/math/MathUtils.h" +#include "paddle/math/SparseRowMatrix.h" #include "paddle/utils/CommandLineParser.h" +#include "paddle/utils/Logging.h" P_DEFINE_int32(enable_grad_share, (100 * 1024 * 1024), diff --git a/paddle/parameter/Parameter.h b/paddle/parameter/Parameter.h index 1c159d669a6a0f7b56c377e0b1cfa35b3fb75d53..532c6770e596c33dfe7fd42f32157b2c6c19e18e 100644 --- a/paddle/parameter/Parameter.h +++ b/paddle/parameter/Parameter.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -23,14 +23,14 @@ limitations under the License. */ #include "ParameterConfig.pb.h" #include "TrainerConfig.pb.h" +#include "ParameterUpdaterHook.h" +#include "paddle/math/Matrix.h" +#include "paddle/math/Vector.h" +#include "paddle/utils/GlobalConstants.h" #include "paddle/utils/Locks.h" +#include "paddle/utils/ThreadLocal.h" #include "paddle/utils/TypeDefs.h" -#include "paddle/math/Vector.h" -#include "paddle/math/Matrix.h" #include "paddle/utils/Util.h" -#include "paddle/utils/ThreadLocal.h" -#include "ParameterUpdaterHook.h" -#include "paddle/utils/GlobalConstants.h" namespace paddle { diff --git a/paddle/parameter/ParameterOptimizer.cpp b/paddle/parameter/ParameterOptimizer.cpp index 2a71d6aee4dae556956616bd317156cfaf8732f0..7c8c6978e22c0e3cb3a3bdf8a7709a091cc2292b 100644 --- a/paddle/parameter/ParameterOptimizer.cpp +++ b/paddle/parameter/ParameterOptimizer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/parameter/ParameterOptimizer.h b/paddle/parameter/ParameterOptimizer.h index 21a148333c2fd3aa127c5b3bb8160784864f4cce..2bdc793d605e01f8e055087bb3e0973168cb0213 100644 --- a/paddle/parameter/ParameterOptimizer.h +++ b/paddle/parameter/ParameterOptimizer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/parameter/ParameterUpdateFunctions.cpp b/paddle/parameter/ParameterUpdateFunctions.cpp index 510ec5bf48a7576f646ecf01b02c5047c637afeb..c8af7105c78dcbf9f625a348b7f38efcf278469e 100644 --- a/paddle/parameter/ParameterUpdateFunctions.cpp +++ b/paddle/parameter/ParameterUpdateFunctions.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/parameter/ParameterUpdateFunctions.h b/paddle/parameter/ParameterUpdateFunctions.h index 2d98030bd2389469fbd32940af6162203557620c..2d277e47e7eafc118fa37343e93e8a331a260aa9 100644 --- a/paddle/parameter/ParameterUpdateFunctions.h +++ b/paddle/parameter/ParameterUpdateFunctions.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,8 +14,8 @@ limitations under the License. */ #pragma once -#include "paddle/utils/TypeDefs.h" #include "paddle/math/Vector.h" +#include "paddle/utils/TypeDefs.h" namespace paddle { diff --git a/paddle/parameter/ParameterUpdaterBase.cpp b/paddle/parameter/ParameterUpdaterBase.cpp index e706742053fc49df9c99081774f425622941e38c..49e2ae2b393f4a5e6c0986bc5e645011f5a3eca1 100644 --- a/paddle/parameter/ParameterUpdaterBase.cpp +++ b/paddle/parameter/ParameterUpdaterBase.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,10 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include -#include "paddle/utils/Logging.h" #include "ParameterUpdaterBase.h" +#include #include "hl_gpu.h" +#include "paddle/utils/Logging.h" namespace paddle { diff --git a/paddle/parameter/ParameterUpdaterBase.h b/paddle/parameter/ParameterUpdaterBase.h index ffd2980261530382ee09f2c98e354d0e56fd8038..5401046f676892c415f3e29ed1adbec75f5abe74 100644 --- a/paddle/parameter/ParameterUpdaterBase.h +++ b/paddle/parameter/ParameterUpdaterBase.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/parameter/ParameterUpdaterHook.cpp b/paddle/parameter/ParameterUpdaterHook.cpp index 7d85a32c0cf527d39c252c2021b7bad0eb58753d..f826e8448c666bb3305c150f2bd95aade23223fb 100644 --- a/paddle/parameter/ParameterUpdaterHook.cpp +++ b/paddle/parameter/ParameterUpdaterHook.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,16 +14,16 @@ limitations under the License. */ #include "ParameterUpdaterHook.h" +#include #include -#include #include -#include #include +#include #include "paddle/math/Vector.h" #include "paddle/parameter/Parameter.h" -#include "paddle/utils/Util.h" #include "paddle/utils/Flags.h" +#include "paddle/utils/Util.h" namespace paddle { @@ -156,7 +156,8 @@ private: static WeakKVCache, IParameterUpdaterHook, - StringIntPairHasher> g_hookCache_; + StringIntPairHasher> + g_hookCache_; /** * ParameterUpdaterHook actually factory method. diff --git a/paddle/parameter/ParameterUpdaterHook.h b/paddle/parameter/ParameterUpdaterHook.h index 553282bcaaa2e90910eaafbe2e03a4afadf04a85..1f4506441da725e13ed2b0f339e6e2f5f30bcc6a 100644 --- a/paddle/parameter/ParameterUpdaterHook.h +++ b/paddle/parameter/ParameterUpdaterHook.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/parameter/Regularizer.cpp b/paddle/parameter/Regularizer.cpp index a9bddc1596656ba36d6c445781f42991684f0c52..8511900150363a2247d508833eeb42b2d87beec1 100644 --- a/paddle/parameter/Regularizer.cpp +++ b/paddle/parameter/Regularizer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Util.h" -#include "paddle/utils/Flags.h" #include "Regularizer.h" +#include "paddle/utils/Flags.h" +#include "paddle/utils/Util.h" namespace paddle { diff --git a/paddle/parameter/Regularizer.h b/paddle/parameter/Regularizer.h index 5baaccc00db5f858272dbfa6751647915bfa6e3c..6d5477309812da4dda4bb7a4a869a2fde7f6bcf0 100644 --- a/paddle/parameter/Regularizer.h +++ b/paddle/parameter/Regularizer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/parameter/Weight.cpp b/paddle/parameter/Weight.cpp index c138010607412fa257a6c7360a27d855197f88ad..3738a58d7f84081db9b6179cef9361322553a627 100644 --- a/paddle/parameter/Weight.cpp +++ b/paddle/parameter/Weight.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Logging.h" #include "Weight.h" +#include "paddle/utils/Logging.h" namespace paddle { diff --git a/paddle/parameter/Weight.h b/paddle/parameter/Weight.h index 531b571cbc0055257e9a88037515834364439dc3..6e7a49154e87b89929cea066872c282f9410e776 100644 --- a/paddle/parameter/Weight.h +++ b/paddle/parameter/Weight.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/parameter/tests/test_common.cpp b/paddle/parameter/tests/test_common.cpp index 1a64fe335257a3107be03cfd333cb483c5ab452d..aa57a6346917b259dbb89f6ad2340fb8db28f3e3 100644 --- a/paddle/parameter/tests/test_common.cpp +++ b/paddle/parameter/tests/test_common.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,12 +12,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include #include +#include #include -#include #include +#include #include #include diff --git a/paddle/pserver/BaseClient.cpp b/paddle/pserver/BaseClient.cpp index ff83970ab1b11f74ceb4009cc8f469f7b54a7272..a43def98c528c2cfbc65a40aa54b5d4a49961a34 100644 --- a/paddle/pserver/BaseClient.cpp +++ b/paddle/pserver/BaseClient.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,11 +12,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include +#include "BaseClient.h" #include -#include "paddle/utils/Stat.h" +#include #include "paddle/utils/CommandLineParser.h" -#include "BaseClient.h" +#include "paddle/utils/Stat.h" P_DECLARE_string(pservers); diff --git a/paddle/pserver/BaseClient.h b/paddle/pserver/BaseClient.h index 3a501172b70a91e02ecda0f9f78e0c025ac67936..262afafbe2d61305a158d945fac2d3b265012cbd 100644 --- a/paddle/pserver/BaseClient.h +++ b/paddle/pserver/BaseClient.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,11 +14,11 @@ limitations under the License. */ #pragma once -#include "paddle/pserver/ProtoServer.h" +#include "ParameterService.pb.h" #include "paddle/math/Matrix.h" +#include "paddle/pserver/ProtoServer.h" #include "paddle/utils/Queue.h" #include "paddle/utils/TypeDefs.h" -#include "ParameterService.pb.h" namespace paddle { diff --git a/paddle/pserver/LightNetwork.cpp b/paddle/pserver/LightNetwork.cpp index 1830170a163fa47114c75a2a88a731ea31060142..329dfb0fb38e8ad377539d8af6be228595baa719 100644 --- a/paddle/pserver/LightNetwork.cpp +++ b/paddle/pserver/LightNetwork.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,23 +12,23 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include -#include +#include #include #include #include -#include +#include +#include #include -#include #include #include +#include #include #include "LightNetwork.h" -#include "paddle/utils/Util.h" -#include "paddle/utils/StringUtil.h" #include "RDMANetwork.h" +#include "paddle/utils/StringUtil.h" +#include "paddle/utils/Util.h" /// quick ack can reduce the latency of small message P_DEFINE_bool(small_messages, diff --git a/paddle/pserver/LightNetwork.h b/paddle/pserver/LightNetwork.h index b7d7bc7902abb18aae03fc4d8a3972f0298199fe..c4a06deb940e8f39af2fcb6de54de1b6cb2d1483 100644 --- a/paddle/pserver/LightNetwork.h +++ b/paddle/pserver/LightNetwork.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -16,10 +16,10 @@ limitations under the License. */ #include "SocketChannel.h" +#include #include #include #include -#include #include "paddle/utils/Thread.h" diff --git a/paddle/pserver/ParameterClient2.cpp b/paddle/pserver/ParameterClient2.cpp index 28cc0ae2dd36273397015e618f6e14ea43398964..84d965a66a16dfc597e728e11dab966cc194dfb1 100644 --- a/paddle/pserver/ParameterClient2.cpp +++ b/paddle/pserver/ParameterClient2.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -15,10 +15,10 @@ limitations under the License. */ #include #include "ParameterClient2.h" -#include "paddle/utils/StringUtil.h" +#include "paddle/math/SparseRowMatrix.h" #include "paddle/utils/Flags.h" #include "paddle/utils/Stat.h" -#include "paddle/math/SparseRowMatrix.h" +#include "paddle/utils/StringUtil.h" P_DEFINE_string(pservers, "127.0.0.1", "Comma separated addresses of pservers"); P_DEFINE_int32(parallel_thread_num, 1, "Thread number for parameter send"); diff --git a/paddle/pserver/ParameterClient2.h b/paddle/pserver/ParameterClient2.h index af8dd41ec4327fcf78625e7aa5d4b136ca7d14dd..52553949498e1938c6dbbf8004946692cd1bfe0b 100644 --- a/paddle/pserver/ParameterClient2.h +++ b/paddle/pserver/ParameterClient2.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -16,23 +16,23 @@ limitations under the License. */ #include #include -#include #include +#include -#include "paddle/utils/Locks.h" #include "paddle/math/Matrix.h" +#include "paddle/math/Vector.h" #include "paddle/parameter/Parameter.h" +#include "paddle/pserver/BaseClient.h" +#include "paddle/utils/Flags.h" +#include "paddle/utils/Locks.h" #include "paddle/utils/Queue.h" #include "paddle/utils/TypeDefs.h" #include "paddle/utils/Util.h" -#include "paddle/math/Vector.h" -#include "paddle/utils/Flags.h" -#include "paddle/pserver/BaseClient.h" #include "ParameterService.pb.h" -#include "SparseParameterDistribution.h" #include "ProtoServer.h" +#include "SparseParameterDistribution.h" P_DECLARE_int32(parallel_thread_num); diff --git a/paddle/pserver/ParameterServer2.cpp b/paddle/pserver/ParameterServer2.cpp index b7f999f8b132e59ce8b7dffe5c4d43615e4c564c..2cb4c93535ffe2012abb45628cc0cfc329846fd9 100644 --- a/paddle/pserver/ParameterServer2.cpp +++ b/paddle/pserver/ParameterServer2.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -21,14 +21,14 @@ limitations under the License. */ #include "paddle/parameter/AverageOptimizer.h" #include "paddle/parameter/FirstOrderOptimizer.h" -#include "paddle/utils/Flags.h" #include "paddle/parameter/OptimizerFunctions.h" #include "paddle/parameter/OptimizerWithRegularizer.h" -#include "paddle/parameter/ParameterUpdateFunctions.h" #include "paddle/parameter/ParameterOptimizer.h" +#include "paddle/parameter/ParameterUpdateFunctions.h" #include "paddle/parameter/Regularizer.h" -#include "paddle/utils/Stat.h" +#include "paddle/utils/Flags.h" #include "paddle/utils/GlobalConstants.h" +#include "paddle/utils/Stat.h" P_DEFINE_int32(pserver_num_threads, 1, "number of threads for sync op exec"); P_DEFINE_double(async_lagged_ratio_min, diff --git a/paddle/pserver/ParameterServer2.h b/paddle/pserver/ParameterServer2.h index ccaea42e7d0cb1865234702315fd4bbd00e548d5..61c139981e479cf6528dfb44ab6ae2f82b33bcc5 100644 --- a/paddle/pserver/ParameterServer2.h +++ b/paddle/pserver/ParameterServer2.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -15,24 +15,24 @@ limitations under the License. */ #pragma once #include +#include #include #include -#include -#include #include -#include +#include +#include #include #include -#include "paddle/utils/Locks.h" #include "paddle/math/Matrix.h" +#include "paddle/math/Vector.h" #include "paddle/parameter/Parameter.h" #include "paddle/parameter/ParameterOptimizer.h" +#include "paddle/utils/Locks.h" +#include "paddle/utils/Stat.h" #include "paddle/utils/ThreadLocal.h" #include "paddle/utils/TypeDefs.h" -#include "paddle/math/Vector.h" -#include "paddle/utils/Stat.h" #include "ParameterService.pb.h" diff --git a/paddle/pserver/ParameterServer2Main.cpp b/paddle/pserver/ParameterServer2Main.cpp index b15ef8c3ccc9220d38514e927e0e10184e901846..ffc521f2c143d95ff07c3825e0a746cb31743d9b 100644 --- a/paddle/pserver/ParameterServer2Main.cpp +++ b/paddle/pserver/ParameterServer2Main.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,13 +12,13 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Util.h" -#include "paddle/utils/StringUtil.h" #include +#include "paddle/utils/StringUtil.h" +#include "paddle/utils/Util.h" -#include "paddle/utils/Flags.h" #include "ParameterServer2.h" #include "RDMANetwork.h" +#include "paddle/utils/Flags.h" using namespace paddle; // NOLINT diff --git a/paddle/pserver/ProtoServer.cpp b/paddle/pserver/ProtoServer.cpp index 2f6d911a017d231692c42f2a235cf1e15257f7ae..410317ece28ec79dd668e91ff9fbed11f20a5acc 100644 --- a/paddle/pserver/ProtoServer.cpp +++ b/paddle/pserver/ProtoServer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/pserver/ProtoServer.h b/paddle/pserver/ProtoServer.h index cf08e24ff3ef47d9c17bfe14d7d3aff1537b8ce8..3acdcc27dab532f964dc97636be020138180e780 100644 --- a/paddle/pserver/ProtoServer.h +++ b/paddle/pserver/ProtoServer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -100,7 +100,8 @@ protected: ResponseCallback callback); typedef std::function msgReader, - ResponseCallback callback)> ServiceFunction; + ResponseCallback callback)> + ServiceFunction; /** * @brief register one RPC function in function mapping diff --git a/paddle/pserver/RDMANetwork.h b/paddle/pserver/RDMANetwork.h index 4e492a3afd120462ac6e056b9df850063c503a53..caef65134bf798851c0b826f7cc8bf2ab64b3f58 100644 --- a/paddle/pserver/RDMANetwork.h +++ b/paddle/pserver/RDMANetwork.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/pserver/SocketChannel.cpp b/paddle/pserver/SocketChannel.cpp index 4ebc47d32659d82f32b9da529aec7ec3f46f77a9..05998891649cee30e23e556d9311c3a383f43e10 100644 --- a/paddle/pserver/SocketChannel.cpp +++ b/paddle/pserver/SocketChannel.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,11 +14,11 @@ limitations under the License. */ #include "SocketChannel.h" -#include -#include -#include #include #include +#include +#include +#include #include #include "RDMANetwork.h" diff --git a/paddle/pserver/SocketChannel.h b/paddle/pserver/SocketChannel.h index 472b37a12283ca1c358034427d491804af765171..6c3dd20d7be60a53bfcf443d22888109ff9e3935 100644 --- a/paddle/pserver/SocketChannel.h +++ b/paddle/pserver/SocketChannel.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/pserver/SparseParameterDistribution.cpp b/paddle/pserver/SparseParameterDistribution.cpp index 2085b22a95138fa8caf474a081fb46229688966f..0068f85b52be75fd2f958ad7a1e2ae76949b1fee 100644 --- a/paddle/pserver/SparseParameterDistribution.cpp +++ b/paddle/pserver/SparseParameterDistribution.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/pserver/SparseParameterDistribution.h b/paddle/pserver/SparseParameterDistribution.h index af2b43af0ff58e842e53745dec7b501da6d36fe2..24b14106cf64060afa61ecede9e981301ea5634a 100644 --- a/paddle/pserver/SparseParameterDistribution.h +++ b/paddle/pserver/SparseParameterDistribution.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -15,8 +15,8 @@ limitations under the License. */ #pragma once #include -#include "paddle/utils/Logging.h" #include +#include "paddle/utils/Logging.h" namespace paddle { diff --git a/paddle/pserver/test/SocketTest.cpp b/paddle/pserver/test/SocketTest.cpp index 24c90f10785a6f5870ab291a5c5e6c13fbc0d49f..6e63c4f67848bea118adde2e3ef0b0c5b64086c9 100644 --- a/paddle/pserver/test/SocketTest.cpp +++ b/paddle/pserver/test/SocketTest.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,11 +14,11 @@ limitations under the License. */ #include "paddle/utils/Util.h" -#include -#include -#include #include #include +#include +#include +#include #include diff --git a/paddle/pserver/test/test_ParameterServer2.cpp b/paddle/pserver/test/test_ParameterServer2.cpp index eb813e92d6d696db6c2ced543a00594b69c7f5af..4257a2308d727fc60cb5b2e7e507ec86c90cd96b 100644 --- a/paddle/pserver/test/test_ParameterServer2.cpp +++ b/paddle/pserver/test/test_ParameterServer2.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include #include #include -#include #include #include diff --git a/paddle/pserver/test/test_ProtoServer.cpp b/paddle/pserver/test/test_ProtoServer.cpp index 79d1f2743a1c2e6050afe48d6cf86a1084a4500c..3880dde5e3fb8a986a8fa870cb92a58d138d43de 100644 --- a/paddle/pserver/test/test_ProtoServer.cpp +++ b/paddle/pserver/test/test_ProtoServer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -16,10 +16,10 @@ limitations under the License. */ #include -#include "paddle/utils/Stat.h" +#include "ParameterService.pb.h" #include "paddle/math/Vector.h" #include "paddle/pserver/ProtoServer.h" -#include "ParameterService.pb.h" +#include "paddle/utils/Stat.h" P_DEFINE_string(server_addr, "127.0.0.1", "Server address"); P_DEFINE_int64(dim, 50000000, "Data size"); diff --git a/paddle/pserver/test/test_ProtoServer.sh b/paddle/pserver/test/test_ProtoServer.sh index a87b1b1ddcd0ea7f48a6a37575dd17fd53fd0751..970c90b494c2a256cf22f3de7b7ea7964fed58ab 100755 --- a/paddle/pserver/test/test_ProtoServer.sh +++ b/paddle/pserver/test/test_ProtoServer.sh @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/py_paddle/__init__.py b/paddle/py_paddle/__init__.py index f8399f9c63d81f5a52bf2b277789c26d809f0153..5504d1d50c523315036bfaaf6641c5216269a5e5 100644 --- a/paddle/py_paddle/__init__.py +++ b/paddle/py_paddle/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/py_paddle/dataprovider_converter.py b/paddle/py_paddle/dataprovider_converter.py index d64c7b20cb65a4b8dfebfc516cfc2c3fdc247114..edcefba6a854df518fd2eb8c1fea5b72c5f5d6a8 100644 --- a/paddle/py_paddle/dataprovider_converter.py +++ b/paddle/py_paddle/dataprovider_converter.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/py_paddle/util.py b/paddle/py_paddle/util.py index 35a355ef29cebd84fd34e00cee05218220b2eb43..ce105d249aaf3e838443d3e0cf5996fe8c783a22 100644 --- a/paddle/py_paddle/util.py +++ b/paddle/py_paddle/util.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -559,10 +559,10 @@ def __monkey_patch_trainer__(): def monkeypatches(): - patches = [__monkeypatch_init_paddle__, - __monkeypatch_gradient_machine__, - __monkey_patch_protobuf_objects__, - __monkey_patch_parameter__, - __monkey_patch_trainer__] + patches = [ + __monkeypatch_init_paddle__, __monkeypatch_gradient_machine__, + __monkey_patch_protobuf_objects__, __monkey_patch_parameter__, + __monkey_patch_trainer__ + ] for patch in patches: patch() diff --git a/paddle/scripts/cluster_train/conf.py b/paddle/scripts/cluster_train/conf.py index f1114a59201b9e57a14b739a327b622327c515f7..c77d7584d3c89144761875b0fbc70369e355930a 100644 --- a/paddle/scripts/cluster_train/conf.py +++ b/paddle/scripts/cluster_train/conf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/scripts/cluster_train/paddle.py b/paddle/scripts/cluster_train/paddle.py index 7343a600c1bf5522ac8b0cd90a38f8a362ba7ae6..9b03ed1d8f6a28259a6cb45f096575b5f3d27ca7 100644 --- a/paddle/scripts/cluster_train/paddle.py +++ b/paddle/scripts/cluster_train/paddle.py @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/scripts/docker/Dockerfile b/paddle/scripts/docker/Dockerfile index 2a1a842336aa0409bba1315c77279ba2b018a4cd..207f97c4a69e6681702d3fe73475885d9b867ce9 100644 --- a/paddle/scripts/docker/Dockerfile +++ b/paddle/scripts/docker/Dockerfile @@ -1,16 +1,31 @@ FROM ubuntu:14.04 MAINTAINER PaddlePaddle Authors +ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update \ && apt-get install -y cmake libprotobuf-dev protobuf-compiler git \ - libgoogle-glog-dev libgflags-dev libatlas-dev libatlas3-base g++ m4 python-pip \ + libgoogle-glog-dev libgflags-dev libgtest-dev \ + libatlas-dev libatlas3-base g++ m4 python-pip \ python-protobuf python-numpy python-dev swig openssh-server \ wget unzip python-matplotlib tar xz-utils bzip2 gzip coreutils \ sed grep graphviz libjpeg-dev zlib1g-dev doxygen \ clang-3.8 llvm-3.8 libclang-3.8-dev \ && apt-get clean -y +RUN cd /usr/src/gtest && cmake . && make && cp *.a /usr/lib RUN pip install -U BeautifulSoup docopt PyYAML pillow \ - sphinx sphinx_rtd_theme breathe recommonmark + sphinx sphinx_rtd_theme recommonmark + +# cmake tends to hide and blur the dependencies between code modules, as +# noted here https://github.com/PaddlePaddle/Paddle/issues/763. We are +# thinking about using Bazel to fix this problem, e.g., +# https://github.com/PaddlePaddle/Paddle/issues/681#issuecomment-263996102. To +# start the trail of fixing, we add Bazel to our Dockerfiles. +RUN apt-get update && apt-get install -y curl software-properties-common \ + && add-apt-repository ppa:webupd8team/java \ + && echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | debconf-set-selections \ + && echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list \ + && curl https://bazel.build/bazel-release.pub.gpg | apt-key add - \ + && apt-get update && apt-get install -y oracle-java8-installer bazel ARG WITH_AVX ARG WITH_DOC diff --git a/paddle/scripts/docker/Dockerfile.gpu b/paddle/scripts/docker/Dockerfile.gpu index b3253d23c35811a68adc665df3d35998c09f9def..33f6adfea2a602c53beb4685e0bf3f87452e2d53 100644 --- a/paddle/scripts/docker/Dockerfile.gpu +++ b/paddle/scripts/docker/Dockerfile.gpu @@ -1,16 +1,31 @@ FROM nvidia/cuda:7.5-cudnn5-devel-ubuntu14.04 MAINTAINER PaddlePaddle Authors +ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update \ && apt-get install -y cmake libprotobuf-dev protobuf-compiler git \ - libgoogle-glog-dev libgflags-dev libatlas-dev libatlas3-base g++ m4 python-pip \ + libgoogle-glog-dev libgflags-dev libgtest-dev \ + libatlas-dev libatlas3-base g++ m4 python-pip \ python-protobuf python-numpy python-dev swig openssh-server \ wget unzip python-matplotlib tar xz-utils bzip2 gzip coreutils \ sed grep graphviz libjpeg-dev zlib1g-dev doxygen \ clang-3.8 llvm-3.8 libclang-3.8-dev \ && apt-get clean -y +RUN cd /usr/src/gtest && cmake . && make && cp *.a /usr/lib RUN pip install -U BeautifulSoup docopt PyYAML pillow \ - sphinx sphinx_rtd_theme breathe recommonmark + sphinx sphinx_rtd_theme recommonmark + +# cmake tends to hide and blur the dependencies between code modules, as +# noted here https://github.com/PaddlePaddle/Paddle/issues/763. We are +# thinking about using Bazel to fix this problem, e.g., +# https://github.com/PaddlePaddle/Paddle/issues/681#issuecomment-263996102. To +# start the trail of fixing, we add Bazel to our Dockerfiles. +RUN apt-get update && apt-get install -y curl software-properties-common \ + && add-apt-repository ppa:webupd8team/java \ + && echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | debconf-set-selections \ + && echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list \ + && curl https://bazel.build/bazel-release.pub.gpg | apt-key add - \ + && apt-get update && apt-get install -y oracle-java8-installer bazel ARG WITH_AVX ARG WITH_DOC diff --git a/paddle/scripts/tools/build_docs/Dockerfile b/paddle/scripts/tools/build_docs/Dockerfile index 506b13210ba1ee7277e2671870d79750cf63e900..78dc756bd1175019d90fc852635497fea1eb55e2 100644 --- a/paddle/scripts/tools/build_docs/Dockerfile +++ b/paddle/scripts/tools/build_docs/Dockerfile @@ -3,5 +3,5 @@ COPY build.sh / RUN pip install sphinx &&\ pip install sphinx_rtd_theme &&\ apt install -y doxygen graphviz &&\ - pip install breathe recommonmark numpy protobuf==2.6.1 + pip install recommonmark numpy protobuf==2.6.1 CMD /build.sh diff --git a/paddle/scripts/travis/docs.sh b/paddle/scripts/travis/docs.sh index c2a4809d75b97a9d8d8b83cf197e90bd62b48603..0bbb76a8a3caa27da0911af0fe87df7fbff617b4 100755 --- a/paddle/scripts/travis/docs.sh +++ b/paddle/scripts/travis/docs.sh @@ -47,17 +47,20 @@ if [ $? -eq 0 ]; then fi set -e -# Commit -git add . -git config user.name "Travis CI" -git config user.email "paddle-dev@baidu.com" -git commit -m "Deploy to GitHub Pages: ${SHA}" - -# Set ssh private key -openssl aes-256-cbc -K $SSL_KEY -iv $SSL_IV -in ../../paddle/scripts/travis/deploy_key.enc -out deploy_key -d -chmod 600 deploy_key -eval `ssh-agent -s` -ssh-add deploy_key - -# Push -git push $SSH_REPO $TARGET_BRANCH +if [ -n $SSL_KEY ]; then # Only push updated docs for github.com/PaddlePaddle/Paddle. + # Commit + git add . + git config user.name "Travis CI" + git config user.email "paddle-dev@baidu.com" + git commit -m "Deploy to GitHub Pages: ${SHA}" + + # Set ssh private key + openssl aes-256-cbc -K $SSL_KEY -iv $SSL_IV -in ../../paddle/scripts/travis/deploy_key.enc -out deploy_key -d + chmod 600 deploy_key + eval `ssh-agent -s` + ssh-add deploy_key + + # Push + git push $SSH_REPO $TARGET_BRANCH + +fi diff --git a/paddle/scripts/travis/main.sh b/paddle/scripts/travis/main.sh index c49d4546c24ac9304cd6f3c5940ed3d1d32ebb3d..13f2552d29db38041a73edca0acd202945c67484 100755 --- a/paddle/scripts/travis/main.sh +++ b/paddle/scripts/travis/main.sh @@ -5,6 +5,8 @@ if [ ${JOB} == "BUILD_AND_TEST" ]; then ./build_and_test.sh elif [ ${JOB} == "DOCS" ]; then ./docs.sh +elif [ ${JOB} == "PRE_COMMIT" ]; then + ./precommit.sh else echo Unknown job ${JOB} exit 1 diff --git a/paddle/scripts/travis/precommit.sh b/paddle/scripts/travis/precommit.sh new file mode 100755 index 0000000000000000000000000000000000000000..5ad84f1821646382818974d7de354d509fdc6ac7 --- /dev/null +++ b/paddle/scripts/travis/precommit.sh @@ -0,0 +1,17 @@ +#!/bin/bash +function abort(){ + echo "Your commit not fit PaddlePaddle code style" 1>&2 + echo "Please use pre-commit scripts to auto-format your code" 1>&2 + exit 1 +} + +trap 'abort' 0 +set -e +source common.sh +cd .. +export PATH=/usr/bin:$PATH +pre-commit install +clang-format --version +pre-commit run -a + +trap : 0 diff --git a/paddle/setup.py.in b/paddle/setup.py.in index 1a15eafd5528a68aa9a68ed020de6decb61bd2a7..b4c38a41b86683f89b6d02e9db97b75e9dca89ea 100644 --- a/paddle/setup.py.in +++ b/paddle/setup.py.in @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/trainer/MergeModel.cpp b/paddle/trainer/MergeModel.cpp index 1d15c66d4d09d047f4ede83b4ad23733d0175617..1cf29a39b92cc26fa6706f857edc1eb2dff29a21 100644 --- a/paddle/trainer/MergeModel.cpp +++ b/paddle/trainer/MergeModel.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,10 +14,10 @@ limitations under the License. */ #include -#include "paddle/utils/PythonUtil.h" -#include "paddle/pserver/ParameterServer2.h" #include "ParamUtil.h" #include "Trainer.h" +#include "paddle/pserver/ParameterServer2.h" +#include "paddle/utils/PythonUtil.h" P_DEFINE_string(model_dir, "", "Directory for separated model files"); P_DEFINE_string(model_file, "", "File for merged model file"); diff --git a/paddle/trainer/ParamUtil.cpp b/paddle/trainer/ParamUtil.cpp index 2be9cd62235a262812231579c536a5f0596b69d9..ffbca42e106591ddeb2cefcfafbeb408c544371b 100644 --- a/paddle/trainer/ParamUtil.cpp +++ b/paddle/trainer/ParamUtil.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -17,22 +17,22 @@ limitations under the License. */ #include #include -#include #include -#include +#include #include +#include #include #include +#include "paddle/utils/GlobalConstants.h" #include "paddle/utils/PythonUtil.h" #include "paddle/utils/Stat.h" #include "paddle/utils/Util.h" -#include "paddle/utils/GlobalConstants.h" +#include "TesterConfig.h" #include "paddle/gserver/gradientmachines/NeuralNetwork.h" #include "paddle/gserver/layers/ValidationLayer.h" -#include "TesterConfig.h" namespace paddle { diff --git a/paddle/trainer/ParamUtil.h b/paddle/trainer/ParamUtil.h index 3923941c3d1533621d89313aa09801e98cd5b8a9..2e05595848760c9abd7d916003656c8103151abf 100644 --- a/paddle/trainer/ParamUtil.h +++ b/paddle/trainer/ParamUtil.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -22,11 +22,11 @@ limitations under the License. */ #include "paddle/gserver/dataproviders/DataProvider.h" #include "paddle/gserver/gradientmachines/GradientMachine.h" +#include +#include +#include "ParameterUpdater.h" #include "TrainerConfig.pb.h" #include "TrainerConfigHelper.h" -#include "ParameterUpdater.h" -#include -#include namespace paddle { diff --git a/paddle/trainer/ParameterUpdater.cpp b/paddle/trainer/ParameterUpdater.cpp index 6001a0b391fb3425315de3194945a4d04aff7150..8b5b95da5b397aada6972d46db35fee8ca1a2ea4 100644 --- a/paddle/trainer/ParameterUpdater.cpp +++ b/paddle/trainer/ParameterUpdater.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/trainer/ParameterUpdater.h b/paddle/trainer/ParameterUpdater.h index b83b4cf55e27b25864499531bbfe483fb75f78a1..e52b5cd318b4d647a4bd126adf2ecfaba08d8363 100644 --- a/paddle/trainer/ParameterUpdater.h +++ b/paddle/trainer/ParameterUpdater.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -24,8 +24,8 @@ limitations under the License. */ #include "paddle/parameter/Parameter.h" #include "paddle/parameter/ParameterUpdaterBase.h" -#include "paddle/gserver/layers/Layer.h" #include "TrainerConfig.pb.h" +#include "paddle/gserver/layers/Layer.h" #include #include diff --git a/paddle/trainer/RemoteParameterUpdater.cpp b/paddle/trainer/RemoteParameterUpdater.cpp index d83bb5b10adeff2dc43ad4705e5c55d10856de0d..b7f7b93b8df091f7ccbe19a639295cba0554399a 100644 --- a/paddle/trainer/RemoteParameterUpdater.cpp +++ b/paddle/trainer/RemoteParameterUpdater.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,8 +14,8 @@ limitations under the License. */ #include "RemoteParameterUpdater.h" #include "Trainer.h" -#include "paddle/utils/Stat.h" #include "paddle/utils/GlobalConstants.h" +#include "paddle/utils/Stat.h" P_DECLARE_int32(trainer_id); P_DECLARE_string(save_dir); diff --git a/paddle/trainer/RemoteParameterUpdater.h b/paddle/trainer/RemoteParameterUpdater.h index a40884724cc7f963dc6ce5eede750327b2bbfed9..66055c778e439a1edf7d1b6dd2e13b945fa73323 100644 --- a/paddle/trainer/RemoteParameterUpdater.h +++ b/paddle/trainer/RemoteParameterUpdater.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,12 +14,12 @@ limitations under the License. */ #pragma once -#include #include -#include "paddle/pserver/ParameterClient2.h" +#include #include "ParameterUpdater.h" -#include "paddle/utils/Util.h" +#include "paddle/pserver/ParameterClient2.h" #include "paddle/utils/Queue.h" +#include "paddle/utils/Util.h" namespace paddle { diff --git a/paddle/trainer/Tester.cpp b/paddle/trainer/Tester.cpp index 6a5b7241a020941fad4321d8e271a1f23467b6ff..97d1b53934b65da05689126292d0e4deb99f9b4f 100644 --- a/paddle/trainer/Tester.cpp +++ b/paddle/trainer/Tester.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/trainer/Tester.h b/paddle/trainer/Tester.h index a9de9fe208c61c00fbeebe644222e255308e762b..e892744db278586f2fd5b3cb527aa7c17752c477 100644 --- a/paddle/trainer/Tester.h +++ b/paddle/trainer/Tester.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -24,12 +24,12 @@ limitations under the License. */ #include "TrainerConfig.pb.h" -#include "ParameterUpdater.h" +#include +#include #include "ParamUtil.h" +#include "ParameterUpdater.h" #include "TesterConfig.h" #include "TrainerInternalConfig.h" -#include -#include namespace paddle { diff --git a/paddle/trainer/TesterConfig.h b/paddle/trainer/TesterConfig.h index f490e5734415c0939fd925a6c7dd34c1e6d3a34f..68d4c931ff2df8e24acaa9fe6b35bfd613197c72 100644 --- a/paddle/trainer/TesterConfig.h +++ b/paddle/trainer/TesterConfig.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -23,9 +23,9 @@ limitations under the License. */ #include "TrainerConfig.pb.h" -#include "ParameterUpdater.h" -#include #include +#include +#include "ParameterUpdater.h" namespace paddle { diff --git a/paddle/trainer/ThreadParameterUpdater.cpp b/paddle/trainer/ThreadParameterUpdater.cpp index cc22851d8ecbf594df1e3f2c8aeaa98c07b3765b..bee7f061fed3a01e8292137272c3288334ef70c2 100644 --- a/paddle/trainer/ThreadParameterUpdater.cpp +++ b/paddle/trainer/ThreadParameterUpdater.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/trainer/ThreadParameterUpdater.h b/paddle/trainer/ThreadParameterUpdater.h index 5a5e3f1d4b3c1e915aa6ac01ff503c552e42de1a..d01ac689f97f360b64d4e63032a804f1f24c83e2 100644 --- a/paddle/trainer/ThreadParameterUpdater.h +++ b/paddle/trainer/ThreadParameterUpdater.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,13 +14,13 @@ limitations under the License. */ #pragma once -#include "paddle/utils/Util.h" #include "paddle/parameter/AverageOptimizer.h" #include "paddle/parameter/FirstOrderOptimizer.h" #include "paddle/parameter/OptimizerFunctions.h" #include "paddle/parameter/OptimizerWithRegularizer.h" #include "paddle/parameter/Parameter.h" #include "paddle/parameter/Regularizer.h" +#include "paddle/utils/Util.h" #include #include diff --git a/paddle/trainer/Trainer.cpp b/paddle/trainer/Trainer.cpp index 9c83c207ede99bddeeab5f56d90d357ee8b56edd..85610ec04e3f64dc83575426922ac936a604b3a7 100644 --- a/paddle/trainer/Trainer.cpp +++ b/paddle/trainer/Trainer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/trainer/Trainer.h b/paddle/trainer/Trainer.h index 899607c7c0f17ef2e91969f5ba1dcfa573518727..cabbb4acd1135f74aca0a4a36116db412c2e89f9 100644 --- a/paddle/trainer/Trainer.h +++ b/paddle/trainer/Trainer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -22,13 +22,13 @@ limitations under the License. */ #include "paddle/gserver/dataproviders/DataProvider.h" #include "paddle/gserver/gradientmachines/GradientMachine.h" -#include "TrainerConfigHelper.h" +#include +#include +#include "ParamUtil.h" #include "ParameterUpdater.h" -#include "TrainerInternal.h" #include "Tester.h" -#include "ParamUtil.h" -#include -#include +#include "TrainerConfigHelper.h" +#include "TrainerInternal.h" #ifdef PADDLE_METRIC_LEARNING #include "paddle/internals/metric_learning/MetricTrainer.h" diff --git a/paddle/trainer/TrainerBenchmark.cpp b/paddle/trainer/TrainerBenchmark.cpp index 54862e95b4a738b88dc256efbac9102fca383a4f..5c3177c8083e11ebf6b6854f86dbee8299d7e3b1 100644 --- a/paddle/trainer/TrainerBenchmark.cpp +++ b/paddle/trainer/TrainerBenchmark.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/trainer/TrainerConfigHelper.cpp b/paddle/trainer/TrainerConfigHelper.cpp index ee5b1e0a9c5a8faa6614d76ab938f1f1b8f4e73a..2017a08d20d494cbce8c3beba564ed07c1d7cc73 100644 --- a/paddle/trainer/TrainerConfigHelper.cpp +++ b/paddle/trainer/TrainerConfigHelper.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/trainer/TrainerConfigHelper.h b/paddle/trainer/TrainerConfigHelper.h index d20684964136a553b2d4119e8db5a1de084278bb..f1366cc041b0d983e65a1bf5b02ec2128324c5a8 100644 --- a/paddle/trainer/TrainerConfigHelper.h +++ b/paddle/trainer/TrainerConfigHelper.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,9 +14,9 @@ limitations under the License. */ #pragma once -#include #include #include +#include namespace paddle { diff --git a/paddle/trainer/TrainerInternal.cpp b/paddle/trainer/TrainerInternal.cpp index b1c3bf26d21d1760cd1710f372aa8a89fb7b101b..f3b465b444167d4624a5e99c30e1257eda53ca2c 100644 --- a/paddle/trainer/TrainerInternal.cpp +++ b/paddle/trainer/TrainerInternal.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -17,22 +17,22 @@ limitations under the License. */ #include #include -#include #include -#include +#include #include +#include #include +#include "paddle/gserver/gradientmachines/NeuralNetwork.h" +#include "paddle/gserver/layers/ValidationLayer.h" +#include "paddle/utils/GlobalConstants.h" #include "paddle/utils/PythonUtil.h" #include "paddle/utils/Stat.h" #include "paddle/utils/Util.h" -#include "paddle/utils/GlobalConstants.h" -#include "paddle/gserver/gradientmachines/NeuralNetwork.h" -#include "paddle/gserver/layers/ValidationLayer.h" -#include "ThreadParameterUpdater.h" #include "RemoteParameterUpdater.h" +#include "ThreadParameterUpdater.h" namespace paddle { diff --git a/paddle/trainer/TrainerInternal.h b/paddle/trainer/TrainerInternal.h index 962d53a30e5454060e8ce864c347c37b9cc98116..7018faab24744f7a087a53130acc56ec6314101e 100644 --- a/paddle/trainer/TrainerInternal.h +++ b/paddle/trainer/TrainerInternal.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -17,15 +17,15 @@ limitations under the License. */ #include "paddle/utils/Util.h" #include -#include #include +#include -#include "hl_gpu.h" -#include "paddle/gserver/gradientmachines/GradientMachine.h" -#include "TrainerConfig.pb.h" #include "ParameterUpdater.h" +#include "TrainerConfig.pb.h" #include "TrainerConfigHelper.h" #include "TrainerInternalConfig.h" +#include "hl_gpu.h" +#include "paddle/gserver/gradientmachines/GradientMachine.h" namespace paddle { diff --git a/paddle/trainer/TrainerInternalConfig.cpp b/paddle/trainer/TrainerInternalConfig.cpp index 0dc74cb3b39309b33a1a92dfa5a45e95defb4120..a017cdec9d06a51ddf0925280f3b60cc2dc1c17a 100644 --- a/paddle/trainer/TrainerInternalConfig.cpp +++ b/paddle/trainer/TrainerInternalConfig.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/trainer/TrainerInternalConfig.h b/paddle/trainer/TrainerInternalConfig.h index b7bfd29abd729b33ca953fb20835c57cbcf3ef74..b47692720efc2ed4f2db84f61ca81fcb52d234c0 100644 --- a/paddle/trainer/TrainerInternalConfig.h +++ b/paddle/trainer/TrainerInternalConfig.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -23,10 +23,10 @@ limitations under the License. */ #include "TrainerConfig.pb.h" -#include "ParameterUpdater.h" +#include #include #include -#include +#include "ParameterUpdater.h" namespace paddle { /** diff --git a/paddle/trainer/TrainerMain.cpp b/paddle/trainer/TrainerMain.cpp index e23e745d99c7b10fb780cb0c89e27207eefc19c1..0a4d56b892a2a6753f83105170ad3162da59264c 100644 --- a/paddle/trainer/TrainerMain.cpp +++ b/paddle/trainer/TrainerMain.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -13,10 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #include +#include "paddle/pserver/ParameterServer2.h" +#include "paddle/utils/Excepts.h" #include "paddle/utils/PythonUtil.h" #include "paddle/utils/StringUtil.h" -#include "paddle/utils/Excepts.h" -#include "paddle/pserver/ParameterServer2.h" #include "ParamUtil.h" #include "Trainer.h" diff --git a/paddle/trainer/tests/__init__.py b/paddle/trainer/tests/__init__.py index c90af2ee000d46a032984ee23559e7e99b49ddad..f662d6826321eb840739382558f76327d27b5847 100644 --- a/paddle/trainer/tests/__init__.py +++ b/paddle/trainer/tests/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/trainer/tests/chunking.conf b/paddle/trainer/tests/chunking.conf index 01c15fab5f7c0f51b8d4ca3296699c7b11e14a6e..d88df919df8fee9209336ffa29d724dabe6af31b 100644 --- a/paddle/trainer/tests/chunking.conf +++ b/paddle/trainer/tests/chunking.conf @@ -1,5 +1,5 @@ #edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/trainer/tests/config_parser_test.py b/paddle/trainer/tests/config_parser_test.py index c5ec315d6b01b0a5a3f73673e1756e9c06d685ba..db66ebb5b7c13fe53df14a07918aad62ba895ffa 100644 --- a/paddle/trainer/tests/config_parser_test.py +++ b/paddle/trainer/tests/config_parser_test.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/trainer/tests/gen_proto_data.py b/paddle/trainer/tests/gen_proto_data.py index a3dbc10c886e183582b44fee479d5ffb074193ef..8cc6d44673b9f992c28ae95cc06db5ea5aca0642 100644 --- a/paddle/trainer/tests/gen_proto_data.py +++ b/paddle/trainer/tests/gen_proto_data.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/trainer/tests/picojson.h b/paddle/trainer/tests/picojson.h index cb657d219e55c1e349ffb77a88945085b4149c78..23bfa164080a6ea392bb6ee15e7e2bec25257ce9 100644 --- a/paddle/trainer/tests/picojson.h +++ b/paddle/trainer/tests/picojson.h @@ -30,10 +30,10 @@ #define picojson_h #include +#include #include #include #include -#include #include #include #include diff --git a/paddle/trainer/tests/sample_trainer_config.conf b/paddle/trainer/tests/sample_trainer_config.conf index 15901065b226fad0e8a0b7ee92193c3157db3498..2697832840f35a33c07f1664ef18a229d656d784 100644 --- a/paddle/trainer/tests/sample_trainer_config.conf +++ b/paddle/trainer/tests/sample_trainer_config.conf @@ -1,5 +1,5 @@ #edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/trainer/tests/sample_trainer_config_hsigmoid.conf b/paddle/trainer/tests/sample_trainer_config_hsigmoid.conf index 174cb5e25f1c4d400869852599cb6b80ecbda033..e4abe31d480b69bc2ff4741649b336714818515b 100644 --- a/paddle/trainer/tests/sample_trainer_config_hsigmoid.conf +++ b/paddle/trainer/tests/sample_trainer_config_hsigmoid.conf @@ -1,5 +1,5 @@ #edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/trainer/tests/sample_trainer_config_opt_a.conf b/paddle/trainer/tests/sample_trainer_config_opt_a.conf index f5b1988ddaf5fba486d35b90cf4c267d209ce290..b1744db8d604c88ec47e7104f79b38bb9d0e4442 100644 --- a/paddle/trainer/tests/sample_trainer_config_opt_a.conf +++ b/paddle/trainer/tests/sample_trainer_config_opt_a.conf @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/trainer/tests/sample_trainer_config_opt_b.conf b/paddle/trainer/tests/sample_trainer_config_opt_b.conf index f5b1988ddaf5fba486d35b90cf4c267d209ce290..b1744db8d604c88ec47e7104f79b38bb9d0e4442 100644 --- a/paddle/trainer/tests/sample_trainer_config_opt_b.conf +++ b/paddle/trainer/tests/sample_trainer_config_opt_b.conf @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/trainer/tests/sample_trainer_config_parallel.conf b/paddle/trainer/tests/sample_trainer_config_parallel.conf index e35a1f26dad2f81f70fe31f9f8c921606ea8461b..e2b8b3ecdab83b4614dbe468c3a295c05867f7f9 100644 --- a/paddle/trainer/tests/sample_trainer_config_parallel.conf +++ b/paddle/trainer/tests/sample_trainer_config_parallel.conf @@ -1,5 +1,5 @@ #edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/trainer/tests/sample_trainer_config_qb_rnn.conf b/paddle/trainer/tests/sample_trainer_config_qb_rnn.conf index d254cc5700abfba652b6e969201272ad7d422b7a..d19222360c2f424ddb306b155dfef07921098a6b 100644 --- a/paddle/trainer/tests/sample_trainer_config_qb_rnn.conf +++ b/paddle/trainer/tests/sample_trainer_config_qb_rnn.conf @@ -1,5 +1,5 @@ #edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/trainer/tests/sample_trainer_config_rnn.conf b/paddle/trainer/tests/sample_trainer_config_rnn.conf index cbb666302943021e31a65715c619202aafd8ce70..b720d4d5a6ca59e207832a8c5410c2cb6074c439 100644 --- a/paddle/trainer/tests/sample_trainer_config_rnn.conf +++ b/paddle/trainer/tests/sample_trainer_config_rnn.conf @@ -1,5 +1,5 @@ #edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/trainer/tests/sample_trainer_nest_rnn_gen.conf b/paddle/trainer/tests/sample_trainer_nest_rnn_gen.conf index 613fd325e10fb742ec18d1451e49da975fcfce18..d669fbc40cbc19df309d8bf20c942a9d8fc8f47d 100644 --- a/paddle/trainer/tests/sample_trainer_nest_rnn_gen.conf +++ b/paddle/trainer/tests/sample_trainer_nest_rnn_gen.conf @@ -1,5 +1,5 @@ #edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/trainer/tests/sample_trainer_rnn_gen.conf b/paddle/trainer/tests/sample_trainer_rnn_gen.conf index ec1c12cc896fb7868ea906447378966821dd3e93..2b337282f6285afb527e9bbf138d2e8184700d8d 100644 --- a/paddle/trainer/tests/sample_trainer_rnn_gen.conf +++ b/paddle/trainer/tests/sample_trainer_rnn_gen.conf @@ -1,5 +1,5 @@ #edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/trainer/tests/testPyDataWrapper.py b/paddle/trainer/tests/testPyDataWrapper.py index 4607bec24e1fec6f8b9996eb32fe991dbbe3ed79..2c29a274339747b78fbd6c27ae4070f0abbd4028 100644 --- a/paddle/trainer/tests/testPyDataWrapper.py +++ b/paddle/trainer/tests/testPyDataWrapper.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/trainer/tests/test_Compare.cpp b/paddle/trainer/tests/test_Compare.cpp index 03312f9e470e0f8b01e229237d25a7ac8e088c5c..63fa48540cca81f6b463b50c4af9ea3259a7301d 100644 --- a/paddle/trainer/tests/test_Compare.cpp +++ b/paddle/trainer/tests/test_Compare.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -16,8 +16,8 @@ limitations under the License. */ #include "paddle/trainer/Trainer.h" -#include #include +#include using namespace paddle; // NOLINT using namespace std; // NOLINT diff --git a/paddle/trainer/tests/test_CompareSparse.cpp b/paddle/trainer/tests/test_CompareSparse.cpp index a7c6862ce3362556fa60cc3309445347476e7f33..3fea3a3c24303b84f78f4029b0ed8e42e419c442 100644 --- a/paddle/trainer/tests/test_CompareSparse.cpp +++ b/paddle/trainer/tests/test_CompareSparse.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/trainer/tests/test_CompareTwoNets.cpp b/paddle/trainer/tests/test_CompareTwoNets.cpp index 81320da6ac9c6e880b936a6b1e2650796bb50ff7..8a4556721dda3f73fb11b36e5fdf798df3993ce8 100644 --- a/paddle/trainer/tests/test_CompareTwoNets.cpp +++ b/paddle/trainer/tests/test_CompareTwoNets.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,10 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include #include -#include #include -#include +#include #include "paddle/trainer/Trainer.h" diff --git a/paddle/trainer/tests/test_CompareTwoOpts.cpp b/paddle/trainer/tests/test_CompareTwoOpts.cpp index a52f2fa7e7708925dbcb173167b17bbfef93a4da..673ef289d8f5bfc0f1d6db58eb7d4e7ecba31ae3 100644 --- a/paddle/trainer/tests/test_CompareTwoOpts.cpp +++ b/paddle/trainer/tests/test_CompareTwoOpts.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,10 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include #include -#include #include -#include +#include #include "paddle/trainer/Trainer.h" diff --git a/paddle/trainer/tests/test_Prediction.cpp b/paddle/trainer/tests/test_Prediction.cpp index 6db33439b319e84e99e828246ca672fa8274e4bf..322121a579440fcf164c042b3265e5d2878e3732 100644 --- a/paddle/trainer/tests/test_Prediction.cpp +++ b/paddle/trainer/tests/test_Prediction.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/trainer/tests/test_PyDataProviderWrapper.cpp b/paddle/trainer/tests/test_PyDataProviderWrapper.cpp index e53291386c6b553e26248dae75e321d4b7246823..66ec65e340a435a7260028611828fb28845e0728 100644 --- a/paddle/trainer/tests/test_PyDataProviderWrapper.cpp +++ b/paddle/trainer/tests/test_PyDataProviderWrapper.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -13,16 +13,16 @@ See the License for the specific language governing permissions and limitations under the License. */ #ifndef PADDLE_NO_PYTHON +#include #include -#include #include -#include #include #include +#include +#include +#include #include #include -#include -#include #include "picojson.h" void checkEqual(const paddle::Argument& expect, const paddle::Argument& actual); diff --git a/paddle/trainer/tests/test_Trainer.cpp b/paddle/trainer/tests/test_Trainer.cpp index 900c05af851aede67253535228d75d211dee6a85..0fede59f8d8d62edcdb2d030952d0e738452160a 100644 --- a/paddle/trainer/tests/test_Trainer.cpp +++ b/paddle/trainer/tests/test_Trainer.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/trainer/tests/test_TrainerOnePass.cpp b/paddle/trainer/tests/test_TrainerOnePass.cpp index da2954d1664fc18cb78e6217807ff9799d220f7f..0b587ecce176d5b6e8e6e6c4a54cb21fc4e25a67 100644 --- a/paddle/trainer/tests/test_TrainerOnePass.cpp +++ b/paddle/trainer/tests/test_TrainerOnePass.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include #include +#include #include "paddle/trainer/Trainer.h" #include "paddle/trainer/TrainerInternal.h" diff --git a/paddle/trainer/tests/test_config.conf b/paddle/trainer/tests/test_config.conf index 2a4548896ffe0770f48b6c375c41eaf452b19366..d1bb9b877fe26702948586dbe90b9ff0ee27c1d6 100644 --- a/paddle/trainer/tests/test_config.conf +++ b/paddle/trainer/tests/test_config.conf @@ -1,5 +1,5 @@ #edit-mode: -*- python -*- -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/paddle/trainer/tests/test_recurrent_machine_generation.cpp b/paddle/trainer/tests/test_recurrent_machine_generation.cpp index 49e8a97ad057246addf29274dd9c436d1481de91..7d8dfd788fd6a336379a96ea5324b8e6f60705ea 100644 --- a/paddle/trainer/tests/test_recurrent_machine_generation.cpp +++ b/paddle/trainer/tests/test_recurrent_machine_generation.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,8 +14,8 @@ limitations under the License. */ #include -#include #include +#include #include diff --git a/paddle/utils/BarrierStat.cpp b/paddle/utils/BarrierStat.cpp index 82c5b84e5960753d5ec4c35bd667a8e43269e9e1..9dde155aca0ec67cca7a0fb8ba9bce4732ffbfa7 100644 --- a/paddle/utils/BarrierStat.cpp +++ b/paddle/utils/BarrierStat.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,13 +12,13 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/utils/BarrierStat.h" +#include #include -#include #include -#include -#include "paddle/utils/Stat.h" -#include "paddle/utils/BarrierStat.h" +#include #include "paddle/utils/Flags.h" +#include "paddle/utils/Stat.h" P_DEFINE_bool(log_barrier_abstract, true, diff --git a/paddle/utils/BarrierStat.h b/paddle/utils/BarrierStat.h index 661340ad275365ab567175d4280abdab18444fac..a9c925eff66838d58d540d7be5476e6207a30bec 100644 --- a/paddle/utils/BarrierStat.h +++ b/paddle/utils/BarrierStat.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -15,18 +15,17 @@ limitations under the License. */ #pragma once #include -#include #include -#include #include +#include +#include #include +#include #include -#include -#include "Logging.h" #include "Locks.h" +#include "Logging.h" #include "ThreadLocal.h" -#include "Stat.h" namespace paddle { diff --git a/paddle/utils/ClassRegistrar.h b/paddle/utils/ClassRegistrar.h index ee58ccb2ad42ac9e5380e3a80fe0044965eab083..1ac27bafabd1945d1d01e3bead22b0dd200d8688 100644 --- a/paddle/utils/ClassRegistrar.h +++ b/paddle/utils/ClassRegistrar.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/utils/CommandLineParser.cpp b/paddle/utils/CommandLineParser.cpp index 307e304bb03d79fa9a640ece9c84845919b0d9c4..51558b45a143c87be1524cabc0b8a98e8f8bc997 100644 --- a/paddle/utils/CommandLineParser.cpp +++ b/paddle/utils/CommandLineParser.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,15 +14,15 @@ limitations under the License. */ #include "CommandLineParser.h" #ifndef PADDLE_USE_GFLAGS -#include "paddle/utils/StringUtil.h" +#include #include -#include #include -#include +#include #include -#include -#include #include +#include +#include +#include "paddle/utils/StringUtil.h" namespace paddle { @@ -46,16 +46,13 @@ template <> bool StringToValue(const std::string& content, bool* value) { std::string tmp = content; - std::transform(tmp.begin(), - tmp.end(), - tmp.begin(), - [](char in) -> char { - if (in <= 'Z' && in >= 'A') { - return in - ('Z' - 'z'); - } else { - return in; - } - }); // tolower. + std::transform(tmp.begin(), tmp.end(), tmp.begin(), [](char in) -> char { + if (in <= 'Z' && in >= 'A') { + return in - ('Z' - 'z'); + } else { + return in; + } + }); // tolower. if (tmp == "true" || tmp == "1") { *value = true; diff --git a/paddle/utils/CommandLineParser.h b/paddle/utils/CommandLineParser.h index c46567913e253bdda645f129449773040c0ec93d..b4449c6f095f101847c029e02fb0cb087f12f754 100644 --- a/paddle/utils/CommandLineParser.h +++ b/paddle/utils/CommandLineParser.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,10 +14,10 @@ limitations under the License. */ #pragma once #ifndef PADDLE_USE_GFLAGS -#include "DisableCopy.h" +#include #include #include -#include +#include "DisableCopy.h" namespace paddle { diff --git a/paddle/utils/CompilerMacros.h b/paddle/utils/CompilerMacros.h index 4236d750c4d8bf722fdf3e371dc95b2d9aa8223d..e50093f7fcf19744cfa11d6fee1611c2bcba6b64 100644 --- a/paddle/utils/CompilerMacros.h +++ b/paddle/utils/CompilerMacros.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/utils/CpuId.cpp b/paddle/utils/CpuId.cpp index 815e0316b1a951e5ad7d950438a2cfd82a251f5d..8eefdd2980e7f56a836df6fd2ff8c31b81a55555 100644 --- a/paddle/utils/CpuId.cpp +++ b/paddle/utils/CpuId.cpp @@ -17,47 +17,45 @@ limitations under the License. */ #include /// for MSVC -#define CPUID(info, x) __cpuidex(info, x, 0) +#define CPUID(info, x) __cpuidex(info, x, 0) #else #include /// for GCC/Clang -#define CPUID(info, x) __cpuid_count(x, 0, info[0], info[1], info[2], info[3]) +#define CPUID(info, x) __cpuid_count(x, 0, info[0], info[1], info[2], info[3]) #endif namespace paddle { SIMDFlags::SIMDFlags() { - unsigned int cpuInfo[4]; - // CPUID: https://en.wikipedia.org/wiki/CPUID - CPUID(cpuInfo, 0x00000001); - simd_flags_ |= cpuInfo[3] & (1 << 25) ? SIMD_SSE : SIMD_NONE; - simd_flags_ |= cpuInfo[3] & (1 << 26) ? SIMD_SSE2 : SIMD_NONE; - simd_flags_ |= cpuInfo[2] & (1 << 0) ? SIMD_SSE3 : SIMD_NONE; - simd_flags_ |= cpuInfo[2] & (1 << 9) ? SIMD_SSSE3 : SIMD_NONE; - simd_flags_ |= cpuInfo[2] & (1 << 19) ? SIMD_SSE41 : SIMD_NONE; - simd_flags_ |= cpuInfo[2] & (1 << 20) ? SIMD_SSE42 : SIMD_NONE; - simd_flags_ |= cpuInfo[2] & (1 << 12) ? SIMD_FMA3 : SIMD_NONE; - simd_flags_ |= cpuInfo[2] & (1 << 28) ? SIMD_AVX : SIMD_NONE; - - CPUID(cpuInfo, 0x00000007); - simd_flags_ |= cpuInfo[1] & (1 << 5) ? SIMD_AVX2 : SIMD_NONE; - simd_flags_ |= cpuInfo[1] & (1 << 16) ? SIMD_AVX512: SIMD_NONE; - - CPUID(cpuInfo, 0x80000001); - simd_flags_ |= cpuInfo[2] & (1 << 16) ? SIMD_FMA4 : SIMD_NONE; -} - -bool SIMDFlags::check(int flags) const { - return (simd_flags_ & flags) == flags; + unsigned int cpuInfo[4]; + // CPUID: https://en.wikipedia.org/wiki/CPUID + // clang-format off + CPUID(cpuInfo, 0x00000001); + simd_flags_ |= cpuInfo[3] & (1 << 25) ? SIMD_SSE : SIMD_NONE; + simd_flags_ |= cpuInfo[3] & (1 << 26) ? SIMD_SSE2 : SIMD_NONE; + simd_flags_ |= cpuInfo[2] & (1 << 0) ? SIMD_SSE3 : SIMD_NONE; + simd_flags_ |= cpuInfo[2] & (1 << 9) ? SIMD_SSSE3 : SIMD_NONE; + simd_flags_ |= cpuInfo[2] & (1 << 19) ? SIMD_SSE41 : SIMD_NONE; + simd_flags_ |= cpuInfo[2] & (1 << 20) ? SIMD_SSE42 : SIMD_NONE; + simd_flags_ |= cpuInfo[2] & (1 << 12) ? SIMD_FMA3 : SIMD_NONE; + simd_flags_ |= cpuInfo[2] & (1 << 28) ? SIMD_AVX : SIMD_NONE; + + CPUID(cpuInfo, 0x00000007); + simd_flags_ |= cpuInfo[1] & (1 << 5) ? SIMD_AVX2 : SIMD_NONE; + simd_flags_ |= cpuInfo[1] & (1 << 16) ? SIMD_AVX512: SIMD_NONE; + + CPUID(cpuInfo, 0x80000001); + simd_flags_ |= cpuInfo[2] & (1 << 16) ? SIMD_FMA4 : SIMD_NONE; + // clang-fotmat on } SIMDFlags const* SIMDFlags::instance() { - static SIMDFlags instance; - return &instance; + static SIMDFlags instance; + return &instance; } -} // namespace paddle +} // namespace paddle diff --git a/paddle/utils/CpuId.h b/paddle/utils/CpuId.h index a1ef7e48e6d35079d7ae373d6e4d0837fa5dc707..7a354da75851ed7cca4e85e77714624634951f00 100644 --- a/paddle/utils/CpuId.h +++ b/paddle/utils/CpuId.h @@ -15,31 +15,37 @@ limitations under the License. */ namespace paddle { +// clang-format off enum simd_t { - SIMD_NONE = 0, ///< None - SIMD_SSE = 1 << 0, ///< SSE - SIMD_SSE2 = 1 << 1, ///< SSE 2 - SIMD_SSE3 = 1 << 2, ///< SSE 3 - SIMD_SSSE3 = 1 << 3, ///< SSSE 3 - SIMD_SSE41 = 1 << 4, ///< SSE 4.1 - SIMD_SSE42 = 1 << 5, ///< SSE 4.2 - SIMD_FMA3 = 1 << 6, ///< FMA 3 - SIMD_FMA4 = 1 << 7, ///< FMA 4 - SIMD_AVX = 1 << 8, ///< AVX - SIMD_AVX2 = 1 << 9, ///< AVX 2 - SIMD_AVX512 = 1 << 10, ///< AVX 512 + SIMD_NONE = 0, ///< None + SIMD_SSE = 1 << 0, ///< SSE + SIMD_SSE2 = 1 << 1, ///< SSE 2 + SIMD_SSE3 = 1 << 2, ///< SSE 3 + SIMD_SSSE3 = 1 << 3, ///< SSSE 3 + SIMD_SSE41 = 1 << 4, ///< SSE 4.1 + SIMD_SSE42 = 1 << 5, ///< SSE 4.2 + SIMD_FMA3 = 1 << 6, ///< FMA 3 + SIMD_FMA4 = 1 << 7, ///< FMA 4 + SIMD_AVX = 1 << 8, ///< AVX + SIMD_AVX2 = 1 << 9, ///< AVX 2 + SIMD_AVX512 = 1 << 10, ///< AVX 512 }; +// clang-format on class SIMDFlags final { public: - DISABLE_COPY(SIMDFlags); - SIMDFlags(); + DISABLE_COPY(SIMDFlags); - static SIMDFlags const* instance(); - bool check(int flags) const; + SIMDFlags(); + + static SIMDFlags const* instance(); + + inline bool check(int flags) const { + return !((simd_flags_ & flags) ^ flags); + } private: - int simd_flags_ = SIMD_NONE; + int simd_flags_ = SIMD_NONE; }; /** @@ -49,31 +55,46 @@ private: * @code{.cpp} * * if (HAS_SIMD(SIMD_AVX2 | SIMD_FMA4)) { - * avx2_fm4_stub(); + * avx2_fm4_stub(); * } else if (HAS_SIMD(SIMD_AVX)) { - * avx_stub(); + * avx_stub(); * } * * @endcode */ -#define HAS_SIMD(__flags) SIMDFlags::instance()->check(__flags) +#define HAS_SIMD(__flags) SIMDFlags::instance()->check(__flags) /** * @brief Check SIMD flags at runtime. * - * 1. Check all SIMD flags at runtime: HAS_SSE && HAS_SSE2 && HAS_SSE3 - * 2. Check one SIMD flags at runtime: HAS_SSE || HAS_SSE2 || HAS_SSE3 + * 1. Check all SIMD flags at runtime: + * + * @code{.cpp} + * if (HAS_AVX && HAS_AVX2) { + * avx2_stub(); + * } + * @endcod + * + * 2. Check one SIMD flag at runtime: + * + * @code{.cpp} + * if (HAS_SSE41 || HAS_SSE42) { + * sse4_stub(); + * } + * @endcode */ -#define HAS_SSE HAS_SIMD(SIMD_SSE) -#define HAS_SSE2 HAS_SIMD(SIMD_SSE2) -#define HAS_SSE3 HAS_SIMD(SIMD_SSE3) -#define HAS_SSSE3 HAS_SIMD(SIMD_SSSE3) -#define HAS_SSE41 HAS_SIMD(SIMD_SSE41) -#define HAS_SSE42 HAS_SIMD(SIMD_SSE42) -#define HAS_FMA3 HAS_SIMD(SIMD_FMA3) -#define HAS_FMA4 HAS_SIMD(SIMD_FMA4) -#define HAS_AVX HAS_SIMD(SIMD_AVX) -#define HAS_AVX2 HAS_SIMD(SIMD_AVX2) -#define HAS_AVX512 HAS_SIMD(SIMD_AVX512) +// clang-format off +#define HAS_SSE HAS_SIMD(SIMD_SSE) +#define HAS_SSE2 HAS_SIMD(SIMD_SSE2) +#define HAS_SSE3 HAS_SIMD(SIMD_SSE3) +#define HAS_SSSE3 HAS_SIMD(SIMD_SSSE3) +#define HAS_SSE41 HAS_SIMD(SIMD_SSE41) +#define HAS_SSE42 HAS_SIMD(SIMD_SSE42) +#define HAS_FMA3 HAS_SIMD(SIMD_FMA3) +#define HAS_FMA4 HAS_SIMD(SIMD_FMA4) +#define HAS_AVX HAS_SIMD(SIMD_AVX) +#define HAS_AVX2 HAS_SIMD(SIMD_AVX2) +#define HAS_AVX512 HAS_SIMD(SIMD_AVX512) +// clang-format on -} // namespace paddle +} // namespace paddle diff --git a/paddle/utils/CustomStackTrace.cpp b/paddle/utils/CustomStackTrace.cpp index 8740fe662ea21ce93c7c0d9505cdeb75975b3020..083f5c509a26cd06d6fc6cea2a7587c7ef57d4e6 100644 --- a/paddle/utils/CustomStackTrace.cpp +++ b/paddle/utils/CustomStackTrace.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -13,8 +13,8 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "CustomStackTrace.h" -#include "CommandLineParser.h" #include +#include "CommandLineParser.h" P_DEFINE_bool( layer_stack_error_only_current_thread, diff --git a/paddle/utils/CustomStackTrace.h b/paddle/utils/CustomStackTrace.h index 878e14eb5fcf870bf6c29758a1b9a297c13ce730..6992e856223494d6575ef3261d82cbdf4e375885 100644 --- a/paddle/utils/CustomStackTrace.h +++ b/paddle/utils/CustomStackTrace.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,10 +14,10 @@ limitations under the License. */ #pragma once +#include #include #include #include -#include #include "ThreadLocal.h" @@ -96,7 +96,8 @@ public: */ typedef std::function DumpCallback; + const T& /*item*/)> + DumpCallback; /** * Dump all thread stack, and all stack will be cleared. diff --git a/paddle/utils/DisableCopy.h b/paddle/utils/DisableCopy.h index e991c07cdf68dac2bdf7fd66de03a292a3bec3c8..41de98bbde664651803c8db4c0cd7216b2ff4231 100644 --- a/paddle/utils/DisableCopy.h +++ b/paddle/utils/DisableCopy.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/utils/Excepts.cpp b/paddle/utils/Excepts.cpp index b2fad3ac9dd6477e388185d95ebd49c8f0da4c84..4ddce35ed31a8fed3f25cb3b03348b4eda8fcfdd 100644 --- a/paddle/utils/Excepts.cpp +++ b/paddle/utils/Excepts.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/utils/Excepts.h b/paddle/utils/Excepts.h index a84a2d33a6a3d0664218151befd6b2af44f72a97..dc3369b7e8c27cf53a03ce56b18a123f291d2d6d 100644 --- a/paddle/utils/Excepts.h +++ b/paddle/utils/Excepts.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/utils/Flags.cpp b/paddle/utils/Flags.cpp index 6fae24e1b58c5296019cfaefe97905c3e8632210..1c9e602f45a818824a34aca23ef8f52a5e14cd17 100644 --- a/paddle/utils/Flags.cpp +++ b/paddle/utils/Flags.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/utils/Flags.h b/paddle/utils/Flags.h index dda60c3f965abd8575677c785b21b058b3400ee5..922533d63e7f0c28a1dcec6b4d9f453f1794abb5 100644 --- a/paddle/utils/Flags.h +++ b/paddle/utils/Flags.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/utils/GlobalConstants.cpp b/paddle/utils/GlobalConstants.cpp index d769cd1ee7d4403f9fddbe91d2afec2c986d6b18..9e8dade0b228eb642a965eaa5bfe0653fe2749de 100644 --- a/paddle/utils/GlobalConstants.cpp +++ b/paddle/utils/GlobalConstants.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/utils/GlobalConstants.h b/paddle/utils/GlobalConstants.h index 4c74c17a50c8cdbc18a075a58f97efc6b3330deb..707346f2c76e59b50722f4f8805ebe56c3cf861b 100644 --- a/paddle/utils/GlobalConstants.h +++ b/paddle/utils/GlobalConstants.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/utils/Locks.h b/paddle/utils/Locks.h index 5990e1657021611437e8fe730147dfaf207c800d..0f922f3548d97eb16ca897564faf1bf083f0d5ac 100644 --- a/paddle/utils/Locks.h +++ b/paddle/utils/Locks.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/utils/Logging.cpp b/paddle/utils/Logging.cpp index 14303bd4c747db2c10ee24b1601f709a79174850..20f32466a56ac4c67c16dfbea229bc78f9f4f6d9 100644 --- a/paddle/utils/Logging.cpp +++ b/paddle/utils/Logging.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -22,13 +22,13 @@ limitations under the License. */ #include #include #include -#include -#include #include +#include +#include -#include -#include #include +#include +#include #include namespace paddle { diff --git a/paddle/utils/Logging.h b/paddle/utils/Logging.h index e9029b421fa3b68845a54194f4cfa69439a99a0c..4379289f6d1b4b5a1006bd723c2177a686ed89f6 100644 --- a/paddle/utils/Logging.h +++ b/paddle/utils/Logging.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ limitations under the License. */ */ #pragma once -#include #include +#include #include #ifndef PADDLE_USE_GLOG diff --git a/paddle/utils/PythonUtil.cpp b/paddle/utils/PythonUtil.cpp index 7f17a825228ef56be7b8678bf003e57388d4b0bf..2ee4e4fb7ed0e2519d5e7182d6f3adc3431b493a 100644 --- a/paddle/utils/PythonUtil.cpp +++ b/paddle/utils/PythonUtil.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -13,8 +13,8 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "PythonUtil.h" -#include #include +#include namespace paddle { diff --git a/paddle/utils/PythonUtil.h b/paddle/utils/PythonUtil.h index 65677d90101a0ee2e62c8ac45c50b88326e169e1..daebaffc855518425ae43942c22ec150d2e327f0 100644 --- a/paddle/utils/PythonUtil.h +++ b/paddle/utils/PythonUtil.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -13,6 +13,8 @@ See the License for the specific language governing permissions and limitations under the License. */ #pragma once +// clang-format off +#include "paddle/utils/Util.h" #ifndef PADDLE_NO_PYTHON // must include the following two blocks, otherwise, @@ -33,13 +35,12 @@ limitations under the License. */ #endif #include #include - #endif -#include "paddle/utils/Util.h" #include -#include #include +#include +// clang-format on namespace paddle { diff --git a/paddle/utils/Queue.h b/paddle/utils/Queue.h index 58d17e86c432b90a6b3240dd5528146a24b72184..f054738f87c02d2d749eec8d6c7bb55b506a6d91 100644 --- a/paddle/utils/Queue.h +++ b/paddle/utils/Queue.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -142,9 +142,9 @@ public: */ bool waitNotEmptyFor(int seconds) { std::unique_lock lock(queueLock_); - return queueCV_.wait_for(lock, - std::chrono::seconds(seconds), - [this] { return numElements_ != 0; }); + return queueCV_.wait_for(lock, std::chrono::seconds(seconds), [this] { + return numElements_ != 0; + }); } private: diff --git a/paddle/utils/Stat.cpp b/paddle/utils/Stat.cpp index ab140c33502ad315d087bb3afc7f39bffc122894..44acee249554e41f715314a3cd7eef29e3e6c5b0 100644 --- a/paddle/utils/Stat.cpp +++ b/paddle/utils/Stat.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -13,9 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "Stat.h" -#include "Util.h" -#include #include +#include +#include "Util.h" namespace paddle { @@ -207,10 +207,9 @@ static unsigned g_profileCount = 0; static std::recursive_mutex g_profileMutex; GpuProfiler::GpuProfiler(std::string statName, std::string info) - : guard_(g_profileMutex) { + : guard_(g_profileMutex) { if (++g_profileCount == 1) { - LOG(INFO) << "Enable GPU Profiler Stat: [" - << statName << "] " << info; + LOG(INFO) << "Enable GPU Profiler Stat: [" << statName << "] " << info; hl_profiler_start(); } } diff --git a/paddle/utils/Stat.h b/paddle/utils/Stat.h index 1ef688ea8da53ee0cd51b1775e671f2b10be782b..9be79e8859a3b4cff4c834ee698902706f947712 100644 --- a/paddle/utils/Stat.h +++ b/paddle/utils/Stat.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/utils/StringUtil.cpp b/paddle/utils/StringUtil.cpp index b416cda4af1572d76cdd9a7144e05b790eedf22a..0c98e6db34530ae40a7245768051b8ce8aa69202 100644 --- a/paddle/utils/StringUtil.cpp +++ b/paddle/utils/StringUtil.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/utils/StringUtil.h b/paddle/utils/StringUtil.h index 8b44dad19231781623a0a65d02b24ac1cf9e4523..0b4f4c9113ae9d714b634b67931e51b408bbe777 100644 --- a/paddle/utils/StringUtil.h +++ b/paddle/utils/StringUtil.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,9 +14,9 @@ limitations under the License. */ #pragma once +#include #include #include -#include #include "Logging.h" namespace paddle { diff --git a/paddle/utils/Thread.h b/paddle/utils/Thread.h index ade0ee496f94f6165f35dd1a0a37618df8fae585..ef36a8c5b2b0e95d759da8a781d781b71d067b7a 100644 --- a/paddle/utils/Thread.h +++ b/paddle/utils/Thread.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -13,9 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #pragma once -#include "Util.h" -#include "Logging.h" #include +#include "Logging.h" +#include "Util.h" #include "Queue.h" #include "ThreadLocal.h" diff --git a/paddle/utils/ThreadLocal.cpp b/paddle/utils/ThreadLocal.cpp index 49d4b1526537def9b8183934faa971402f3678aa..8a2878fc4bafb803a8c4b99ceccfc77405a0a3a0 100644 --- a/paddle/utils/ThreadLocal.cpp +++ b/paddle/utils/ThreadLocal.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "Util.h" #include "ThreadLocal.h" #include "CommandLineParser.h" +#include "Util.h" P_DEFINE_bool(thread_local_rand_use_global_seed, false, diff --git a/paddle/utils/ThreadLocal.h b/paddle/utils/ThreadLocal.h index 06c8b392af23f81ab48042cb4d24a40b1c50275d..a4987c9ec261a2ee57e62d1640e2a21c7f804c99 100644 --- a/paddle/utils/ThreadLocal.h +++ b/paddle/utils/ThreadLocal.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -15,14 +15,14 @@ limitations under the License. */ #pragma once #include -#include #include +#include #include #include #include #include -#include "Util.h" #include "Logging.h" +#include "Util.h" namespace paddle { diff --git a/paddle/utils/TypeDefs.h b/paddle/utils/TypeDefs.h index e8be779bea255eec71057495d1253ed92c2256c3..c50a05e82daefd1273c896f3603957f4484ecd5d 100644 --- a/paddle/utils/TypeDefs.h +++ b/paddle/utils/TypeDefs.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/utils/Util.cpp b/paddle/utils/Util.cpp index bc727cfa74cdfb51b36259bd08733804578f6d66..26ff385c84564d1188120464f94f418d88c20f19 100644 --- a/paddle/utils/Util.cpp +++ b/paddle/utils/Util.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -15,11 +15,11 @@ limitations under the License. */ #include "Util.h" #include +#include #include #include #include #include -#include #include #include @@ -28,10 +28,10 @@ limitations under the License. */ #include "CommandLineParser.h" #include "CustomStackTrace.h" +#include "StringUtil.h" #include "Thread.h" #include "ThreadLocal.h" #include "Version.h" -#include "StringUtil.h" P_DEFINE_int32(seed, 1, "random number seed. 0 for srand(time)"); @@ -126,25 +126,23 @@ void registerInitFunction(std::function func, int priority) { } void runInitFunctions() { - std::call_once( - g_onceFlag, - []() { - LOG(INFO) << "Calling runInitFunctions"; - if (g_initFuncs) { - std::sort(g_initFuncs->begin(), - g_initFuncs->end(), - [](const PriorityFuncPair& x, const PriorityFuncPair& y) { - return x.first > y.first; - }); - for (auto& f : *g_initFuncs) { - f.second(); - } - delete g_initFuncs; - g_initFuncs = nullptr; - } - g_initialized = true; - LOG(INFO) << "Call runInitFunctions done."; - }); + std::call_once(g_onceFlag, []() { + LOG(INFO) << "Calling runInitFunctions"; + if (g_initFuncs) { + std::sort(g_initFuncs->begin(), + g_initFuncs->end(), + [](const PriorityFuncPair& x, const PriorityFuncPair& y) { + return x.first > y.first; + }); + for (auto& f : *g_initFuncs) { + f.second(); + } + delete g_initFuncs; + g_initFuncs = nullptr; + } + g_initialized = true; + LOG(INFO) << "Call runInitFunctions done."; + }); } void initMain(int argc, char** argv) { diff --git a/paddle/utils/Util.h b/paddle/utils/Util.h index ed38f8fa60b3716c12e755b047557c1409fa767c..24ddde28e7e9f44c32d70e1b9621954ee77b2883 100644 --- a/paddle/utils/Util.h +++ b/paddle/utils/Util.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,25 +14,25 @@ limitations under the License. */ #pragma once +#include // for syscall() +#include #include #include -#include -#include +#include #include +#include +#include #include #include -#include -#include -#include // for syscall() -#include +#include #include "CommandLineParser.h" +#include "DisableCopy.h" #include "Logging.h" #include "TrainerConfig.pb.h" -#include "DisableCopy.h" -#include "TypeDefs.h" #include "Flags.h" +#include "TypeDefs.h" #include "hl_gpu.h" /** diff --git a/paddle/utils/Version.cpp b/paddle/utils/Version.cpp index e706983918b4a865f6674a34083ef0143bd6e185..a9e351b69fcbac661142d0a3322d7bf3a4293cd9 100644 --- a/paddle/utils/Version.cpp +++ b/paddle/utils/Version.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,10 +14,10 @@ limitations under the License. */ #include "Version.h" -#include "Flags.h" -#include "Util.h" #include #include +#include "Flags.h" +#include "Util.h" //! TODO(yuyang18) in gflags, version has another define. Use another flag //! instead. #ifndef PADDLE_USE_GFLAGS @@ -33,7 +33,12 @@ void printVersion(std::ostream& os) { #ifndef PADDLE_VERSION #define PADDLE_VERSION "unknown" #endif - os << "paddle version: " << PADDLE_VERSION << std::endl +// converts macro to string +// https://gcc.gnu.org/onlinedocs/cpp/Stringification.html +#define xstr(s) str(s) +#define str(s) #s + + os << "paddle version: " << xstr(PADDLE_VERSION) << std::endl << std::boolalpha << "\t" << "withGpu: " << version::isWithGpu() << std::endl << "\t" diff --git a/paddle/utils/Version.h b/paddle/utils/Version.h index e6c799644ee7f88e4e90eec565d1bab2bc9faed7..d1a07d9485076e5382d47f7408fcbf032166b1ed 100644 --- a/paddle/utils/Version.h +++ b/paddle/utils/Version.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,8 +14,8 @@ limitations under the License. */ #pragma once #include -#include "TypeDefs.h" #include +#include "TypeDefs.h" namespace paddle { diff --git a/paddle/utils/arch/linux/Locks.cpp b/paddle/utils/arch/linux/Locks.cpp index 93016daeaea644ca44499fdc6024ec8deac57ca8..2a6f96e04d024ac3977bc154dbeeb69ce9ab3a5d 100644 --- a/paddle/utils/arch/linux/Locks.cpp +++ b/paddle/utils/arch/linux/Locks.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/utils/arch/osx/Locks.cpp b/paddle/utils/arch/osx/Locks.cpp index ae563a6afd29b6315d9c6609474faddbfaaded14..e03992363fd6051a1970664d63406b2e7a47fce3 100644 --- a/paddle/utils/arch/osx/Locks.cpp +++ b/paddle/utils/arch/osx/Locks.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -13,10 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/utils/Locks.h" -#include "paddle/utils/Logging.h" #include -#include #include +#include +#include "paddle/utils/Logging.h" namespace paddle { diff --git a/paddle/utils/tests/test_CommandLineParser.cpp b/paddle/utils/tests/test_CommandLineParser.cpp index 5ecfb2b4f511e63eac21a5eae3829532f6860d66..ed2b3068d5dda710de728cfad14a98aeaf847954 100644 --- a/paddle/utils/tests/test_CommandLineParser.cpp +++ b/paddle/utils/tests/test_CommandLineParser.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -15,8 +15,8 @@ limitations under the License. */ #ifndef PADDLE_USE_GFLAGS //! Test Command Line Parser for paddle internal implement. -#include #include +#include P_DEFINE_int32(i1, 1, "test int flag 1"); P_DEFINE_int32(i2, 2, "test int flag 2"); diff --git a/paddle/utils/tests/test_CustomStackTrace.cpp b/paddle/utils/tests/test_CustomStackTrace.cpp index 3bfb381ed93659feebcc567a04b2a095dc94dfa8..292ed4619d8bb0c3f7069cbbea7e729d91dd126c 100644 --- a/paddle/utils/tests/test_CustomStackTrace.cpp +++ b/paddle/utils/tests/test_CustomStackTrace.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -15,10 +15,10 @@ limitations under the License. */ #include #include -#include "paddle/utils/CustomStackTrace.h" #include "paddle/utils/CommandLineParser.h" -#include "paddle/utils/Util.h" +#include "paddle/utils/CustomStackTrace.h" #include "paddle/utils/Locks.h" +#include "paddle/utils/Util.h" P_DEFINE_int32(test_thread_num, 10, "testing thread number"); diff --git a/paddle/utils/tests/test_CustomStackTracePrint.cpp b/paddle/utils/tests/test_CustomStackTracePrint.cpp index d39a190961a96906eef2b510cb3538c639d5df5c..611b16aa7116d03ee51ba0095d043b78df1742ba 100644 --- a/paddle/utils/tests/test_CustomStackTracePrint.cpp +++ b/paddle/utils/tests/test_CustomStackTracePrint.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/utils/Util.h" #include "paddle/utils/CustomStackTrace.h" +#include "paddle/utils/Util.h" int main(int argc, char** argv) { paddle::initMain(argc, argv); diff --git a/paddle/utils/tests/test_Logging.cpp b/paddle/utils/tests/test_Logging.cpp index 9f477fab14a2abde93505a05fc4c9ccd3d6426b6..fbfffcc65aeb9f5ebbe97dcb54ec44bd63f8d4bd 100644 --- a/paddle/utils/tests/test_Logging.cpp +++ b/paddle/utils/tests/test_Logging.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -17,10 +17,10 @@ limitations under the License. */ * Used in embedded system where there is no glogs. */ +#include #include -#include #include -#include +#include #include "paddle/utils/Logging.h" #include "paddle/utils/Util.h" #ifndef PADDLE_USE_GLOG diff --git a/paddle/utils/tests/test_SIMDFlags.cpp b/paddle/utils/tests/test_SIMDFlags.cpp index 47b6c542ea6fbb126e1172708ff0a8a8fb31e77f..e056be5f7cc7088f01fe0e3a5fb3552b2c5c1b4a 100644 --- a/paddle/utils/tests/test_SIMDFlags.cpp +++ b/paddle/utils/tests/test_SIMDFlags.cpp @@ -9,25 +9,26 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ - #include #include "paddle/utils/CpuId.h" #include "paddle/utils/Logging.h" #include "paddle/utils/Util.h" -using namespace paddle; // NOLINT +using namespace paddle; // NOLINT TEST(SIMDFlags, gccTest) { #if (defined(__GNUC__) || defined(__GNUG__)) && !(defined(__clang__)) - CHECK(!__builtin_cpu_supports("sse") != HAS_SSE); - CHECK(!__builtin_cpu_supports("sse2") != HAS_SSE2); - CHECK(!__builtin_cpu_supports("sse3") != HAS_SSE3); - CHECK(!__builtin_cpu_supports("ssse3") != HAS_SSSE3); - CHECK(!__builtin_cpu_supports("sse4.1")!= HAS_SSE41); - CHECK(!__builtin_cpu_supports("sse4.2")!= HAS_SSE42); - CHECK(!__builtin_cpu_supports("avx") != HAS_AVX); - CHECK(!__builtin_cpu_supports("avx2") != HAS_AVX2); +// clang-format off + CHECK(!__builtin_cpu_supports("sse") != HAS_SSE); + CHECK(!__builtin_cpu_supports("sse2") != HAS_SSE2); + CHECK(!__builtin_cpu_supports("sse3") != HAS_SSE3); + CHECK(!__builtin_cpu_supports("ssse3") != HAS_SSSE3); + CHECK(!__builtin_cpu_supports("sse4.1") != HAS_SSE41); + CHECK(!__builtin_cpu_supports("sse4.2") != HAS_SSE42); + CHECK(!__builtin_cpu_supports("avx") != HAS_AVX); + CHECK(!__builtin_cpu_supports("avx2") != HAS_AVX2); +// clang-format on #endif } @@ -46,6 +47,5 @@ TEST(SIMDFlags, normalPrint) { int main(int argc, char** argv) { testing::InitGoogleTest(&argc, argv); - paddle::initMain(argc, argv); return RUN_ALL_TESTS(); } diff --git a/paddle/utils/tests/test_SpinLock.cpp b/paddle/utils/tests/test_SpinLock.cpp index 77d281962cfeaa3cc951a72eddf4f37b619c5691..22f8584ef559d78bb1ba01356b3361accf3093c4 100644 --- a/paddle/utils/tests/test_SpinLock.cpp +++ b/paddle/utils/tests/test_SpinLock.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,10 +14,10 @@ limitations under the License. */ #include #include -#include "paddle/utils/Logging.h" #include "paddle/utils/CommandLineParser.h" -#include "paddle/utils/Util.h" #include "paddle/utils/Locks.h" +#include "paddle/utils/Logging.h" +#include "paddle/utils/Util.h" P_DEFINE_int32(test_thread_num, 100, "testing thread number"); diff --git a/paddle/utils/tests/test_StringUtils.cpp b/paddle/utils/tests/test_StringUtils.cpp index 2c699b791ffad8ed680c5537005aac7dad832f41..fdc914d1bcc3c74e0f05ef475069abc315bdc306 100644 --- a/paddle/utils/tests/test_StringUtils.cpp +++ b/paddle/utils/tests/test_StringUtils.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/paddle/utils/tests/test_Thread.cpp b/paddle/utils/tests/test_Thread.cpp index 154db5d9c616d4817b933c82587834f5ce2d0f8e..2f5c5bbce07f39b799b928fd231bb4db1d2b3e05 100644 --- a/paddle/utils/tests/test_Thread.cpp +++ b/paddle/utils/tests/test_Thread.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include -#include #include +#include +#include using paddle::AsyncThreadPool; // NOLINT @@ -52,17 +52,13 @@ TEST(AsyncThreadPool, multiThreadAddBatchJob) { int counter = 0; const int numMonitors = 300; const int numSlaves = 300; - std::vector moniterJobs( - numMonitors, - [&] { - std::vector slaveJobs( - numSlaves, - [mut, &counter] { - std::lock_guard lk(*mut); - counter++; - }); - levelTwoPool.addBatchJobs(slaveJobs); - }); + std::vector moniterJobs(numMonitors, [&] { + std::vector slaveJobs(numSlaves, [mut, &counter] { + std::lock_guard lk(*mut); + counter++; + }); + levelTwoPool.addBatchJobs(slaveJobs); + }); levelOnePool.addBatchJobs(moniterJobs); ASSERT_EQ(counter, numMonitors * numSlaves); } diff --git a/paddle/utils/tests/test_ThreadBarrier.cpp b/paddle/utils/tests/test_ThreadBarrier.cpp index 20b9babd94cf4e6a475daece349c871bd606d83d..4a8af5b97e3977961bce40a9aa9ad691113e342b 100644 --- a/paddle/utils/tests/test_ThreadBarrier.cpp +++ b/paddle/utils/tests/test_ThreadBarrier.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -15,10 +15,10 @@ limitations under the License. */ #include #include #include -#include "paddle/utils/Logging.h" #include "paddle/utils/CommandLineParser.h" -#include "paddle/utils/Util.h" #include "paddle/utils/Locks.h" +#include "paddle/utils/Logging.h" +#include "paddle/utils/Util.h" P_DEFINE_int32(test_thread_num, 100, "testing thread number"); diff --git a/proto/DataConfig.proto.m4 b/proto/DataConfig.proto.m4 index 01d451ff7d5334f8f84d28973c2d7c4b4fac5885..1f8e3f4f3e523447b69bfd2dbce9c99dc22571d1 100644 --- a/proto/DataConfig.proto.m4 +++ b/proto/DataConfig.proto.m4 @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/proto/DataFormat.proto.m4 b/proto/DataFormat.proto.m4 index 8a4a0be1b31a62cca35ca732a037ddc8b20786c4..54e9fd008e485d24c21c58d543be6b311378905b 100644 --- a/proto/DataFormat.proto.m4 +++ b/proto/DataFormat.proto.m4 @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/proto/ModelConfig.proto.m4 b/proto/ModelConfig.proto.m4 index 4e8ed36f4ed4446193fab6fb710a0283d87b4b3a..ccad69a3c2209542d2be855ddf3f75def9e8d729 100644 --- a/proto/ModelConfig.proto.m4 +++ b/proto/ModelConfig.proto.m4 @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/proto/ParameterConfig.proto.m4 b/proto/ParameterConfig.proto.m4 index 26e7c3ef77b7377b8d6da4d947bcad27ae4edf72..b5c0fea6c373307dc0af2e29c0f1ff5362823411 100644 --- a/proto/ParameterConfig.proto.m4 +++ b/proto/ParameterConfig.proto.m4 @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/proto/ParameterService.proto.m4 b/proto/ParameterService.proto.m4 index 0b3f14a2ee5b3e1771f724bd9d271a3ecfd15038..25b0991583ec128aeeca1ca775a574f81500d6e5 100644 --- a/proto/ParameterService.proto.m4 +++ b/proto/ParameterService.proto.m4 @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/proto/TrainerConfig.proto.m4 b/proto/TrainerConfig.proto.m4 index 965c9cd39353970dd547f2a595eb99531f3693c6..4684203b03e3297f60629ff6929729c3daffd8c6 100644 --- a/proto/TrainerConfig.proto.m4 +++ b/proto/TrainerConfig.proto.m4 @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/python/paddle/__init__.py b/python/paddle/__init__.py index c90af2ee000d46a032984ee23559e7e99b49ddad..f662d6826321eb840739382558f76327d27b5847 100644 --- a/python/paddle/__init__.py +++ b/python/paddle/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/python/paddle/proto/__init__.py b/python/paddle/proto/__init__.py index cd6a59ecbb0952e89f34b11678a60ad300585979..07406a841ec90a79fbe5d0aca7b19d19d85e008a 100644 --- a/python/paddle/proto/__init__.py +++ b/python/paddle/proto/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/python/paddle/trainer/PyDataProvider2.py b/python/paddle/trainer/PyDataProvider2.py index 0c577ec657bc6d35c41e55ed5ab6adb80ab2c37c..6e8cce1cce700f3a46571451da17b781e838c3b8 100644 --- a/python/paddle/trainer/PyDataProvider2.py +++ b/python/paddle/trainer/PyDataProvider2.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/python/paddle/trainer/PyDataProviderWrapper.py b/python/paddle/trainer/PyDataProviderWrapper.py index 90b684a000017fc03c8c33f829aaa64a5f769e45..6af250772859811b3c48434ab005e50b435dd320 100644 --- a/python/paddle/trainer/PyDataProviderWrapper.py +++ b/python/paddle/trainer/PyDataProviderWrapper.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/python/paddle/trainer/__init__.py b/python/paddle/trainer/__init__.py index c90af2ee000d46a032984ee23559e7e99b49ddad..f662d6826321eb840739382558f76327d27b5847 100644 --- a/python/paddle/trainer/__init__.py +++ b/python/paddle/trainer/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/python/paddle/trainer/config_parser.py b/python/paddle/trainer/config_parser.py index c6c0c9c151d840963fab1fe689eb5b9c340518ce..5b7f4d85e2c3343013938e38492be8985a8cd11f 100644 --- a/python/paddle/trainer/config_parser.py +++ b/python/paddle/trainer/config_parser.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -141,9 +141,9 @@ def init_config_environment( g_add_submodel_suffix=False, # Whether current layer needs to pass the image height and width. - # Default value is true, but if it encounters recurrent_layer_group, - # it will be false. The reason is that image is converted to be sequence, - # image height will be sequence length, and image width will be feature + # Default value is true, but if it encounters recurrent_layer_group, + # it will be false. The reason is that image is converted to be sequence, + # image height will be sequence length, and image width will be feature # length of each timestep. g_pass_height_width=True, ): @@ -1067,7 +1067,7 @@ def cnn_output_size(img_size, filter_size, padding, stride, caffe_mode): return 1 + int(math.ceil(output)) -#calcualte image_size based on output_size for de-convolution (ConvTransLayer). +#calcualte image_size based on output_size for de-convolution (ConvTransLayer). #It is the reverse function of cnn_output_size def cnn_image_size(output_size, filter_size, padding, stride, caffe_mode): img_size = (output_size - 1) * stride + filter_size - 2 * padding @@ -3365,12 +3365,26 @@ def my_fatal(s): raise Exception() +_parse_config_hooks = set() + + +def register_parse_config_hook(f): + """ + Register a hook function for parse_config. parse_config will invoke the hook + at the beginning of parse. This make it possible to reset global state for + for constructing the model. + """ + _parse_config_hooks.add(f) + + def parse_config(config_file, config_arg_str): ''' @param config_arg_str: a string of the form var1=val1,var2=val2. It will be passed to config script as a dictionary CONFIG_ARGS ''' init_config_environment() + for hook in _parse_config_hooks: + hook() config_args = {} diff --git a/python/paddle/trainer/config_parser_extension.py b/python/paddle/trainer/config_parser_extension.py index ba4c79efdc10ec6cc895e76ddb87bc3fbd19ddc1..b9e0f3eb13dd3f54e26a566f4ae937940134fa03 100644 --- a/python/paddle/trainer/config_parser_extension.py +++ b/python/paddle/trainer/config_parser_extension.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/python/paddle/trainer/recurrent_units.py b/python/paddle/trainer/recurrent_units.py index a80ad13d1ed52d84c3b5882939271b91ecc07bb3..edca279dcadef42243cb3fc00366cec90cbc69bf 100644 --- a/python/paddle/trainer/recurrent_units.py +++ b/python/paddle/trainer/recurrent_units.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/python/paddle/trainer_config_helpers/__init__.py b/python/paddle/trainer_config_helpers/__init__.py index adebebba2523f851507c4a0525eeaae9cfeb9dcc..3ac14549340bb61809a434053a8f04071a767b14 100644 --- a/python/paddle/trainer_config_helpers/__init__.py +++ b/python/paddle/trainer_config_helpers/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/python/paddle/trainer_config_helpers/activations.py b/python/paddle/trainer_config_helpers/activations.py index eeed18a98a27313dac65a695960043d0543bb577..06be3e45993bedc2ccf9874e1ab503a9fdbba623 100644 --- a/python/paddle/trainer_config_helpers/activations.py +++ b/python/paddle/trainer_config_helpers/activations.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/python/paddle/trainer_config_helpers/attrs.py b/python/paddle/trainer_config_helpers/attrs.py index 54169f382f164e7b9cf061baeb21d4109a8ae5b6..59bb18bfcab30540bd38ca8d1cb300813d30fee8 100644 --- a/python/paddle/trainer_config_helpers/attrs.py +++ b/python/paddle/trainer_config_helpers/attrs.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/python/paddle/trainer_config_helpers/data_sources.py b/python/paddle/trainer_config_helpers/data_sources.py index b41097953dad8aa9c8755c25860b177cdbff5b93..b6ecd42857852c1f9f12db8370183d7799761a4f 100644 --- a/python/paddle/trainer_config_helpers/data_sources.py +++ b/python/paddle/trainer_config_helpers/data_sources.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/python/paddle/trainer_config_helpers/default_decorators.py b/python/paddle/trainer_config_helpers/default_decorators.py index c01050e338d5933f49f0504f2e9ef5f15c7743ba..ad3efcbf369411b9c42b2a32ed05b04f86bf7de6 100644 --- a/python/paddle/trainer_config_helpers/default_decorators.py +++ b/python/paddle/trainer_config_helpers/default_decorators.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -78,6 +78,20 @@ class DefaultNameFactory(object): """ pass + def reset(self): + self.__counter__ = 0 + + +_name_factories = [] + + +def reset_hook(): + for factory in _name_factories: + factory.reset() + + +register_parse_config_hook(reset_hook) + def wrap_name_default(name_prefix=None): """ @@ -95,7 +109,9 @@ def wrap_name_default(name_prefix=None): :return: a decorator to set default name :rtype: callable """ - return wrap_param_default(["name"], DefaultNameFactory(name_prefix)) + factory = DefaultNameFactory(name_prefix) + _name_factories.append(factory) + return wrap_param_default(["name"], factory) def wrap_param_attr_default(param_names=None, default_factory=None): diff --git a/python/paddle/trainer_config_helpers/evaluators.py b/python/paddle/trainer_config_helpers/evaluators.py index dc6a36392f9c6bff42d3a37f963ed18a849414f5..0ee116d8c47c2f2d351af89583e2edbc22f9df55 100644 --- a/python/paddle/trainer_config_helpers/evaluators.py +++ b/python/paddle/trainer_config_helpers/evaluators.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/python/paddle/trainer_config_helpers/layers.py b/python/paddle/trainer_config_helpers/layers.py index 4541b6fd8deddbd9cd3f8cb02f01e8328718d6e7..8dd6b7b7d28f841d7d7657b8ef3c25188c2f086e 100644 --- a/python/paddle/trainer_config_helpers/layers.py +++ b/python/paddle/trainer_config_helpers/layers.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/python/paddle/trainer_config_helpers/math.py b/python/paddle/trainer_config_helpers/math.py index 30a9b1c4e895f2d7629c222208b79545b9c56fda..2d9e36f2b0d379d907634208a45c69efa9dbba3d 100644 --- a/python/paddle/trainer_config_helpers/math.py +++ b/python/paddle/trainer_config_helpers/math.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/python/paddle/trainer_config_helpers/networks.py b/python/paddle/trainer_config_helpers/networks.py index ff6d2e1cffcebf3b55ba7dfbefce9e2af6d09672..375bea34e8aa0ac2ea222531f313a627414495b0 100644 --- a/python/paddle/trainer_config_helpers/networks.py +++ b/python/paddle/trainer_config_helpers/networks.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/python/paddle/trainer_config_helpers/optimizers.py b/python/paddle/trainer_config_helpers/optimizers.py index 501fc3211bf2b955065f40109ab5ceeaa8041e6e..d95b2cfe464bbe6c9bbd216ab4f066545c970cdc 100644 --- a/python/paddle/trainer_config_helpers/optimizers.py +++ b/python/paddle/trainer_config_helpers/optimizers.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/python/paddle/trainer_config_helpers/poolings.py b/python/paddle/trainer_config_helpers/poolings.py index 6f13a76f25a106dfda5e71dbc237b95afefff884..0c38a8dce553ec120cacc72edb604bfeb1819f93 100644 --- a/python/paddle/trainer_config_helpers/poolings.py +++ b/python/paddle/trainer_config_helpers/poolings.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/python/paddle/trainer_config_helpers/tests/CMakeLists.txt b/python/paddle/trainer_config_helpers/tests/CMakeLists.txt index 6180b2efbcad87e511a4b981d533f204f45fb5dc..d1a9843d326669711bf3d0769df1b804cfcfa673 100644 --- a/python/paddle/trainer_config_helpers/tests/CMakeLists.txt +++ b/python/paddle/trainer_config_helpers/tests/CMakeLists.txt @@ -4,6 +4,11 @@ add_test(NAME layers_test python ${PROJ_ROOT}/python/paddle/trainer_config_helpers/tests/layers_test.py WORKING_DIRECTORY ${PROJ_ROOT}/python/paddle) +add_test(NAME test_reset_hook + COMMAND ${PROJ_ROOT}/paddle/.set_python_path.sh -d ${PROJ_ROOT}/python/ + python ${PROJ_ROOT}/python/paddle/trainer_config_helpers/tests/test_reset_hook.py + WORKING_DIRECTORY ${PROJ_ROOT}/python/paddle) + if (PROTOBUF_3) add_paddle_exe(protobuf_equal ProtobufEqualMain.cpp) diff --git a/python/paddle/trainer_config_helpers/tests/ProtobufEqualMain.cpp b/python/paddle/trainer_config_helpers/tests/ProtobufEqualMain.cpp index 06f7de9306307e2f92958ef211ec137d54c99d1c..fc53422afd44a6cb1d81a8ec9d27d83523f30e6c 100644 --- a/python/paddle/trainer_config_helpers/tests/ProtobufEqualMain.cpp +++ b/python/paddle/trainer_config_helpers/tests/ProtobufEqualMain.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve. +/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/python/paddle/trainer_config_helpers/tests/configs/generate_protostr.sh b/python/paddle/trainer_config_helpers/tests/configs/generate_protostr.sh index e55f9bd3884a907dcc17a882e3c1dfd71fef79bb..a54af94ce3db4ed300dee697b30516c3b6448d7c 100755 --- a/python/paddle/trainer_config_helpers/tests/configs/generate_protostr.sh +++ b/python/paddle/trainer_config_helpers/tests/configs/generate_protostr.sh @@ -11,10 +11,12 @@ for conf in ${configs[*]} do echo "Generating " $conf python -m paddle.utils.dump_config $conf.py > $protostr/$conf.protostr.unittest + cat ${conf}.py |python test_config_parser_for_non_file_config.py > $protostr/$conf.protostr.non_file_config.unittest done for conf in ${whole_configs[*]} do echo "Generating " $conf python -m paddle.utils.dump_config $conf.py "" --whole > $protostr/$conf.protostr.unittest + cat ${conf}.py |python test_config_parser_for_non_file_config.py --whole > $protostr/$conf.protostr.non_file_config.unittest done diff --git a/python/paddle/trainer_config_helpers/tests/configs/run_tests.sh b/python/paddle/trainer_config_helpers/tests/configs/run_tests.sh index 73f8b333b236a8850e4c2dfa8fc75addeb143e9d..e984ee70625456241b3cfe6202fdadaa3807d33c 100755 --- a/python/paddle/trainer_config_helpers/tests/configs/run_tests.sh +++ b/python/paddle/trainer_config_helpers/tests/configs/run_tests.sh @@ -17,6 +17,7 @@ if [ -z $1 ]; then base_protostr=$protostr/$file new_protostr=$protostr/$file.unittest diff $base_protostr $new_protostr -u + diff $protostr/$file $protostr/$file.non_file_config.unittest -u done else for file in ${configs[*]} @@ -24,6 +25,9 @@ else if ! $1 $protostr/$file.protostr $protostr/$file.protostr.unittest; then diff $protostr/$file.protostr $protostr/$file.protostr.unittest -u fi + if ! $1 $protostr/$file.protostr $protostr/$file.protostr.non_file_config.unittest; then + diff $protostr/$file.protostr $protostr/$file.protostr.non_file_config.unittest -u + fi done for file in ${whole_configs[*]} @@ -31,5 +35,8 @@ else if ! $1 $protostr/$file.protostr $protostr/$file.protostr.unittest --whole; then diff $protostr/$file.protostr $protostr/$file.protostr.unittest -u fi + if ! $1 $protostr/$file.protostr $protostr/$file.protostr.non_file_config.unittest --whole; then + diff $protostr/$file.protostr $protostr/$file.protostr.non_file_config.unittest -u + fi done fi diff --git a/python/paddle/trainer_config_helpers/tests/configs/test_config_parser_for_non_file_config.py b/python/paddle/trainer_config_helpers/tests/configs/test_config_parser_for_non_file_config.py new file mode 100644 index 0000000000000000000000000000000000000000..9b791a0222dd60e9ae2fca8b2798cddd13ed1d1c --- /dev/null +++ b/python/paddle/trainer_config_helpers/tests/configs/test_config_parser_for_non_file_config.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import sys +import re +import getopt + + +def main(print_whole_config, globals, locals): + ''' + this test will all test_config.py + ''' + cmdstr = """from paddle.trainer.config_parser import parse_config\n""" + importstr = "" + functionstr = "" + + for line in sys.stdin: + if re.match("^import", line) or re.match("^from.*import", line): + importstr = importstr + line + else: + functionstr = functionstr + " " + line + + cmdstr = cmdstr + importstr + """def configs():\n""" + functionstr + #cmdstr = cmdstr + """def configs():\n""" + importstr + functionstr + if print_whole_config: + cmdstr = cmdstr + """print parse_config(configs, "")""" + else: + cmdstr = cmdstr + """print parse_config(configs, "").model_config""" + + exec (cmdstr, globals, locals) + + +if __name__ == '__main__': + whole = False + opts, args = getopt.getopt(sys.argv[1:], "", ["whole"]) + for op, value in opts: + if op == "--whole": + whole = True + main(whole, globals(), locals()) diff --git a/python/paddle/trainer_config_helpers/tests/layers_test.py b/python/paddle/trainer_config_helpers/tests/layers_test.py index 3b55667354750066a7d3ab3a0af59eb9e7d47d86..05902ea293df5a3e9c10f6700930ca6a343603c2 100644 --- a/python/paddle/trainer_config_helpers/tests/layers_test.py +++ b/python/paddle/trainer_config_helpers/tests/layers_test.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/python/paddle/trainer_config_helpers/tests/layers_test_config.py b/python/paddle/trainer_config_helpers/tests/layers_test_config.py index 44d134d1f7d5fb5de790cf564f4c1e0899571473..ae275735aa2b852b3b226a4a0e5b2d4d000ba199 100644 --- a/python/paddle/trainer_config_helpers/tests/layers_test_config.py +++ b/python/paddle/trainer_config_helpers/tests/layers_test_config.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/python/paddle/trainer_config_helpers/tests/test_reset_hook.py b/python/paddle/trainer_config_helpers/tests/test_reset_hook.py new file mode 100644 index 0000000000000000000000000000000000000000..0423babdb720191d8e9dfc67f1af3be339dbe27d --- /dev/null +++ b/python/paddle/trainer_config_helpers/tests/test_reset_hook.py @@ -0,0 +1,28 @@ +# Copyright PaddlePaddle contributors. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import unittest +from paddle.trainer.config_parser import parse_config + + +class TestParse(unittest.TestCase): + def test_parse(self): + a = parse_config('trainer_config_helpers/tests/layers_test_config.py', + '') + b = parse_config('trainer_config_helpers/tests/layers_test_config.py', + '') + self.assertEqual(a, b) + + +if __name__ == '__main__': + unittest.main() diff --git a/python/paddle/trainer_config_helpers/utils.py b/python/paddle/trainer_config_helpers/utils.py index c0235b28cdfb96fbff9c02c217ffd972e4f8816e..fe6e9cd53cc821d2b6dbdabb7130567e22f8000f 100644 --- a/python/paddle/trainer_config_helpers/utils.py +++ b/python/paddle/trainer_config_helpers/utils.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/python/paddle/utils/__init__.py b/python/paddle/utils/__init__.py index 3e93f41c2e32025b3e29a0990833d7e97a7c8caa..15595d208583b567b8f768c8d7bd84986ca5a03f 100644 --- a/python/paddle/utils/__init__.py +++ b/python/paddle/utils/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/python/paddle/utils/dump_config.py b/python/paddle/utils/dump_config.py index c5ce5c8d9a084d68b250d091808f528459f46921..73bf349c46726163d664c374aa47598871b90106 100644 --- a/python/paddle/utils/dump_config.py +++ b/python/paddle/utils/dump_config.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/python/paddle/utils/image_multiproc.py b/python/paddle/utils/image_multiproc.py new file mode 100644 index 0000000000000000000000000000000000000000..6ce32f7811d6be6864a567cf41bf408f422409a7 --- /dev/null +++ b/python/paddle/utils/image_multiproc.py @@ -0,0 +1,262 @@ +import os, sys +import numpy as np +from PIL import Image +from cStringIO import StringIO +import multiprocessing +import functools +import itertools + +from paddle.utils.image_util import * +from paddle.trainer.config_parser import logger + +try: + import cv2 +except ImportError: + logger.warning("OpenCV2 is not installed, using PIL to prcoess") + cv2 = None + +__all__ = ["CvTransformer", "PILTransformer", "MultiProcessImageTransformer"] + + +class CvTransformer(ImageTransformer): + """ + CvTransformer used python-opencv to process image. + """ + + def __init__( + self, + min_size=None, + crop_size=None, + transpose=(2, 0, 1), # transpose to C * H * W + channel_swap=None, + mean=None, + is_train=True, + is_color=True): + ImageTransformer.__init__(self, transpose, channel_swap, mean, is_color) + self.min_size = min_size + self.crop_size = crop_size + self.is_train = is_train + + def resize(self, im, min_size): + row, col = im.shape[:2] + new_row, new_col = min_size, min_size + if row > col: + new_row = min_size * row / col + else: + new_col = min_size * col / row + im = cv2.resize(im, (new_row, new_col), interpolation=cv2.INTER_CUBIC) + return im + + def crop_and_flip(self, im): + """ + Return cropped image. + The size of the cropped image is inner_size * inner_size. + im: (H x W x K) ndarrays + """ + row, col = im.shape[:2] + start_h, start_w = 0, 0 + if self.is_train: + start_h = np.random.randint(0, row - self.crop_size + 1) + start_w = np.random.randint(0, col - self.crop_size + 1) + else: + start_h = (row - self.crop_size) / 2 + start_w = (col - self.crop_size) / 2 + end_h, end_w = start_h + self.crop_size, start_w + self.crop_size + if self.is_color: + im = im[start_h:end_h, start_w:end_w, :] + else: + im = im[start_h:end_h, start_w:end_w] + if (self.is_train) and (np.random.randint(2) == 0): + if self.is_color: + im = im[:, ::-1, :] + else: + im = im[:, ::-1] + return im + + def transform(self, im): + im = self.resize(im, self.min_size) + im = self.crop_and_flip(im) + # transpose, swap channel, sub mean + im = im.astype('float32') + ImageTransformer.transformer(self, im) + return im + + def load_image_from_string(self, data): + flag = cv2.CV_LOAD_IMAGE_COLOR if self.is_color else cv2.CV_LOAD_IMAGE_GRAYSCALE + im = cv2.imdecode(np.fromstring(data, np.uint8), flag) + return im + + def transform_from_string(self, data): + im = self.load_image_from_string(data) + return self.transform(im) + + def load_image_from_file(self, file): + flag = cv2.CV_LOAD_IMAGE_COLOR if self.is_color else cv2.CV_LOAD_IMAGE_GRAYSCALE + im = cv2.imread(file, flag) + return im + + def transform_from_file(self, file): + im = self.load_image_from_file(file) + return self.transform(im) + + +class PILTransformer(ImageTransformer): + """ + PILTransformer used PIL to process image. + """ + + def __init__( + self, + min_size=None, + crop_size=None, + transpose=(2, 0, 1), # transpose to C * H * W + channel_swap=None, + mean=None, + is_train=True, + is_color=True): + ImageTransformer.__init__(self, transpose, channel_swap, mean, is_color) + self.min_size = min_size + self.crop_size = crop_size + self.is_train = is_train + + def resize(self, im, min_size): + row, col = im.size[:2] + new_row, new_col = min_size, min_size + if row > col: + new_row = min_size * row / col + else: + new_col = min_size * col / row + im = im.resize((new_row, new_col), Image.ANTIALIAS) + return im + + def crop_and_flip(self, im): + """ + Return cropped image. + The size of the cropped image is inner_size * inner_size. + """ + row, col = im.size[:2] + start_h, start_w = 0, 0 + if self.is_train: + start_h = np.random.randint(0, row - self.crop_size + 1) + start_w = np.random.randint(0, col - self.crop_size + 1) + else: + start_h = (row - self.crop_size) / 2 + start_w = (col - self.crop_size) / 2 + end_h, end_w = start_h + self.crop_size, start_w + self.crop_size + im = im.crop((start_h, start_w, end_h, end_w)) + if (self.is_train) and (np.random.randint(2) == 0): + im = im.transpose(Image.FLIP_LEFT_RIGHT) + return im + + def transform(self, im): + im = self.resize(im, self.min_size) + im = self.crop_and_flip(im) + im = np.array(im, dtype=np.float32) # convert to numpy.array + # transpose, swap channel, sub mean + ImageTransformer.transformer(self, im) + return im + + def load_image_from_string(self, data): + im = Image.open(StringIO(data)) + return im + + def transform_from_string(self, data): + im = self.load_image_from_string(data) + return self.transform(im) + + def load_image_from_file(self, file): + im = Image.open(file) + return im + + def transform_from_file(self, file): + im = self.load_image_from_file(file) + return self.transform(im) + + +def job(is_img_string, transformer, (data, label)): + if is_img_string: + return transformer.transform_from_string(data), label + else: + return transformer.transform_from_file(data), label + + +class MultiProcessImageTransformer(object): + def __init__(self, + procnum=10, + resize_size=None, + crop_size=None, + transpose=(2, 0, 1), + channel_swap=None, + mean=None, + is_train=True, + is_color=True, + is_img_string=True): + """ + Processing image with multi-process. If it is used in PyDataProvider, + the simple usage for CNN is as follows: + + .. code-block:: python + + def hool(settings, is_train, **kwargs): + settings.is_train = is_train + settings.mean_value = np.array([103.939,116.779,123.68], dtype=np.float32) + settings.input_types = [ + dense_vector(3 * 224 * 224), + integer_value(1)] + settings.transformer = MultiProcessImageTransformer( + procnum=10, + resize_size=256, + crop_size=224, + transpose=(2, 0, 1), + mean=settings.mean_values, + is_train=settings.is_train) + + + @provider(init_hook=hook, pool_size=20480) + def process(settings, file_list): + with open(file_list, 'r') as fdata: + for line in fdata: + data_dic = np.load(line.strip()) # load the data batch pickled by Pickle. + data = data_dic['data'] + labels = data_dic['label'] + labels = np.array(labels, dtype=np.float32) + for im, lab in settings.dp.run(data, labels): + yield [im.astype('float32'), int(lab)] + + :param procnum: processor number. + :type procnum: int + :param resize_size: the shorter edge size of image after resizing. + :type resize_size: int + :param crop_size: the croping size. + :type crop_size: int + :param transpose: the transpose order, Paddle only allow C * H * W order. + :type transpose: tuple or list + :param channel_swap: the channel swap order, RGB or BRG. + :type channel_swap: tuple or list + :param mean: the mean values of image, per-channel mean or element-wise mean. + :type mean: array, The dimension is 1 for per-channel mean. + The dimension is 3 for element-wise mean. + :param is_train: training peroid or testing peroid. + :type is_train: bool. + :param is_color: the image is color or gray. + :type is_color: bool. + :param is_img_string: The input can be the file name of image or image string. + :type is_img_string: bool. + """ + + self.procnum = procnum + self.pool = multiprocessing.Pool(procnum) + self.is_img_string = is_img_string + if cv2 is not None: + self.transformer = CvTransformer(resize_size, crop_size, transpose, + channel_swap, mean, is_train, + is_color) + else: + self.transformer = PILTransformer(resize_size, crop_size, transpose, + channel_swap, mean, is_train, + is_color) + + def run(self, data, label): + fun = functools.partial(job, self.is_img_string, self.transformer) + return self.pool.imap_unordered( + fun, itertools.izip(data, label), chunksize=100 * self.procnum) diff --git a/python/paddle/utils/image_util.py b/python/paddle/utils/image_util.py index b5c6431c06f77cef5c31ca844a8427eebaea2fce..d3d79b14405256bbc95c41d805dbee56cb104f5e 100644 --- a/python/paddle/utils/image_util.py +++ b/python/paddle/utils/image_util.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -186,29 +186,32 @@ class ImageTransformer: channel_swap=None, mean=None, is_color=True): - self.transpose = transpose - self.channel_swap = None - self.mean = None self.is_color = is_color + self.set_transpose(transpose) + self.set_channel_swap(channel_swap) + self.set_mean(mean) def set_transpose(self, order): - if self.is_color: - assert 3 == len(order) + if order is not None: + if self.is_color: + assert 3 == len(order) self.transpose = order def set_channel_swap(self, order): - if self.is_color: - assert 3 == len(order) + if order is not None: + if self.is_color: + assert 3 == len(order) self.channel_swap = order def set_mean(self, mean): - # mean value, may be one value per channel - if mean.ndim == 1: - mean = mean[:, np.newaxis, np.newaxis] - else: - # elementwise mean - if self.is_color: - assert len(mean.shape) == 3 + if mean is not None: + # mean value, may be one value per channel + if mean.ndim == 1: + mean = mean[:, np.newaxis, np.newaxis] + else: + # elementwise mean + if self.is_color: + assert len(mean.shape) == 3 self.mean = mean def transformer(self, data): diff --git a/python/paddle/utils/make_model_diagram.py b/python/paddle/utils/make_model_diagram.py index 29e271717d7108f343d4c28d51c7dfb11bb33fba..1370ea83a49955d3152a1147f8e8108371a8ae12 100644 --- a/python/paddle/utils/make_model_diagram.py +++ b/python/paddle/utils/make_model_diagram.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/python/paddle/utils/plotcurve.py b/python/paddle/utils/plotcurve.py index 7bc7c5f8d243ed4cca834c48197c511e44baf215..27bd8157d39632913e2fa3278f3af20ddea61da7 100644 --- a/python/paddle/utils/plotcurve.py +++ b/python/paddle/utils/plotcurve.py @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/python/paddle/utils/predefined_net.py b/python/paddle/utils/predefined_net.py index e9033432ed5200a88ce1ce4f3d7e74d03cf8c8e5..fa05f981f2b66bf55303a6f7c332c0bc9b112d29 100644 --- a/python/paddle/utils/predefined_net.py +++ b/python/paddle/utils/predefined_net.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/python/paddle/utils/preprocess_img.py b/python/paddle/utils/preprocess_img.py index f3c609e4cd1a3714219965cd543ab11136d3585f..975f1e9edea161331d37afbc6b5af46286f185bf 100644 --- a/python/paddle/utils/preprocess_img.py +++ b/python/paddle/utils/preprocess_img.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/python/paddle/utils/preprocess_util.py b/python/paddle/utils/preprocess_util.py index e5067a80ea7005bee7781e885b3658a2c03dc6f2..1d17a488243eb81e46bea3ead686efd021499e22 100644 --- a/python/paddle/utils/preprocess_util.py +++ b/python/paddle/utils/preprocess_util.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/python/paddle/utils/show_pb.py b/python/paddle/utils/show_pb.py index 3b371727b84e51f9f7db80b34e6e38fd149fcaaa..20614826d1d01f50a2bb54a840e2c584fb93b247 100644 --- a/python/paddle/utils/show_pb.py +++ b/python/paddle/utils/show_pb.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/python/paddle/utils/torch2paddle.py b/python/paddle/utils/torch2paddle.py index 958f55dbc4ee0b588b78fb630153b585f1ad4be0..91490111a1144ae25ed6566ff1c83db4f7954d33 100644 --- a/python/paddle/utils/torch2paddle.py +++ b/python/paddle/utils/torch2paddle.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Baidu, Inc. All Rights Reserved +# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/third_party/gtest.BUILD b/third_party/gtest.BUILD new file mode 100644 index 0000000000000000000000000000000000000000..71c74af513ca8c511dd273d089722bc7fbffd84c --- /dev/null +++ b/third_party/gtest.BUILD @@ -0,0 +1,8 @@ +cc_library( + name="main", + srcs=glob( + ["src/*.cc"], exclude=["src/gtest-all.cc"]), + hdrs=glob(["include/**/*.h", "src/*.h"]), + copts=["-Iexternal/gtest/include"], + linkopts=["-pthread"], + visibility=["//visibility:public"], ) diff --git a/third_party/protobuf_test/BUILD b/third_party/protobuf_test/BUILD new file mode 100644 index 0000000000000000000000000000000000000000..95a687a35629315398c7046ca7dc8d526892e227 --- /dev/null +++ b/third_party/protobuf_test/BUILD @@ -0,0 +1,24 @@ +licenses(["notice"]) # Apache 2.0 + +load("@protobuf//:protobuf.bzl", "cc_proto_library") + +cc_proto_library( + name="example_proto", + srcs=["example.proto"], + protoc="@protobuf//:protoc", + default_runtime="@protobuf//:protobuf", ) + +cc_library( + name="example_lib", + srcs=["example_lib.cc"], + hdrs=["example_lib.h"], + deps=[":example_proto"], ) + +cc_test( + name="example_lib_test", + srcs=["example_lib_test.cc"], + copts=["-Iexternal/gtest/include"], + deps=[ + "@gtest//:main", + ":example_lib", + ], ) diff --git a/third_party/protobuf_test/README.md b/third_party/protobuf_test/README.md new file mode 100644 index 0000000000000000000000000000000000000000..e8bdeee6fee66ef79d0b813b4d8dfa4c180754c6 --- /dev/null +++ b/third_party/protobuf_test/README.md @@ -0,0 +1 @@ +This package tests that Bazel can build protobuf related rules. diff --git a/third_party/protobuf_test/example.proto b/third_party/protobuf_test/example.proto new file mode 100644 index 0000000000000000000000000000000000000000..6a7eada9c14a9df5d3ef8971b636c14a11da3d11 --- /dev/null +++ b/third_party/protobuf_test/example.proto @@ -0,0 +1,7 @@ +syntax = "proto3"; + +package third_party.protobuf_test; + +message Greeting { + string name = 1; +} diff --git a/third_party/protobuf_test/example_lib.cc b/third_party/protobuf_test/example_lib.cc new file mode 100644 index 0000000000000000000000000000000000000000..ced377bc0a17dde31c5c853dec1a852fa0be7223 --- /dev/null +++ b/third_party/protobuf_test/example_lib.cc @@ -0,0 +1,9 @@ +#include "third_party/protobuf_test/example_lib.h" + +namespace third_party { +namespace protobuf_test { + +std::string get_greet(const Greeting& who) { return "Hello " + who.name(); } + +} // namespace protobuf_test +} // namespace thrid_party diff --git a/third_party/protobuf_test/example_lib.h b/third_party/protobuf_test/example_lib.h new file mode 100644 index 0000000000000000000000000000000000000000..516326e812e19eb162f5392b519904a65c66c660 --- /dev/null +++ b/third_party/protobuf_test/example_lib.h @@ -0,0 +1,13 @@ +#pragma once + +#include "third_party/protobuf_test/example.pb.h" + +#include + +namespace third_party { +namespace protobuf_test { + +std::string get_greet(const Greeting &who); + +} // namespace protobuf_test +} // namespace third_party diff --git a/third_party/protobuf_test/example_lib_test.cc b/third_party/protobuf_test/example_lib_test.cc new file mode 100644 index 0000000000000000000000000000000000000000..6229f56e6026908fff991765bd6bdaff6f8236ac --- /dev/null +++ b/third_party/protobuf_test/example_lib_test.cc @@ -0,0 +1,15 @@ +#include "third_party/protobuf_test/example_lib.h" + +#include "gtest/gtest.h" + +namespace third_party { +namespace protobuf_test { + +TEST(ProtobufTest, GetGreet) { + Greeting g; + g.set_name("Paddle"); + EXPECT_EQ("Hello Paddle", get_greet(g)); +} + +} // namespace protobuf_test +} // namespace third_party