Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
203db079
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
203db079
编写于
1月 08, 2017
作者:
L
liaogang
浏览文件
操作
浏览文件
下载
差异文件
Merge confict with another PR
上级
934ba0bf
c016758f
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
603 addition
and
283 deletion
+603
-283
.travis.yml
.travis.yml
+4
-3
CMakeLists.txt
CMakeLists.txt
+17
-17
cmake/configure.cmake
cmake/configure.cmake
+4
-0
cmake/external/python.cmake
cmake/external/python.cmake
+202
-184
cmake/external/swig.cmake
cmake/external/swig.cmake
+54
-50
cmake/external/warpctc.cmake
cmake/external/warpctc.cmake
+1
-0
demo/traffic_prediction/README
demo/traffic_prediction/README
+7
-0
demo/traffic_prediction/data/get_data.sh
demo/traffic_prediction/data/get_data.sh
+34
-0
demo/traffic_prediction/dataprovider.py
demo/traffic_prediction/dataprovider.py
+82
-0
demo/traffic_prediction/gen_result.py
demo/traffic_prediction/gen_result.py
+61
-0
demo/traffic_prediction/predict.sh
demo/traffic_prediction/predict.sh
+30
-0
demo/traffic_prediction/train.sh
demo/traffic_prediction/train.sh
+27
-0
demo/traffic_prediction/trainer_config.py
demo/traffic_prediction/trainer_config.py
+52
-0
paddle/api/CMakeLists.txt
paddle/api/CMakeLists.txt
+14
-12
paddle/gserver/tests/CMakeLists.txt
paddle/gserver/tests/CMakeLists.txt
+1
-1
paddle/scripts/travis/before_install.osx.sh
paddle/scripts/travis/before_install.osx.sh
+3
-1
paddle/scripts/travis/build_and_test.sh
paddle/scripts/travis/build_and_test.sh
+6
-13
paddle/utils/PythonUtil.cpp.in
paddle/utils/PythonUtil.cpp.in
+4
-2
未找到文件。
.travis.yml
浏览文件 @
203db079
...
...
@@ -21,14 +21,16 @@ addons:
packages
:
-
gcc-4.8
-
g++-4.8
-
wget
-
git
-
build-essential
-
libatlas-base-dev
-
python
-
python-pip
-
python2.7-dev
-
python-numpy
-
python-wheel
-
curl
-
swig
-
graphviz
-
clang-format-3.8
-
automake
...
...
@@ -47,8 +49,7 @@ before_install:
fi
-
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then paddle/scripts/travis/before_install.osx.sh; fi
-
if [[ "$JOB" == "PRE_COMMIT" ]]; then sudo ln -s /usr/bin/clang-format-3.8 /usr/bin/clang-format; fi
-
pip install --upgrade pip
-
pip install wheel protobuf sphinx recommonmark sphinx_rtd_theme virtualenv pre-commit requests==2.9.2 LinkChecker
-
pip install numpy wheel protobuf sphinx recommonmark sphinx_rtd_theme virtualenv pre-commit requests==2.9.2 LinkChecker
script
:
-
paddle/scripts/travis/main.sh
notifications
:
...
...
CMakeLists.txt
浏览文件 @
203db079
...
...
@@ -27,22 +27,23 @@ find_package(Threads REQUIRED)
include
(
system
)
include
(
simd
)
###################### Configurations ############################
option
(
WITH_DSO
"Compile PaddlePaddle with dynamic linked libraries"
OFF
)
option
(
WITH_GPU
"Compile PaddlePaddle with gpu"
${
CUDA_FOUND
}
)
option
(
WITH_DOUBLE
"Compile PaddlePaddle with double precision, otherwise use single precision"
OFF
)
option
(
WITH_AVX
"Compile PaddlePaddle with avx intrinsics"
${
AVX_FOUND
}
)
option
(
WITH_PYTHON
"Compile PaddlePaddle with python interpreter"
ON
)
option
(
WITH_STYLE_CHECK
"Style Check for PaddlePaddle"
ON
)
option
(
WITH_RDMA
"Compile PaddlePaddle with rdma support"
OFF
)
option
(
WITH_TIMER
"Compile PaddlePaddle use timer"
OFF
)
option
(
WITH_PROFILER
"Compile PaddlePaddle use gpu profiler"
OFF
)
option
(
WITH_TESTING
"Compile and run unittest for PaddlePaddle"
ON
)
option
(
WITH_DOC
"Compile PaddlePaddle with documentation"
OFF
)
option
(
WITH_SWIG_PY
"Compile PaddlePaddle with py PaddlePaddle prediction api"
ON
)
option
(
ON_TRAVIS
"Running test on travis-ci or not."
OFF
)
option
(
ON_COVERALLS
"Generating code coverage data on coveralls or not."
OFF
)
option
(
COVERALLS_UPLOAD
"Uploading the generated coveralls json."
ON
)
################################ Configurations #######################################
option
(
WITH_GPU
"Compile PaddlePaddle with NVIDIA GPU"
${
CUDA_FOUND
}
)
option
(
WITH_AVX
"Compile PaddlePaddle with AVX intrinsics"
${
AVX_FOUND
}
)
option
(
WITH_DSO
"Compile PaddlePaddle with dynamic linked CUDA"
OFF
)
option
(
WITH_TESTING
"Compile PaddlePaddle with unit testing"
ON
)
option
(
WITH_SWIG_PY
"Compile PaddlePaddle with inference api"
ON
)
option
(
WITH_STYLE_CHECK
"Compile PaddlePaddle with style check"
ON
)
option
(
WITH_PYTHON
"Compile PaddlePaddle with python interpreter"
ON
)
option
(
WITH_DOUBLE
"Compile PaddlePaddle with double precision"
OFF
)
option
(
WITH_RDMA
"Compile PaddlePaddle with RDMA support"
OFF
)
option
(
WITH_TIMER
"Compile PaddlePaddle with stats timer"
OFF
)
option
(
WITH_PROFILER
"Compile PaddlePaddle with GPU profiler"
OFF
)
option
(
WITH_DOC
"Compile PaddlePaddle with documentation"
OFF
)
option
(
ON_COVERALLS
"Compile PaddlePaddle with code coverage"
OFF
)
option
(
COVERALLS_UPLOAD
"Package code coverage data to coveralls"
OFF
)
option
(
ON_TRAVIS
"Exclude special unit test on Travis CI"
OFF
)
########################################################################################
include
(
external/zlib
)
# download, build, install zlib
include
(
external/gflags
)
# download, build, install gflags
...
...
@@ -63,7 +64,6 @@ include(flags) # set paddle compile flags
include
(
cudnn
)
# set cudnn libraries
include
(
version
)
# set PADDLE_VERSION
include
(
coveralls
)
# set code coverage
include
(
python_module
)
# set python module
include
(
configure
)
# add paddle env configuration
...
...
cmake/configure.cmake
浏览文件 @
203db079
...
...
@@ -12,6 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
if
(
NOT WITH_PYTHON
)
add_definitions
(
-DPADDLE_NO_PYTHON
)
endif
(
NOT WITH_PYTHON
)
if
(
WITH_DSO
)
add_definitions
(
-DPADDLE_USE_DSO
)
endif
(
WITH_DSO
)
...
...
cmake/external/python.cmake
浏览文件 @
203db079
...
...
@@ -13,192 +13,210 @@
# limitations under the License.
INCLUDE
(
ExternalProject
)
INCLUDE
(
python_module
)
FIND_PACKAGE
(
PythonInterp 2.7
)
FIND_PACKAGE
(
PythonLibs 2.7
)
SET
(
py_env
""
)
IF
(
PYTHONLIBS_FOUND AND PYTHONINTERP_FOUND
)
find_python_module
(
pip REQUIRED
)
find_python_module
(
numpy REQUIRED
)
find_python_module
(
wheel REQUIRED
)
find_python_module
(
google.protobuf REQUIRED
)
FIND_PACKAGE
(
NumPy REQUIRED
)
ELSE
(
PYTHONLIBS_FOUND AND PYTHONINTERP_FOUND
)
##################################### PYTHON ########################################
SET
(
PYTHON_SOURCES_DIR
${
CMAKE_CURRENT_SOURCE_DIR
}
/third_party/python
)
SET
(
PYTHON_INSTALL_DIR
${
CMAKE_CURRENT_SOURCE_DIR
}
/third_party/install/python
)
SET
(
_python_DIR
${
PYTHON_INSTALL_DIR
}
)
IF
(
UNIX
)
SET
(
PYTHON_FOUND ON
)
SET
(
PYTHON_INCLUDE_DIR
"
${
PYTHON_INSTALL_DIR
}
/include/python2.7"
CACHE PATH
"Python include dir"
FORCE
)
SET
(
PYTHON_LIBRARIES
"
${
PYTHON_INSTALL_DIR
}
/lib/libpython2.7.a"
CACHE FILEPATH
"Python library"
FORCE
)
SET
(
PYTHON_EXECUTABLE
${
PYTHON_INSTALL_DIR
}
/bin/python CACHE FILEPATH
"Python executable"
FORCE
)
SET
(
PY_SITE_PACKAGES_PATH
"
${
PYTHON_INSTALL_DIR
}
/lib/python2.7/site-packages"
CACHE PATH
"Python site-packages path"
FORCE
)
ELSEIF
(
WIN32
)
SET
(
PYTHON_FOUND ON
)
SET
(
PYTHON_INCLUDE_DIR
"
${
PYTHON_INSTALL_DIR
}
/include"
CACHE PATH
"Python include dir"
FORCE
)
SET
(
PYTHON_LIBRARIES
"
${
PYTHON_INSTALL_DIR
}
/libs/python27.lib"
CACHE FILEPATH
"Python library"
FORCE
)
SET
(
PYTHON_EXECUTABLE
"
${
PYTHON_INSTALL_DIR
}
/bin/python.exe"
CACHE FILEPATH
"Python executable"
FORCE
)
SET
(
PY_SITE_PACKAGES_PATH
"
${
PYTHON_INSTALL_DIR
}
/Lib/site-packages"
CACHE PATH
"Python site-packages path"
FORCE
)
ELSE
()
MESSAGE
(
FATAL_ERROR
"Unknown system !"
)
ENDIF
()
##################################### PYTHON ########################################
SET
(
PYTHON_SOURCES_DIR
${
CMAKE_CURRENT_SOURCE_DIR
}
/third_party/python
)
SET
(
PYTHON_INSTALL_DIR
${
CMAKE_CURRENT_SOURCE_DIR
}
/third_party/install/python
)
SET
(
_python_DIR
${
PYTHON_INSTALL_DIR
}
)
IF
(
UNIX
)
SET
(
PYTHON_FOUND ON
)
SET
(
PYTHON_INCLUDE_DIR
"
${
PYTHON_INSTALL_DIR
}
/include/python2.7"
CACHE PATH
"Python include dir"
FORCE
)
SET
(
PYTHON_LIBRARIES
"
${
PYTHON_INSTALL_DIR
}
/lib/libpython2.7.a"
CACHE FILEPATH
"Python library"
FORCE
)
SET
(
PYTHON_EXECUTABLE
${
PYTHON_INSTALL_DIR
}
/bin/python CACHE FILEPATH
"Python executable"
FORCE
)
SET
(
PY_SITE_PACKAGES_PATH
"
${
PYTHON_INSTALL_DIR
}
/lib/python2.7/site-packages"
CACHE PATH
"Python site-packages path"
FORCE
)
ELSEIF
(
WIN32
)
SET
(
PYTHON_FOUND ON
)
SET
(
PYTHON_INCLUDE_DIR
"
${
PYTHON_INSTALL_DIR
}
/include"
CACHE PATH
"Python include dir"
FORCE
)
SET
(
PYTHON_LIBRARIES
"
${
PYTHON_INSTALL_DIR
}
/libs/python27.lib"
CACHE FILEPATH
"Python library"
FORCE
)
SET
(
PYTHON_EXECUTABLE
"
${
PYTHON_INSTALL_DIR
}
/bin/python.exe"
CACHE FILEPATH
"Python executable"
FORCE
)
SET
(
PY_SITE_PACKAGES_PATH
"
${
PYTHON_INSTALL_DIR
}
/Lib/site-packages"
CACHE PATH
"Python site-packages path"
FORCE
)
ELSE
()
MESSAGE
(
FATAL_ERROR
"Unknown system !"
)
ENDIF
()
SET
(
py_env
PATH=
${
PYTHON_INSTALL_DIR
}
/bin/:$ENV{PATH}
PYTHONHOME=
${
PYTHON_INSTALL_DIR
}
PYTHONPATH=
${
PYTHON_INSTALL_DIR
}
/lib:
${
PYTHON_INSTALL_DIR
}
/lib/python2.7:
${
PY_SITE_PACKAGES_PATH
}
)
INCLUDE_DIRECTORIES
(
${
PYTHON_INCLUDE_DIR
}
)
IF
(
APPLE
)
LIST
(
APPEND EXTERNAL_PROJECT_OPTIONAL_CMAKE_ARGS
-DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=ON
)
ENDIF
()
SET
(
EXTERNAL_PROJECT_OPTIONAL_CMAKE_CACHE_ARGS
)
# Force Python build to "Release".
IF
(
CMAKE_CONFIGURATION_TYPES
)
SET
(
SAVED_CMAKE_CFG_INTDIR
${
CMAKE_CFG_INTDIR
}
)
SET
(
CMAKE_CFG_INTDIR
"Release"
)
ELSE
()
LIST
(
APPEND EXTERNAL_PROJECT_OPTIONAL_CMAKE_CACHE_ARGS
-DCMAKE_BUILD_TYPE:STRING=Release
)
ENDIF
()
ExternalProject_Add
(
python
${
EXTERNAL_PROJECT_LOG_ARGS
}
GIT_REPOSITORY
"https://github.com/python-cmake-buildsystem/python-cmake-buildsystem.git"
PREFIX
${
PYTHON_SOURCES_DIR
}
UPDATE_COMMAND
""
CMAKE_ARGS -DPYTHON_VERSION=2.7.12
CMAKE_ARGS -DCMAKE_CXX_COMPILER=
${
CMAKE_CXX_COMPILER
}
CMAKE_ARGS -DCMAKE_C_COMPILER=
${
CMAKE_C_COMPILER
}
CMAKE_CACHE_ARGS
-DCMAKE_INSTALL_PREFIX:PATH=
${
PYTHON_INSTALL_DIR
}
-DBUILD_LIBPYTHON_SHARED:BOOL=OFF
-DUSE_SYSTEM_LIBRARIES:BOOL=OFF
-DZLIB_ROOT:FILEPATH=
${
ZLIB_ROOT
}
-DZLIB_INCLUDE_DIR:PATH=
${
ZLIB_INCLUDE_DIR
}
-DZLIB_LIBRARY:FILEPATH=
${
ZLIB_LIBRARIES
}
-DDOWNLOAD_SOURCES:BOOL=ON
-DINSTALL_WINDOWS_TRADITIONAL:BOOL=OFF
${
EXTERNAL_PROJECT_OPTIONAL_CMAKE_CACHE_ARGS
}
${
EXTERNAL_PROJECT_OPTIONAL_CMAKE_ARGS
}
DEPENDS zlib
)
####################################################################################
##################################### SETUPTOOLS ###################################
SET
(
SETUPTOOLS_SOURCES_DIR
${
PYTHON_SOURCES_DIR
}
/setuptools
)
ExternalProject_Add
(
setuptools
${
EXTERNAL_PROJECT_LOG_ARGS
}
PREFIX
${
SETUPTOOLS_SOURCES_DIR
}
URL
"https://pypi.python.org/packages/source/s/setuptools/setuptools-18.3.2.tar.gz"
BUILD_IN_SOURCE 1
PATCH_COMMAND
""
UPDATE_COMMAND
""
CONFIGURE_COMMAND
""
INSTALL_COMMAND
""
BUILD_COMMAND env
${
py_env
}
${
PYTHON_EXECUTABLE
}
setup.py install
DEPENDS python zlib
)
#####################################################################################
##################################### SIX ###########################################
SET
(
SIX_SOURCES_DIR
${
PYTHON_SOURCES_DIR
}
/six
)
ExternalProject_Add
(
six
${
EXTERNAL_PROJECT_LOG_ARGS
}
PREFIX
${
SIX_SOURCES_DIR
}
URL https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz
BUILD_IN_SOURCE 1
PATCH_COMMAND
""
UPDATE_COMMAND
""
CONFIGURE_COMMAND
""
INSTALL_COMMAND
""
BUILD_COMMAND env
${
py_env
}
${
PYTHON_EXECUTABLE
}
setup.py install
DEPENDS python setuptools
)
#####################################################################################
##################################### CYTHON ########################################
SET
(
CYTHON_SOURCES_DIR
${
PYTHON_SOURCES_DIR
}
/cython
)
ExternalProject_Add
(
cython
${
EXTERNAL_PROJECT_LOG_ARGS
}
PREFIX
${
CYTHON_SOURCES_DIR
}
URL https://github.com/cython/cython/archive/0.25.2.tar.gz
GIT_TAG 0.25.2
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND
""
PATCH_COMMAND
""
UPDATE_COMMAND
""
INSTALL_COMMAND
""
BUILD_COMMAND env
${
py_env
}
${
PYTHON_EXECUTABLE
}
setup.py install
DEPENDS python
)
####################################################################################
##################################### NUMPY ########################################
SET
(
NUMPY_SOURCES_DIR
${
PYTHON_SOURCES_DIR
}
/numpy
)
SET
(
NUMPY_TAG_VERSION
"v1.11.3"
)
SET
(
NUMPY_VERSION
"1.11.3"
)
SET
(
EGG_NAME
""
)
SET
(
PYTHON_NUMPY_INCLUDE_DIR
""
)
IF
(
WIN32
)
SET
(
EGG_NAME
"numpy-
${
NUMPY_VERSION
}
-py2.7-
${
HOST_SYSTEM
}
.egg"
)
ELSE
(
WIN32
)
IF
(
APPLE
)
SET
(
EGG_NAME
"numpy-
${
NUMPY_VERSION
}
-py2.7-
${
HOST_SYSTEM
}
-
${
MACOS_VERSION
}
"
)
ELSE
(
APPLE
)
SET
(
EGG_NAME
"numpy-
${
NUMPY_VERSION
}
-py2.7-linux"
)
SET
(
EGG_NAME
"numpy-
${
NUMPY_VERSION
}
-py2.7-linux"
)
ENDIF
(
APPLE
)
FOREACH
(
suffix x86_64 intel fat64 fat32 universal
)
LIST
(
APPEND PYTHON_NUMPY_INCLUDE_DIR
${
PY_SITE_PACKAGES_PATH
}
/
${
EGG_NAME
}
-
${
suffix
}
.egg/numpy/core/include
)
ENDFOREACH
()
ENDIF
(
WIN32
)
LIST
(
APPEND EXTERNAL_PROJECT_OPTIONAL_CMAKE_ARGS
-DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=ON
)
ENDIF
()
SET
(
EXTERNAL_PROJECT_OPTIONAL_CMAKE_CACHE_ARGS
)
# Force Python build to "Release".
IF
(
CMAKE_CONFIGURATION_TYPES
)
SET
(
SAVED_CMAKE_CFG_INTDIR
${
CMAKE_CFG_INTDIR
}
)
SET
(
CMAKE_CFG_INTDIR
"Release"
)
ELSE
()
LIST
(
APPEND EXTERNAL_PROJECT_OPTIONAL_CMAKE_CACHE_ARGS
-DCMAKE_BUILD_TYPE:STRING=Release
)
ENDIF
()
ExternalProject_Add
(
python
${
EXTERNAL_PROJECT_LOG_ARGS
}
GIT_REPOSITORY
"https://github.com/python-cmake-buildsystem/python-cmake-buildsystem.git"
PREFIX
${
PYTHON_SOURCES_DIR
}
UPDATE_COMMAND
""
CMAKE_ARGS -DPYTHON_VERSION=2.7.12
CMAKE_ARGS -DCMAKE_CXX_COMPILER=
${
CMAKE_CXX_COMPILER
}
CMAKE_ARGS -DCMAKE_C_COMPILER=
${
CMAKE_C_COMPILER
}
CMAKE_CACHE_ARGS
-DCMAKE_INSTALL_PREFIX:PATH=
${
PYTHON_INSTALL_DIR
}
-DBUILD_LIBPYTHON_SHARED:BOOL=OFF
-DUSE_SYSTEM_LIBRARIES:BOOL=OFF
-DZLIB_ROOT:FILEPATH=
${
ZLIB_ROOT
}
-DZLIB_INCLUDE_DIR:PATH=
${
ZLIB_INCLUDE_DIR
}
-DZLIB_LIBRARY:FILEPATH=
${
ZLIB_LIBRARIES
}
-DDOWNLOAD_SOURCES:BOOL=ON
-DINSTALL_WINDOWS_TRADITIONAL:BOOL=OFF
${
EXTERNAL_PROJECT_OPTIONAL_CMAKE_CACHE_ARGS
}
${
EXTERNAL_PROJECT_OPTIONAL_CMAKE_ARGS
}
DEPENDS zlib
)
SET
(
py_env
PATH=
${
PYTHON_INSTALL_DIR
}
/bin
PYTHONHOME=
${
PYTHON_INSTALL_DIR
}
PYTHONPATH=
${
PYTHON_INSTALL_DIR
}
/lib:
${
PYTHON_INSTALL_DIR
}
/lib/python2.7:
${
PY_SITE_PACKAGES_PATH
}
)
####################################################################################
##################################### SETUPTOOLS ###################################
SET
(
SETUPTOOLS_SOURCES_DIR
${
PYTHON_SOURCES_DIR
}
/setuptools
)
ExternalProject_Add
(
setuptools
${
EXTERNAL_PROJECT_LOG_ARGS
}
PREFIX
${
SETUPTOOLS_SOURCES_DIR
}
URL
"https://pypi.python.org/packages/source/s/setuptools/setuptools-18.3.2.tar.gz"
BUILD_IN_SOURCE 1
PATCH_COMMAND
""
UPDATE_COMMAND
""
CONFIGURE_COMMAND
""
INSTALL_COMMAND
""
BUILD_COMMAND env
${
py_env
}
${
PYTHON_EXECUTABLE
}
setup.py install
DEPENDS python zlib
)
#####################################################################################
##################################### SIX ###########################################
SET
(
SIX_SOURCES_DIR
${
PYTHON_SOURCES_DIR
}
/six
)
ExternalProject_Add
(
six
${
EXTERNAL_PROJECT_LOG_ARGS
}
PREFIX
${
SIX_SOURCES_DIR
}
URL https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz
BUILD_IN_SOURCE 1
PATCH_COMMAND
""
UPDATE_COMMAND
""
CONFIGURE_COMMAND
""
INSTALL_COMMAND
""
BUILD_COMMAND env
${
py_env
}
${
PYTHON_EXECUTABLE
}
setup.py install
DEPENDS python setuptools
)
#####################################################################################
##################################### CYTHON ########################################
SET
(
CYTHON_SOURCES_DIR
${
PYTHON_SOURCES_DIR
}
/cython
)
ExternalProject_Add
(
cython
${
EXTERNAL_PROJECT_LOG_ARGS
}
PREFIX
${
CYTHON_SOURCES_DIR
}
URL https://github.com/cython/cython/archive/0.25.2.tar.gz
GIT_TAG 0.25.2
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND
""
PATCH_COMMAND
""
UPDATE_COMMAND
""
INSTALL_COMMAND
""
BUILD_COMMAND env
${
py_env
}
${
PYTHON_EXECUTABLE
}
setup.py install
DEPENDS python
)
####################################################################################
##################################### NUMPY ########################################
SET
(
NUMPY_SOURCES_DIR
${
PYTHON_SOURCES_DIR
}
/numpy
)
SET
(
NUMPY_TAG_VERSION
"v1.11.3"
)
SET
(
NUMPY_VERSION
"1.11.3"
)
SET
(
EGG_NAME
""
)
SET
(
PYTHON_NUMPY_INCLUDE_DIR
""
)
IF
(
WIN32
)
SET
(
EGG_NAME
"numpy-
${
NUMPY_VERSION
}
-py2.7-
${
HOST_SYSTEM
}
.egg"
)
ELSE
(
WIN32
)
IF
(
APPLE
)
SET
(
EGG_NAME
"numpy-
${
NUMPY_VERSION
}
-py2.7-
${
HOST_SYSTEM
}
-
${
MACOS_VERSION
}
"
)
ELSE
(
APPLE
)
SET
(
EGG_NAME
"numpy-
${
NUMPY_VERSION
}
-py2.7-linux"
)
SET
(
EGG_NAME
"numpy-
${
NUMPY_VERSION
}
-py2.7-linux"
)
ENDIF
(
APPLE
)
FOREACH
(
suffix x86_64 intel fat64 fat32 universal
)
LIST
(
APPEND PYTHON_NUMPY_INCLUDE_DIR
${
PY_SITE_PACKAGES_PATH
}
/
${
EGG_NAME
}
-
${
suffix
}
.egg/numpy/core/include
)
ENDFOREACH
()
ENDIF
(
WIN32
)
ExternalProject_Add
(
numpy
${
EXTERNAL_PROJECT_LOG_ARGS
}
GIT_REPOSITORY https://github.com/numpy/numpy.git
GIT_TAG
${
NUMPY_TAG_VERSION
}
CONFIGURE_COMMAND
""
UPDATE_COMMAND
""
PREFIX
${
NUMPY_SOURCES_DIR
}
BUILD_COMMAND env
${
py_env
}
${
PYTHON_EXECUTABLE
}
setup.py build
INSTALL_COMMAND env
${
py_env
}
${
PYTHON_EXECUTABLE
}
setup.py install
BUILD_IN_SOURCE 1
DEPENDS python setuptools cython
)
####################################################################################
##################################### WHEEL ########################################
SET
(
WHEEL_SOURCES_DIR
${
PYTHON_SOURCES_DIR
}
/wheel
)
ExternalProject_Add
(
wheel
${
EXTERNAL_PROJECT_LOG_ARGS
}
URL https://pypi.python.org/packages/source/w/wheel/wheel-0.29.0.tar.gz
PREFIX
${
WHEEL_SOURCES_DIR
}
CONFIGURE_COMMAND
""
UPDATE_COMMAND
""
BUILD_COMMAND
""
INSTALL_COMMAND env
${
py_env
}
${
PYTHON_EXECUTABLE
}
setup.py install
BUILD_IN_SOURCE 1
DEPENDS python setuptools
)
####################################################################################
################################### PROTOBUF #######################################
SET
(
PY_PROTOBUF_SOURCES_DIR
${
PYTHON_SOURCES_DIR
}
/protobuf
)
ExternalProject_Add
(
python-protobuf
${
EXTERNAL_PROJECT_LOG_ARGS
}
URL https://pypi.python.org/packages/e0/b0/0a1b364fe8a7d177b4b7d4dca5b798500dc57a7273b93cca73931b305a6a/protobuf-3.1.0.post1.tar.gz
URL_MD5 38b5fb160c768d2f8444d0c6d637ff91
PREFIX
${
PY_PROTOBUF_SOURCES_DIR
}
BUILD_IN_SOURCE 1
PATCH_COMMAND
""
CONFIGURE_COMMAND
""
BUILD_COMMAND env
${
py_env
}
${
PYTHON_EXECUTABLE
}
setup.py build
INSTALL_COMMAND env
${
py_env
}
${
PYTHON_EXECUTABLE
}
setup.py install
DEPENDS python setuptools six
)
####################################################################################
LIST
(
APPEND external_project_dependencies python setuptools six cython wheel python-protobuf numpy
)
ENDIF
(
PYTHONLIBS_FOUND AND PYTHONINTERP_FOUND
)
INCLUDE_DIRECTORIES
(
${
PYTHON_INCLUDE_DIR
}
)
INCLUDE_DIRECTORIES
(
${
PYTHON_NUMPY_INCLUDE_DIR
}
)
ExternalProject_Add
(
numpy
${
EXTERNAL_PROJECT_LOG_ARGS
}
GIT_REPOSITORY https://github.com/numpy/numpy.git
GIT_TAG
${
NUMPY_TAG_VERSION
}
CONFIGURE_COMMAND
""
UPDATE_COMMAND
""
PREFIX
${
NUMPY_SOURCES_DIR
}
BUILD_COMMAND env
${
py_env
}
${
PYTHON_EXECUTABLE
}
setup.py build
INSTALL_COMMAND env
${
py_env
}
${
PYTHON_EXECUTABLE
}
setup.py install
BUILD_IN_SOURCE 1
DEPENDS python setuptools cython
)
####################################################################################
##################################### WHEEL ########################################
SET
(
WHEEL_SOURCES_DIR
${
PYTHON_SOURCES_DIR
}
/wheel
)
ExternalProject_Add
(
wheel
${
EXTERNAL_PROJECT_LOG_ARGS
}
URL https://pypi.python.org/packages/source/w/wheel/wheel-0.29.0.tar.gz
PREFIX
${
WHEEL_SOURCES_DIR
}
CONFIGURE_COMMAND
""
UPDATE_COMMAND
""
BUILD_COMMAND
""
INSTALL_COMMAND env
${
py_env
}
${
PYTHON_EXECUTABLE
}
setup.py install
BUILD_IN_SOURCE 1
DEPENDS python setuptools
)
####################################################################################
################################### PROTOBUF #######################################
SET
(
PY_PROTOBUF_SOURCES_DIR
${
PYTHON_SOURCES_DIR
}
/protobuf
)
ExternalProject_Add
(
python-protobuf
${
EXTERNAL_PROJECT_LOG_ARGS
}
URL https://pypi.python.org/packages/e0/b0/0a1b364fe8a7d177b4b7d4dca5b798500dc57a7273b93cca73931b305a6a/protobuf-3.1.0.post1.tar.gz
URL_MD5 38b5fb160c768d2f8444d0c6d637ff91
PREFIX
${
PY_PROTOBUF_SOURCES_DIR
}
BUILD_IN_SOURCE 1
PATCH_COMMAND
""
CONFIGURE_COMMAND
""
BUILD_COMMAND env PATH=
${
PROTOBUF_INSTALL_DIR
}
/bin:$ENV{PATH}
${
py_env
}
${
PYTHON_EXECUTABLE
}
setup.py build
INSTALL_COMMAND env PATH=
${
PROTOBUF_INSTALL_DIR
}
/bin:$ENV{PATH}
${
py_env
}
${
PYTHON_EXECUTABLE
}
setup.py install
DEPENDS python setuptools six
)
LIST
(
APPEND external_project_dependencies python setuptools six cython numpy wheel python-protobuf
)
MESSAGE
(
"[Paddle] Python Executable:
${
PYTHON_EXECUTABLE
}
"
)
MESSAGE
(
"[Paddle] Python Include:
${
PYTHON_INCLUDE_DIRS
}
"
)
MESSAGE
(
"[Paddle] Python Libraries:
${
PYTHON_LIBRARIES
}
"
)
cmake/external/swig.cmake
浏览文件 @
203db079
...
...
@@ -12,59 +12,63 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# build swig as an external project
INCLUDE
(
ExternalProject
)
FIND_PACKAGE
(
SWIG
)
SET
(
SWIG_SOURCES_DIR
${
CMAKE_CURRENT_SOURCE_DIR
}
/third_party/swig
)
SET
(
SWIG_INSTALL_DIR
${
CMAKE_CURRENT_SOURCE_DIR
}
/third_party/install/swig
)
SET
(
SWIG_TARGET_VERSION
"3.0.2"
)
SET
(
SWIG_DOWNLOAD_SRC_MD5
"62f9b0d010cef36a13a010dc530d0d41"
)
SET
(
SWIG_DOWNLOAD_WIN_MD5
"3f18de4fc09ab9abb0d3be37c11fbc8f"
)
IF
(
NOT SWIG_FOUND
)
# build swig as an external project
INCLUDE
(
ExternalProject
)
IF
(
WIN32
)
# swig.exe available as pre-built binary on Windows:
ExternalProject_Add
(
swig
URL http://prdownloads.sourceforge.net/swig/swigwin-
${
SWIG_TARGET_VERSION
}
.zip
URL_MD5
${
SWIG_DOWNLOAD_WIN_MD5
}
SOURCE_DIR
${
SWIG_SOURCES_DIR
}
CONFIGURE_COMMAND
""
BUILD_COMMAND
""
INSTALL_COMMAND
""
UPDATE_COMMAND
""
)
SET
(
SWIG_DIR
${
SWIG_SOURCES_DIR
}
CACHE FILEPATH
"SWIG Directory"
FORCE
)
SET
(
SWIG_EXECUTABLE
${
SWIG_SOURCES_DIR
}
/swig.exe CACHE FILEPATH
"SWIG Executable"
FORCE
)
ELSE
(
WIN32
)
# From PCRE configure
ExternalProject_Add
(
pcre
${
EXTERNAL_PROJECT_LOG_ARGS
}
GIT_REPOSITORY https://github.com/svn2github/pcre.git
PREFIX
${
SWIG_SOURCES_DIR
}
/pcre
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=
${
SWIG_INSTALL_DIR
}
/pcre
)
SET
(
SWIG_SOURCES_DIR
${
CMAKE_CURRENT_SOURCE_DIR
}
/third_party/swig
)
SET
(
SWIG_INSTALL_DIR
${
CMAKE_CURRENT_SOURCE_DIR
}
/third_party/install/swig
)
SET
(
SWIG_TARGET_VERSION
"3.0.2"
)
SET
(
SWIG_DOWNLOAD_SRC_MD5
"62f9b0d010cef36a13a010dc530d0d41"
)
SET
(
SWIG_DOWNLOAD_WIN_MD5
"3f18de4fc09ab9abb0d3be37c11fbc8f"
)
# swig uses bison find it by cmake and pass it down
FIND_PACKAGE
(
BISON
)
IF
(
WIN32
)
# swig.exe available as pre-built binary on Windows:
ExternalProject_Add
(
swig
URL http://prdownloads.sourceforge.net/swig/swigwin-
${
SWIG_TARGET_VERSION
}
.zip
URL_MD5
${
SWIG_DOWNLOAD_WIN_MD5
}
SOURCE_DIR
${
SWIG_SOURCES_DIR
}
CONFIGURE_COMMAND
""
BUILD_COMMAND
""
INSTALL_COMMAND
""
UPDATE_COMMAND
""
)
SET
(
SWIG_DIR
${
SWIG_SOURCES_DIR
}
CACHE FILEPATH
"SWIG Directory"
FORCE
)
SET
(
SWIG_EXECUTABLE
${
SWIG_SOURCES_DIR
}
/swig.exe CACHE FILEPATH
"SWIG Executable"
FORCE
)
ELSE
(
WIN32
)
# From PCRE configure
ExternalProject_Add
(
pcre
${
EXTERNAL_PROJECT_LOG_ARGS
}
GIT_REPOSITORY https://github.com/svn2github/pcre.git
PREFIX
${
SWIG_SOURCES_DIR
}
/pcre
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=
${
SWIG_INSTALL_DIR
}
/pcre
)
# From SWIG configure
ExternalProject_Add
(
swig
GIT_REPOSITORY https://github.com/swig/swig.git
GIT_TAG rel-3.0.10
PREFIX
${
SWIG_SOURCES_DIR
}
CONFIGURE_COMMAND cd
${
SWIG_SOURCES_DIR
}
/src/swig && ./autogen.sh
CONFIGURE_COMMAND cd
${
SWIG_SOURCES_DIR
}
/src/swig &&
env
"PCRE_LIBS=
${
SWIG_INSTALL_DIR
}
/pcre/lib/libpcre.a
${
SWIG_INSTALL_DIR
}
/pcre/lib/libpcrecpp.a
${
SWIG_INSTALL_DIR
}
/pcre/lib/libpcreposix.a"
./configure
--prefix=
${
SWIG_INSTALL_DIR
}
--with-pcre-prefix=
${
SWIG_INSTALL_DIR
}
/pcre
BUILD_COMMAND cd
${
SWIG_SOURCES_DIR
}
/src/swig && make
INSTALL_COMMAND cd
${
SWIG_SOURCES_DIR
}
/src/swig && make install
UPDATE_COMMAND
""
DEPENDS pcre
)
# swig uses bison find it by cmake and pass it down
FIND_PACKAGE
(
BISON
)
SET
(
SWIG_DIR
${
SWIG_INSTALL_DIR
}
/share/swig/
${
SWIG_TARGET_VERSION
}
)
SET
(
SWIG_EXECUTABLE
${
SWIG_INSTALL_DIR
}
/bin/swig
)
ENDIF
(
WIN32
)
# From SWIG configure
ExternalProject_Add
(
swig
GIT_REPOSITORY https://github.com/swig/swig.git
GIT_TAG rel-3.0.10
PREFIX
${
SWIG_SOURCES_DIR
}
CONFIGURE_COMMAND cd
${
SWIG_SOURCES_DIR
}
/src/swig && ./autogen.sh
CONFIGURE_COMMAND cd
${
SWIG_SOURCES_DIR
}
/src/swig &&
env
"PCRE_LIBS=
${
SWIG_INSTALL_DIR
}
/pcre/lib/libpcre.a
${
SWIG_INSTALL_DIR
}
/pcre/lib/libpcrecpp.a
${
SWIG_INSTALL_DIR
}
/pcre/lib/libpcreposix.a"
./configure
--prefix=
${
SWIG_INSTALL_DIR
}
--with-pcre-prefix=
${
SWIG_INSTALL_DIR
}
/pcre
BUILD_COMMAND cd
${
SWIG_SOURCES_DIR
}
/src/swig && make
INSTALL_COMMAND cd
${
SWIG_SOURCES_DIR
}
/src/swig && make install
UPDATE_COMMAND
""
DEPENDS pcre
)
LIST
(
APPEND external_project_dependencies swig
)
SET
(
SWIG_DIR
${
SWIG_INSTALL_DIR
}
/share/swig/
${
SWIG_TARGET_VERSION
}
)
SET
(
SWIG_EXECUTABLE
${
SWIG_INSTALL_DIR
}
/bin/swig
)
ENDIF
(
WIN32
)
LIST
(
APPEND external_project_dependencies swig
)
ENDIF
(
NOT SWIG_FOUND
)
cmake/external/warpctc.cmake
浏览文件 @
203db079
...
...
@@ -53,6 +53,7 @@ ExternalProject_Add(
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=
${
WARPCTC_INSTALL_DIR
}
CMAKE_ARGS -DWITH_GPU=
${
WITH_GPU
}
CMAKE_ARGS -DWITH_OMP=
${
USE_OMP
}
CMAKE_ARGS -DBUILD_SHARED=OFF
)
LIST
(
APPEND external_project_dependencies warpctc
)
demo/traffic_prediction/README
0 → 100644
浏览文件 @
203db079
run by:
cd ./data
sh get_data.sh
cd ..
sh train.sh
sh predict.sh
demo/traffic_prediction/data/get_data.sh
0 → 100755
浏览文件 @
203db079
#!/bin/bash
# Copyright (c) 2016 PaddlePaddle Authors, 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.
set
-e
set
-x
DIR
=
"
$(
cd
"
$(
dirname
"
$0
"
)
"
;
pwd
-P
)
"
cd
$DIR
#download the dataset
echo
"Downloading traffic data..."
wget http://paddlepaddle.cdn.bcebos.com/demo/traffic/traffic_data.tar.gz
#extract package
echo
"Unzipping..."
tar
-zxvf
traffic_data.tar.gz
echo
"data/speeds.csv"
>
train.list
echo
"data/speeds.csv"
>
test.list
echo
"data/speeds.csv"
>
pred.list
echo
"Done."
demo/traffic_prediction/dataprovider.py
0 → 100644
浏览文件 @
203db079
# Copyright (c) 2016 PaddlePaddle Authors, 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.PyDataProvider2
import
*
import
sys
import
numpy
as
np
TERM_NUM
=
24
FORECASTING_NUM
=
24
LABEL_VALUE_NUM
=
4
def
initHook
(
settings
,
file_list
,
**
kwargs
):
"""
Init hook is invoked before process data. It will set obj.slots and store data meta.
:param settings: global object. It will passed to process routine.
:type obj: object
:param file_list: the meta file object, which passed from trainer_config.py,but unused in this function.
:param kwargs: unused other arguments.
"""
del
kwargs
#unused
settings
.
pool_size
=
sys
.
maxint
#Use a time seires of the past as feature.
#Dense_vector's expression form is [float,float,...,float]
settings
.
input_types
=
[
dense_vector
(
TERM_NUM
)]
#There are next FORECASTING_NUM fragments you need predict.
#Every predicted condition at time point has four states.
for
i
in
range
(
FORECASTING_NUM
):
settings
.
input_types
.
append
(
integer_value
(
LABEL_VALUE_NUM
))
@
provider
(
init_hook
=
initHook
,
cache
=
CacheType
.
CACHE_PASS_IN_MEM
,
should_shuffle
=
True
)
def
process
(
settings
,
file_name
):
with
open
(
file_name
)
as
f
:
#abandon fields name
f
.
next
()
for
row_num
,
line
in
enumerate
(
f
):
speeds
=
map
(
int
,
line
.
rstrip
(
'
\r\n
'
).
split
(
","
)[
1
:])
# Get the max index.
end_time
=
len
(
speeds
)
# Scanning and generating samples
for
i
in
range
(
TERM_NUM
,
end_time
-
FORECASTING_NUM
):
# For dense slot
pre_spd
=
map
(
float
,
speeds
[
i
-
TERM_NUM
:
i
])
# Integer value need predicting, values start from 0, so every one minus 1.
fol_spd
=
[
j
-
1
for
j
in
speeds
[
i
:
i
+
FORECASTING_NUM
]]
# Predicting label is missing, abandon the sample.
if
-
1
in
fol_spd
:
continue
yield
[
pre_spd
]
+
fol_spd
def
predict_initHook
(
settings
,
file_list
,
**
kwargs
):
settings
.
pool_size
=
sys
.
maxint
settings
.
input_types
=
[
dense_vector
(
TERM_NUM
)]
@
provider
(
init_hook
=
predict_initHook
,
should_shuffle
=
False
)
def
process_predict
(
settings
,
file_name
):
with
open
(
file_name
)
as
f
:
#abandon fields name
f
.
next
()
for
row_num
,
line
in
enumerate
(
f
):
speeds
=
map
(
int
,
line
.
rstrip
(
'
\r\n
'
).
split
(
","
))
end_time
=
len
(
speeds
)
pre_spd
=
map
(
float
,
speeds
[
end_time
-
TERM_NUM
:
end_time
])
yield
pre_spd
demo/traffic_prediction/gen_result.py
0 → 100644
浏览文件 @
203db079
# Copyright (c) 2016 PaddlePaddle Authors, 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.
res
=
[]
with
open
(
'./rank-00000'
)
as
f
:
for
line
in
f
:
pred
=
map
(
int
,
line
.
strip
(
'
\r\n
;'
).
split
(
";"
))
#raw prediction range from 0 to 3
res
.
append
([
i
+
1
for
i
in
pred
])
file_name
=
open
(
'./data/pred.list'
).
read
().
strip
(
'
\r\n
'
)
FORECASTING_NUM
=
24
header
=
[
'id'
,
'201604200805'
,
'201604200810'
,
'201604200815'
,
'201604200820'
,
'201604200825'
,
'201604200830'
,
'201604200835'
,
'201604200840'
,
'201604200845'
,
'201604200850'
,
'201604200855'
,
'201604200900'
,
'201604200905'
,
'201604200910'
,
'201604200915'
,
'201604200920'
,
'201604200925'
,
'201604200930'
,
'201604200935'
,
'201604200940'
,
'201604200945'
,
'201604200950'
,
'201604200955'
,
'201604201000'
,
]
###################
## To CSV format ##
###################
with
open
(
file_name
)
as
f
:
f
.
next
()
print
','
.
join
(
header
)
for
row_num
,
line
in
enumerate
(
f
):
fields
=
line
.
rstrip
(
'
\r\n
'
).
split
(
','
)
linkid
=
fields
[
0
]
print
linkid
+
','
+
','
.
join
(
map
(
str
,
res
[
row_num
]))
demo/traffic_prediction/predict.sh
0 → 100755
浏览文件 @
203db079
#!/bin/bash
# Copyright (c) 2016 PaddlePaddle Authors, 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.
set
-e
cfg
=
trainer_config.py
# pass choice
model
=
"output/pass-00000"
paddle train
\
--config
=
$cfg
\
--use_gpu
=
false
\
--job
=
test
\
--init_model_path
=
$model
\
--config_args
=
is_predict
=
1
\
--predict_output_dir
=
.
python gen_result.py
>
result.txt
rm
-rf
rank-00000
demo/traffic_prediction/train.sh
0 → 100755
浏览文件 @
203db079
#!/bin/bash
# Copyright (c) 2016 PaddlePaddle Authors, 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.
set
-e
cfg
=
trainer_config.py
paddle train
\
--config
=
$cfg
\
--save_dir
=
./output
\
--trainer_count
=
4
\
--log_period
=
1000
\
--dot_period
=
10
\
--num_passes
=
10
\
--use_gpu
=
false
\
--show_parameter_stats_period
=
3000
\
2>&1 |
tee
'train.log'
demo/traffic_prediction/trainer_config.py
0 → 100755
浏览文件 @
203db079
# Copyright (c) 2016 PaddlePaddle Authors, 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 Configuration #############################################
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"
,
obj
=
process
)
################################### Parameter Configuaration #######################################
TERM_NUM
=
24
FORECASTING_NUM
=
24
emb_size
=
16
batch_size
=
128
if
not
is_predict
else
1
settings
(
batch_size
=
batch_size
,
learning_rate
=
1e-3
,
learning_method
=
RMSPropOptimizer
())
################################### Algorithm Configuration ########################################
output_label
=
[]
link_encode
=
data_layer
(
name
=
'link_encode'
,
size
=
TERM_NUM
)
for
i
in
xrange
(
FORECASTING_NUM
):
# Each task share same weight.
link_param
=
ParamAttr
(
name
=
'_link_vec.w'
,
initial_max
=
1.0
,
initial_min
=-
1.0
)
link_vec
=
fc_layer
(
input
=
link_encode
,
size
=
emb_size
,
param_attr
=
link_param
)
score
=
fc_layer
(
input
=
link_vec
,
size
=
4
,
act
=
SoftmaxActivation
())
if
is_predict
:
maxid
=
maxid_layer
(
score
)
output_label
.
append
(
maxid
)
else
:
# Multi-task training.
label
=
data_layer
(
name
=
'label_%dmin'
%
((
i
+
1
)
*
5
),
size
=
4
)
cls
=
classification_cost
(
input
=
score
,
name
=
"cost_%dmin"
%
((
i
+
1
)
*
5
),
label
=
label
)
output_label
.
append
(
cls
)
outputs
(
output_label
)
paddle/api/CMakeLists.txt
浏览文件 @
203db079
...
...
@@ -94,17 +94,19 @@ add_dependencies(python_api_wheel python_swig_sources
paddle_cuda
)
if
(
WITH_TESTING
)
SET
(
PIP_SOURCES_DIR
${
PYTHON_SOURCES_DIR
}
/pip
)
ExternalProject_Add
(
pip
${
EXTERNAL_PROJECT_LOG_ARGS
}
GIT_REPOSITORY https://github.com/pypa/pip.git
GIT_TAG 9.0.1
PREFIX
${
PIP_SOURCES_DIR
}
CONFIGURE_COMMAND
""
BUILD_COMMAND
""
INSTALL_COMMAND env
${
py_env
}
${
PYTHON_EXECUTABLE
}
setup.py install
BUILD_IN_SOURCE 1
DEPENDS python setuptools python_api_wheel
)
IF
(
NOT PY_PIP_FOUND
)
SET
(
PIP_SOURCES_DIR
${
PYTHON_SOURCES_DIR
}
/pip
)
ExternalProject_Add
(
pip
${
EXTERNAL_PROJECT_LOG_ARGS
}
GIT_REPOSITORY https://github.com/pypa/pip.git
GIT_TAG 9.0.1
PREFIX
${
PIP_SOURCES_DIR
}
CONFIGURE_COMMAND
""
BUILD_COMMAND
""
INSTALL_COMMAND env
${
py_env
}
${
PYTHON_EXECUTABLE
}
setup.py install
BUILD_IN_SOURCE 1
DEPENDS python setuptools python_api_wheel
)
ENDIF
()
add_subdirectory
(
test
)
endif
()
paddle/gserver/tests/CMakeLists.txt
浏览文件 @
203db079
...
...
@@ -80,7 +80,7 @@ if(NOT WITH_DOUBLE)
test_WarpCTCLayer.cpp
)
add_test
(
NAME test_WarpCTCLayer
COMMAND
${
CMAKE_CURRENT_BINARY_DIR
}
/test_WarpCTCLayer
--warpctc_dir=
${
WARPCTC_LIB_DIR
}
COMMAND
${
CMAKE_CURRENT_BINARY_DIR
}
/test_WarpCTCLayer
WORKING_DIRECTORY
${
PROJ_ROOT
}
/paddle
)
endif
()
...
...
paddle/scripts/travis/before_install.osx.sh
浏览文件 @
203db079
#!/bin/bash
brew update
brew tap homebrew/science
brew
install
openblas md5sha1sum
brew
install
python
sudo
pip
install
--upgrade
protobuf
brew
install
swig openblas md5sha1sum protobuf
paddle/scripts/travis/build_and_test.sh
浏览文件 @
203db079
#!/bin/bash
source
./common.sh
python
-c
'import pip; print(pip.pep425tags.get_supported())'
if
[[
"
$TRAVIS_OS_NAME
"
==
"osx"
]]
;
then
CMAKE_EXTRA
=
"-DWITH_SWIG_PY=OFF"
else
CMAKE_EXTRA
=
"-DWITH_SWIG_PY=ON"
fi
cmake ..
-DWITH_GPU
=
OFF
-DWITH_DOC
=
OFF
-DWITH_TESTING
=
ON
-DON_TRAVIS
=
ON
-DON_COVERALLS
=
ON
${
CMAKE_EXTRA
}
NPROC
=
1
if
[[
"
$TRAVIS_OS_NAME
"
==
"linux"
]]
;
then
export
PYTHONPATH
=
/opt/python/2.7.12/lib/python2.7/site-packages
export
PYTHONHOME
=
/opt/python/2.7.12
export
PATH
=
/opt/python/2.7.12/bin:
${
PATH
}
cmake ..
-DON_TRAVIS
=
ON
-DON_COVERALLS
=
ON
-DCOVERALLS_UPLOAD
=
ON
NRPOC
=
`
nproc
`
make
-j
$NPROC
make coveralls
sudo
make
install
elif
[[
"
$TRAVIS_OS_NAME
"
==
"osx"
]]
;
then
export
PYTHONPATH
=
/usr/local/lib/python2.7/site-packages
cmake ..
-DON_TRAVIS
=
ON
-DON_COVERALLS
=
ON
-DCOVERALLS_UPLOAD
=
ON
NPROC
=
`
sysctl
-n
hw.ncpu
`
make
-j
$NPROC
env
CTEST_OUTPUT_ON_FAILURE
=
1 make
test
ARGS
=
"-j
$NPROC
"
sudo
make
install
sudo
paddle version
fi
paddle/utils/PythonUtil.cpp.in
浏览文件 @
203db079
...
...
@@ -195,8 +195,10 @@ extern const char enable_virtualenv_py[];
}
void initPython(int argc, char** argv) {
#ifndef PADDLE_NO_PYTHON
char PythonHome[] = "@PYTHON_INSTALL_DIR@"; // NOLINT
Py_SetPythonHome(PythonHome);
char pyHome[] = "@PYTHON_INSTALL_DIR@"; // NOLINT
if (strlen(pyHome)) {
Py_SetPythonHome(pyHome);
}
Py_SetProgramName(argv[0]);
Py_Initialize();
PySys_SetArgv(argc, argv);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录