[mlpack-git] [mlpack] ANN Saving the network and reloading (#531)

sudarshan notifications at github.com
Wed Mar 2 10:36:58 EST 2016


Thank you. I am building against C++14 as well. Here is my CMake file:
```
cmake_minimum_required ( VERSION 2.8 )
project ( mlpack_nn )
 
set ( CMAKE_CXX_FLAGS "-std=c++1y" )
set ( CMAKE_EXPORT_COMPILE_COMMANDS 1 )
set ( PROJECT_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include )

set ( MLPACK_INCLUDE_DIR "/usr/local/include/mlpack/" )
set ( MLPACK_LIBRARY "/usr/local/lib/libmlpack.so.2" )

find_package ( Armadillo REQUIRED )
find_package ( Boost COMPONENTS serialization REQUIRED )
include_directories ( ${ARMADILLO_INCLUDE_DIRS} )
include_directories ( ${Boost_INCLUDE_DIR} )
include_directories ( ${MLPACK_INCLUDE_DIR} )
 
file ( GLOB_RECURSE PROJ_SRCS src/*.cpp )
 
include_directories ( "${PROJECT_INCLUDE_DIR}" )
add_executable ( ff_nn ${PROJ_SRCS} )
target_link_libraries ( ff_nn ${ARMADILLO_LIBRARIES} ${Boost_LIBRARIES} ${MLPACK_LIBRARY} )
```
After stero's suggestion, I did a pull today and fast-forwarded my branch by 4 commits and built and ran the mlpack_test which found no errors. After this, when I compile I am still getting errors but its different:

```
In file included from /home/sudarshan/project-yanack/mlpack_nn/src/ff_nn.cpp:13:0:
/usr/local/include/mlpack/methods/ann/layer/base_layer.hpp: In instantiation of ‘OutputDataType& mlpack::ann::BaseLayer<ActivationFunction, InputDataType, OutputDataType>::OutputParameter() const [with ActivationFunction = mlpack::ann::LogisticFunction; InputDataType = arma::Mat<double>; OutputDataType = arma::Mat<double>]’:
/usr/local/include/mlpack/methods/ann/ffn.hpp:314:5:   required from ‘double mlpack::ann::FFN<LayerTypes, OutputLayerType, InitializationRuleType, PerformanceFunction>::OutputError(const DataType&, ErrorType&, const std::tuple<_Args2 ...>&) [with DataType = arma::Mat<double>; ErrorType = arma::Mat<double>; Tp = {mlpack::ann::LinearLayer<arma::Mat<double>, arma::Mat<double> >, mlpack::ann::BiasLayer<arma::Mat<double>, arma::Mat<double> >, mlpack::ann::BaseLayer<mlpack::ann::LogisticFunction, arma::Mat<double>, arma::Mat<double> >, mlpack::ann::LinearLayer<arma::Mat<double>, arma::Mat<double> >, mlpack::ann::BiasLayer<arma::Mat<double>, arma::Mat<double> >, mlpack::ann::BaseLayer<mlpack::ann::LogisticFunction, arma::Mat<double>, arma::Mat<double> >}; LayerTypes = std::tuple<mlpack::ann::LinearLayer<arma::Mat<double>, arma::Mat<double> >, mlpack::ann::BiasLayer<arma::Mat<double>, arma::Mat<double> >, mlpack::ann::BaseLayer<mlpack::ann::LogisticFunction, arma::Mat<double>, arma::Mat<double> >, mlpack::ann::LinearLayer<arma::Mat<double>, arma::Mat<double> >, mlpack::ann::BiasLayer<arma::Mat<double>, arma::Mat<double> >, mlpack::ann::BaseLayer<mlpack::ann::LogisticFunction, arma::Mat<double>, arma::Mat<double> > >; OutputLayerType = mlpack::ann::BinaryClassificationLayer; InitializationRuleType = mlpack::ann::RandomInitialization; PerformanceFunction = mlpack::ann::MeanSquaredErrorFunction]’
/usr/local/include/mlpack/methods/ann/ffn_impl.hpp:241:28:   required from ‘double mlpack::ann::FFN<LayerTypes, OutputLayerType, InitializationRuleType, PerformanceFunction>::Evaluate(const mat&, size_t, bool) [with LayerTypes = std::tuple<mlpack::ann::LinearLayer<arma::Mat<double>, arma::Mat<double> >, mlpack::ann::BiasLayer<arma::Mat<double>, arma::Mat<double> >, mlpack::ann::BaseLayer<mlpack::ann::LogisticFunction, arma::Mat<double>, arma::Mat<double> >, mlpack::ann::LinearLayer<arma::Mat<double>, arma::Mat<double> >, mlpack::ann::BiasLayer<arma::Mat<double>, arma::Mat<double> >, mlpack::ann::BaseLayer<mlpack::ann::LogisticFunction, arma::Mat<double>, arma::Mat<double> > >; OutputLayerType = mlpack::ann::BinaryClassificationLayer; InitializationRuleType = mlpack::ann::RandomInitialization; PerformanceFunction = mlpack::ann::MeanSquaredErrorFunction; arma::mat = arma::Mat<double>; size_t = long unsigned int]’
/usr/local/include/mlpack/core/optimizers/rmsprop/rmsprop_impl.hpp:54:22:   required from ‘double mlpack::optimization::RMSprop<DecomposableFunctionType>::Optimize(arma::mat&) [with DecomposableFunctionType = mlpack::ann::FFN<std::tuple<mlpack::ann::LinearLayer<arma::Mat<double>, arma::Mat<double> >, mlpack::ann::BiasLayer<arma::Mat<double>, arma::Mat<double> >, mlpack::ann::BaseLayer<mlpack::ann::LogisticFunction, arma::Mat<double>, arma::Mat<double> >, mlpack::ann::LinearLayer<arma::Mat<double>, arma::Mat<double> >, mlpack::ann::BiasLayer<arma::Mat<double>, arma::Mat<double> >, mlpack::ann::BaseLayer<mlpack::ann::LogisticFunction, arma::Mat<double>, arma::Mat<double> > >, mlpack::ann::BinaryClassificationLayer, mlpack::ann::RandomInitialization, mlpack::ann::MeanSquaredErrorFunction>&; arma::mat = arma::Mat<double>]’
/usr/local/include/mlpack/methods/ann/ffn_impl.hpp:137:50:   required from ‘void mlpack::ann::FFN<LayerTypes, OutputLayerType, InitializationRuleType, PerformanceFunction>::Train(const mat&, const mat&) [with OptimizerType = mlpack::optimization::RMSprop; LayerTypes = std::tuple<mlpack::ann::LinearLayer<arma::Mat<double>, arma::Mat<double> >, mlpack::ann::BiasLayer<arma::Mat<double>, arma::Mat<double> >, mlpack::ann::BaseLayer<mlpack::ann::LogisticFunction, arma::Mat<double>, arma::Mat<double> >, mlpack::ann::LinearLayer<arma::Mat<double>, arma::Mat<double> >, mlpack::ann::BiasLayer<arma::Mat<double>, arma::Mat<double> >, mlpack::ann::BaseLayer<mlpack::ann::LogisticFunction, arma::Mat<double>, arma::Mat<double> > >; OutputLayerType = mlpack::ann::BinaryClassificationLayer; InitializationRuleType = mlpack::ann::RandomInitialization; PerformanceFunction = mlpack::ann::MeanSquaredErrorFunction; arma::mat = arma::Mat<double>]’
/home/sudarshan/project-yanack/mlpack_nn/src/ff_nn.cpp:45:5:   required from ‘void BuildFFN(MatType&, MatType&, MatType&, MatType&, size_t) [with PerformanceFunction = mlpack::ann::LogisticFunction; OutputLayerType = mlpack::ann::BinaryClassificationLayer; PerformanceFunctionType = mlpack::ann::MeanSquaredErrorFunction; MatType = arma::Mat<double>; size_t = long unsigned int]’
/home/sudarshan/project-yanack/mlpack_nn/src/ff_nn.cpp:79:71:   required from here
/usr/local/include/mlpack/methods/ann/layer/base_layer.hpp:128:52: error: invalid initialization of reference of type ‘arma::Mat<double>&’ from expression of type ‘const arma::Mat<double>’
   OutputDataType& OutputParameter() const { return outputParameter; }
                                                    ^
make[2]: *** [CMakeFiles/ff_nn.dir/src/ff_nn.cpp.o] Error 1
make[1]: *** [CMakeFiles/ff_nn.dir/all] Error 2
make: *** [all] Error 2
```

I was able to isolate the error to the net.Train(trainData, trainLabels) call. Any suggestions?

Thanks.

---
Reply to this email directly or view it on GitHub:
https://github.com/mlpack/mlpack/issues/531#issuecomment-191290369
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20160302/da3e1ac9/attachment-0001.html>


More information about the mlpack-git mailing list