Adding train and predictor drivers

This commit is contained in:
Suresh Parthasarathy 2017-11-16 13:33:40 +05:30
Родитель 2af1ce6874
Коммит c1fc8922ea
24 изменённых файлов: 349 добавлений и 12 удалений

1
.gitignore поставляемый
Просмотреть файл

@ -17,6 +17,7 @@
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
[Bb]uild/
x64/
x86/
bld/

Просмотреть файл

@ -26,17 +26,17 @@ endif()
#define variables for mkl include directories
#set your MKL_ROOT here
#set(MKL_ROOT "C:/Program Files (x86)/IntelSWTools/compilers_and_libraries_2017/windows/mkl")
#set(MKL_INCLUDE_DIR ${MKL_ROOT}/include)
#include_directories(${MKL_INCLUDE_DIR})
#link_directories(${MKL_ROOT}/lib/intel64_win)
#link_directories(${MKL_ROOT}/../compiler/lib/intel64_win)
set(MKL_ROOT "/opt/intel/mkl/")
set(MKL_ROOT "C:/Program Files (x86)/IntelSWTools/compilers_and_libraries/windows/mkl")
set(MKL_INCLUDE_DIR ${MKL_ROOT}/include)
include_directories(${MKL_INCLUDE_DIR})
link_directories(${MKL_ROOT}/lib/intel64_lin)
link_directories(${MKL_ROOT}/../compiler/lib/intel64_lin)
link_directories(${MKL_ROOT}/lib/intel64_win)
link_directories(${MKL_ROOT}/../compiler/lib/intel64_win)
#set(MKL_ROOT "/opt/intel/mkl/")
#set(MKL_INCLUDE_DIR ${MKL_ROOT}/include)
#include_directories(${MKL_INCLUDE_DIR})
#link_directories(${MKL_ROOT}/lib/intel64_lin)
#link_directories(${MKL_ROOT}/../compiler/lib/intel64_lin)
# add debug definitions to compiler flags
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DLIGHT_LOGGER") #-DLOGGER #-DTIMER -DCONCISE #-DSTDERR_ONSCREEN #-DLIGHT_LOGGER -DVERBOSE #-DDUMP #-DVERIFY
@ -64,4 +64,4 @@ MESSAGE(STATUS "CMAKE_CXX_FLAGS_DEBUG:" ${CMAKE_CXX_FLAGS_DEBUG})
# Include project directories
add_subdirectory(src)
#add_subdirectory(test)
add_subdirectory(drivers)

Просмотреть файл

@ -0,0 +1,8 @@
#
# cmake file for Bonsai drivers
#
add_subdirectory(trainer)
add_subdirectory(predictor)
#add_subdirectory(ingestTest)

Просмотреть файл

Просмотреть файл

@ -0,0 +1,21 @@
set (tool_name BonsaiIngest)
set (src BonsaiIngestTest.cpp)
source_group("src" FILES ${src})
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR})
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR})
add_executable(${tool_name} ${src} ${include})
target_include_directories(${tool_name} PRIVATE ${CMAKE_SOURCE_DIR}/src/common ${CMAKE_SOURCE_DIR}/src/Bonsai)
IF(CMAKE_COMPILER_IS_GNUCC)
target_link_libraries(${tool_name} common Bonsai mkl_intel_ilp64 mkl_core mkl_sequential cilkrts)
ENDIF (CMAKE_COMPILER_IS_GNUCC)
IF(NOT CMAKE_COMPILER_IS_GNUCC)
target_link_libraries(${tool_name} common Bonsai mkl_intel_ilp64 mkl_core mkl_sequential)
ENDIF (NOT CMAKE_COMPILER_IS_GNUCC)
set_property(TARGET ${tool_name} PROPERTY FOLDER "drivers/Bonsai")

Просмотреть файл

@ -0,0 +1,21 @@
set (tool_name BonsaiPredict)
set (src BonsaiPredictDriver.cpp)
source_group("src" FILES ${src})
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR})
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR})
add_executable(${tool_name} ${src} ${include})
target_include_directories(${tool_name} PRIVATE ${CMAKE_SOURCE_DIR}/src/common ${CMAKE_SOURCE_DIR}/src/Bonsai)
IF(CMAKE_COMPILER_IS_GNUCC)
target_link_libraries(${tool_name} common Bonsai mkl_intel_ilp64 mkl_core mkl_sequential cilkrts)
ENDIF (CMAKE_COMPILER_IS_GNUCC)
IF(NOT CMAKE_COMPILER_IS_GNUCC)
target_link_libraries(${tool_name} common Bonsai mkl_intel_ilp64 mkl_core mkl_sequential)
ENDIF (NOT CMAKE_COMPILER_IS_GNUCC)
set_property(TARGET ${tool_name} PROPERTY FOLDER "drivers/Bonsai")

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -0,0 +1,21 @@
set (tool_name BonsaiTrain)
set (src BonsaiTrainDriver.cpp)
source_group("src" FILES ${src})
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR})
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR})
add_executable(${tool_name} ${src} ${include})
target_include_directories(${tool_name} PRIVATE ${CMAKE_SOURCE_DIR}/src/common ${CMAKE_SOURCE_DIR}/src/Bonsai)
IF(CMAKE_COMPILER_IS_GNUCC)
target_link_libraries(${tool_name} common Bonsai mkl_intel_ilp64 mkl_core mkl_sequential cilkrts)
ENDIF (CMAKE_COMPILER_IS_GNUCC)
IF(NOT CMAKE_COMPILER_IS_GNUCC)
target_link_libraries(${tool_name} common Bonsai mkl_intel_ilp64 mkl_core mkl_sequential)
ENDIF (NOT CMAKE_COMPILER_IS_GNUCC)
set_property(TARGET ${tool_name} PROPERTY FOLDER "drivers/Bonsai")

7
drivers/CMakeLists.txt Normal file
Просмотреть файл

@ -0,0 +1,7 @@
#
# cmake file for Edge ML drivers
#
add_subdirectory(Bonsai)
add_subdirectory(ProtoNN)

Просмотреть файл

@ -0,0 +1,8 @@
#
# cmake file for ProtoNN drivers
#
add_subdirectory(trainer)
add_subdirectory(predictor)
#add_subdirectory(ingestTest)

Просмотреть файл

@ -0,0 +1,21 @@
set (tool_name ProtoNNIngest)
set (src ProtoNNIngestTest.cpp)
source_group("src" FILES ${src})
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR})
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR})
add_executable(${tool_name} ${src} ${include})
target_include_directories(${tool_name} PRIVATE ${CMAKE_SOURCE_DIR}/src/common ${CMAKE_SOURCE_DIR}/src/ProtoNN)
IF(CMAKE_COMPILER_IS_GNUCC)
target_link_libraries(${tool_name} common ProtoNN mkl_intel_ilp64 mkl_core mkl_gnu_thread gomp pthread cilkrts)
ENDIF (CMAKE_COMPILER_IS_GNUCC)
IF(NOT CMAKE_COMPILER_IS_GNUCC)
target_link_libraries(${tool_name} common ProtoNN mkl_intel_ilp64 mkl_intel_thread mkl_core libiomp5md)
ENDIF (NOT CMAKE_COMPILER_IS_GNUCC)
set_property(TARGET ${tool_name} PROPERTY FOLDER "drivers/ProtoNN")

Просмотреть файл

Просмотреть файл

@ -0,0 +1,21 @@
set (tool_name ProtoNNPredict)
set (src ProtoNNPredictDriver.cpp)
source_group("src" FILES ${src})
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR})
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR})
add_executable(${tool_name} ${src} ${include})
target_include_directories(${tool_name} PRIVATE ${CMAKE_SOURCE_DIR}/src/common ${CMAKE_SOURCE_DIR}/src/ProtoNN)
IF(CMAKE_COMPILER_IS_GNUCC)
target_link_libraries(${tool_name} common ProtoNN mkl_intel_ilp64 mkl_core mkl_gnu_thread gomp pthread cilkrts)
ENDIF (CMAKE_COMPILER_IS_GNUCC)
IF(NOT CMAKE_COMPILER_IS_GNUCC)
target_link_libraries(${tool_name} common ProtoNN mkl_intel_ilp64 mkl_intel_thread mkl_core libiomp5md)
ENDIF (NOT CMAKE_COMPILER_IS_GNUCC)
set_property(TARGET ${tool_name} PROPERTY FOLDER "drivers/ProtoNN")

Просмотреть файл

@ -0,0 +1,21 @@
set (tool_name ProtoNNTrain)
set (src ProtoNNTrainDriver.cpp)
source_group("src" FILES ${src})
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR})
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR})
add_executable(${tool_name} ${src} ${include})
target_include_directories(${tool_name} PRIVATE ${CMAKE_SOURCE_DIR}/src/common ${CMAKE_SOURCE_DIR}/src/ProtoNN)
IF(CMAKE_COMPILER_IS_GNUCC)
target_link_libraries(${tool_name} common ProtoNN mkl_intel_ilp64 mkl_core mkl_gnu_thread gomp pthread cilkrts)
ENDIF (CMAKE_COMPILER_IS_GNUCC)
IF(NOT CMAKE_COMPILER_IS_GNUCC)
target_link_libraries(${tool_name} common ProtoNN mkl_intel_ilp64 mkl_intel_thread mkl_core libiomp5md)
ENDIF (NOT CMAKE_COMPILER_IS_GNUCC)
set_property(TARGET ${tool_name} PROPERTY FOLDER "drivers/ProtoNN")

Просмотреть файл

Просмотреть файл

@ -0,0 +1,34 @@
@ECHO OFF
REM # Copyright (c) Microsoft Corporation. All rights reserved.
REM # Licensed under the MIT license.
REM # Have a look at README_BONSAI_OSS.md for details on how to setup the directory to run this script.
REM ########################################################
REM # Input-output parameters
REM ########################################################
SET input_dir=-D ./usps10
SET input_format=-f 0
REM # Note: The model_dir has to be changed as Model naming is based on timestamp so required to be changed by the user
SET model_dir=-M ./usps10/BonsaiResults/23_44_23_15_11
REM ########################################################
REM # Data-dependent parameters
REM ########################################################
SET ntest=-N 2007
REM ########################################################
REM # execute Bonsai
REM ########################################################
SET executable=./BonsaiPredict
SET command=%executable% %input_format% %ntest% %input_dir% %model_dir%
@ECHO ON
ECHO Running Bonsai Predict with following command:
ECHO %command%
START /B %command%
pause

Просмотреть файл

@ -0,0 +1,57 @@
@ECHO OFF
REM # Copyright (c) Microsoft Corporation. All rights reserved.
REM # Licensed under the MIT license.
REM # Have a look at README_BONSAI_OSS.md for details on how to setup the directory to run this script.
REM ########################################################
REM # Input-output parameters
REM ########################################################
SET input_dir=./usps10
SET input_format=-f 0
REM ########################################################
REM # Data-dependent parameters
REM ########################################################
SET ntrain=-nT 7291
SET ntest=-nE 2007
SET num_features=-F 256
SET num_labels=-C 10
REM ########################################################
REM # Bonsai hyper-parameters (optional)
REM ########################################################
SET projection_dimension=-P 28
SET tree_depth=-D 3
SET sigma=-S 1
SET reg_W=-lW 0.001
SET reg_V=-lV 0.001
SET reg_Theta=-lT 0.001
SET reg_Z=-lZ 0.0001
SET sparse_W=-sW 0.3
SET sparse_V=-sV 0.3
SET sparse_Theta=-sT 0.62
SET sparse_Z=-sZ 0.2
REM ########################################################
REM # Bonsai optimization hyper-parameters (optional)
REM ########################################################
SET batch_factor=-B 1
SET iters=-I 100
REM ########################################################
REM # execute Bonsai
REM ########################################################
SET executable=./BonsaiTrain
SET command=%executable% %input_format% %num_features% %num_labels% %ntrain% %ntest% %projection_dimension% %tree_depth% %sigma% %reg_W% %reg_Z% %reg_Theta% %reg_V% %sparse_Z% %sparse_Theta% %sparse_V" %sparse_W% %batch_factor% %iters% %input_dir%
@ECHO ON
ECHO Running Bonsai with following command:
ECHO %command%
START /B %command%
pause

Просмотреть файл

@ -0,0 +1,29 @@
@ECHO OFF
REM # Copyright (c) Microsoft Corporation. All rights reserved.
REM # Licensed under the MIT license.
REM # Have a look at README.md and README_PROTONN_OSS.md for details on how to setup the data directory to run this script.
SET test_file=-I usps10/test.txt
SET model_file=-M usps10/ProtoNNResults/ProtoNNTrainer_pd_15_protPerClass_0_prot_200_spW_1.000000_spZ_1.000000_spB_1.000000_gammaNumer_1.000000_normal_3_seed_42_bs_1024_it_20_ep_20/model
SET normalization_file=-n usps10/ProtoNNResults/ProtoNNTrainer_pd_15_protPerClass_0_prot_200_spW_1.000000_spZ_1.000000_spB_1.000000_gammaNumer_1.000000_normal_3_seed_42_bs_1024_it_20_ep_20/minMaxParams
SET output_dir=-O usps10/ProtoNNResults
SET input_format=-F 0
SET ntest=-e 2007
REM SET batch_size=-b 1024
REM ########################################################
REM # execute ProtoNNPredict
REM ########################################################
SET executable=./ProtoNNPredict
SET command=%executable% %test_file% %model_file% %output_dir% %normalization_file% %input_format% %ntest% %batch_size%
@ECHO ON
echo Running ProtoNNPredict with following command:
echo %command%
START /B %command%
pause

Просмотреть файл

@ -0,0 +1,67 @@
@ECHO OFF
REM # Copyright (c) Microsoft Corporation. All rights reserved.
REM # Licensed under the MIT license.
REM # Have a look at README.md and README_PROTONN_OSS.md for details on how to setup the data directory to run this script.
REM ########################################################
REM # Input-output parameters
REM ########################################################
SET predefined_model=-P 0
SET problem_format=-C 1
SET train_file=-I usps10/train.txt
SET validation_file=-V usps10/test.txt
SET output_dir=-O usps10/ProtoNNResults
SET input_format=-F 0
REM ########################################################
REM # Data-dependent parameters
REM ########################################################
SET ntrain=-r 7291
SET ntest=-e 2007
SET original_dimension=-D 256
SET num_labels=-l 10
REM ########################################################
REM # ProtoNN hyper-parameters (required)
REM ########################################################
SET projection_dimension=-d 15
REM #prototypes=-k 20
SET prototypes=-m 200
REM ########################################################
REM # ProtoNN hyper-parameters (optional)
REM ########################################################
SET lambda_W=-W 1.0
SET lambda_Z=-Z 1.0
SET lambda_B=-B 1.0
SET gammaNumerator=-g 1.0
SET normalization=-N 0
SET seed=-R 42
REM ########################################################
REM # ProtoNN optimization hyper-parameters (optional)
REM ########################################################
SET batch_size=-b 1024
SET iters=-T 20
SET epochs=-E 20
REM ########################################################
REM # execute ProtoNN
REM ########################################################
SET executable=./ProtoNNTrain
SET command=%executable% %predefined_model% %seed% %problem_format% %train_file% %validation_file% %output_dir% %model_dir% %input_format% %ntrain% %validation% %original_dimension% %projection_dimension% %num_labels% %prototypes% %lambda_W% %lambda_Z% %lambda_B% %gammaNumerator% %batch_size% %iters% %epochs% %normalization%
@ECHO ON
ECHO Running ProtoNN with following command:
ECHO %command%
START /B %command%
pause

Просмотреть файл

@ -67,7 +67,7 @@ epochs="-E 20"
########################################################
#gdb=" gdb --args"
executable="./ProtoNN"
executable="./ProtoNNTrain"
command=$gdb" "$executable" "$predefined_model" "$seed" "$problem_format" "$train_file" "$validation_file" "$output_dir" "$model_dir" "$input_format" "$ntrain" "$nvalidation" "$original_dimension" "$projection_dimension" "$num_labels" "$prototypes" "$lambda_W" "$lambda_Z" "$lambda_B" "$gammaNumerator" "$batch_size" "$iters" "$epochs" "$normalization
echo "Running ProtoNN with following command: "
echo $command

Просмотреть файл

@ -37,7 +37,7 @@ using namespace Eigen;
#ifndef COMPILER_GCC
#pragma comment(lib, "../../../../Libraries/MKL/Win/Microsoft.MachineLearning.MklImports.lib")
//#pragma comment(lib, "../../../../Libraries/MKL/Win/Microsoft.MachineLearning.MklImports.lib")
#endif
//input and output are assumed to be of the same format (single/double)