Get rid of all of the remaining parts of Boost!

This commit is contained in:
Ryan Curtin
2022-05-27 15:17:37 -04:00
parent c15bf6924a
commit 89dfbb600a
17 changed files with 20 additions and 576 deletions
+3 -13
View File
@@ -27,11 +27,7 @@ macro(get_deps LINK DEPS_NAME PACKAGE)
# Get the name of the directory.
file (GLOB DIRECTORIES RELATIVE "${CMAKE_BINARY_DIR}/deps/"
"${CMAKE_BINARY_DIR}/deps/${DEPS_NAME}*.*")
# Clean this line when boost is removed.
if (${DEPS_NAME} MATCHES "boost")
file (GLOB DIRECTORIES RELATIVE "${CMAKE_BINARY_DIR}/deps/"
"${CMAKE_BINARY_DIR}/deps/${DEPS_NAME}*_*")
elseif(${DEPS_NAME} MATCHES "stb")
if(${DEPS_NAME} MATCHES "stb")
file (GLOB DIRECTORIES RELATIVE "${CMAKE_BINARY_DIR}/deps/"
"${CMAKE_BINARY_DIR}/deps/${DEPS_NAME}")
endif()
@@ -44,14 +40,8 @@ macro(get_deps LINK DEPS_NAME PACKAGE)
list(LENGTH DIRECTORIES DIRECTORIES_LEN)
if (DIRECTORIES_LEN GREATER 0)
list(GET DIRECTORIES 0 DEPENDENCY_DIR)
# Clean these lines when boost is removed.
if (${DEPS_NAME} MATCHES "boost")
set(Boost_INCLUDE_DIR "${CMAKE_BINARY_DIR}/deps/${DEPENDENCY_DIR}/")
install(DIRECTORY "${Boost_INCLUDE_DIR}/boost" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
else()
set(GENERIC_INCLUDE_DIR "${CMAKE_BINARY_DIR}/deps/${DEPENDENCY_DIR}/include")
install(DIRECTORY "${GENERIC_INCLUDE_DIR}/" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
endif()
set(GENERIC_INCLUDE_DIR "${CMAKE_BINARY_DIR}/deps/${DEPENDENCY_DIR}/include")
install(DIRECTORY "${GENERIC_INCLUDE_DIR}/" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
else ()
message(FATAL_ERROR
"Problem unpacking ${DEPS_NAME}! Expected only one directory ${DEPS_NAME};. Try to remove the directory ${CMAKE_BINARY_DIR}/deps and reconfigure.")
-51
View File
@@ -26,7 +26,6 @@ option(BUILD_DOCS "Build doxygen documentation (if doxygen is available)." ON)
# See https://github.com/mlpack/mlpack/issues/3033 for some more discussion.
set(ARMADILLO_VERSION "9.800")
set(ENSMALLEN_VERSION "2.10.0")
set(BOOST_VERSION "1.58")
set(CEREAL_VERSION "1.1.2")
# If BUILD_SHARED_LIBS is OFF then the mlpack library will be built statically.
@@ -290,8 +289,6 @@ endif()
# ARMADILLO_LIBRARY - location of libarmadillo.so / armadillo.lib
# ARMADILLO_INCLUDE_DIR - directory containing <armadillo>
# ARMADILLO_INCLUDE_DIRS - directories necessary for Armadillo includes
# BOOST_ROOT - root of Boost installation
# BOOST_INCLUDEDIR - include directory for Boost
# CEREAL_INCLUDE_DIR - include directory for cereal
# ENSMALLEN_INCLUDE_DIR - include directory for ensmallen
# STB_IMAGE_INCLUDE_DIR - include directory for STB image library
@@ -377,54 +374,6 @@ else()
endif()
set(MLPACK_INCLUDE_DIRS ${MLPACK_INCLUDE_DIRS} ${CEREAL_INCLUDE_DIR})
# Unfortunately this configuration variable is necessary and will need to be
# updated as time goes on and new versions are released.
set(Boost_ADDITIONAL_VERSIONS
"1.79.0" "1.79"
"1.78.0" "1.78"
"1.77.0" "1.77"
"1.76.0" "1.76"
"1.75.0" "1.75"
"1.74.0" "1.74"
"1.73.0" "1.73"
"1.72.0" "1.72"
"1.71.0" "1.71"
"1.70.0" "1.70"
"1.69.0" "1.69"
"1.68.0" "1.68"
"1.67.0" "1.67"
"1.66.0" "1.66"
"1.65.1" "1.65.0" "1.65"
"1.64.1" "1.64.0" "1.64"
"1.63.1" "1.63.0" "1.63"
"1.62.1" "1.62.0" "1.62"
"1.61.1" "1.61.0" "1.61"
"1.60.1" "1.60.0" "1.60"
"1.59.1" "1.59.0" "1.59"
"1.58.1" "1.58.0" "1.58")
# Disable forced config-mode CMake search for Boost, which only imports targets
# and does not set the variables that we need.
#
# TODO for the brave: transition all mlpack's CMake to 'target-based modern
# CMake'. Good luck! You'll need it.
set(Boost_NO_BOOST_CMAKE 1)
if (NOT DOWNLOAD_DEPENDENCIES)
find_package(Boost "${BOOST_VERSION}" REQUIRED)
else()
find_package(Boost "${BOOST_VERSION}")
if (NOT Boost_FOUND)
if (CMAKE_COMPILER_IS_GNUCC AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0))
get_deps(http://sourceforge.net/projects/boost/files/boost/1.58.0/boost_1_58_0.tar.gz boost boost_1_58_0.tar.gz)
else()
get_deps(https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.tar.gz boost boost_1_76_0.tar.gz)
endif()
find_package(Boost REQUIRED)
endif()
endif()
set(MLPACK_INCLUDE_DIRS ${MLPACK_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
set(MLPACK_LIBRARIES ${MLPACK_LIBRARIES})
set(MLPACK_LIBRARY_DIRS ${MLPACK_LIBRARY_DIRS})
# Detect OpenMP support in a compiler. If the compiler supports OpenMP, flags
# to compile with OpenMP are returned and added and the HAS_OPENMP definition
# is added for compilation.
-2
View File
@@ -100,7 +100,6 @@ Citations are beneficial for the growth and improvement of mlpack.
mlpack has the following dependencies:
Armadillo >= 9.800
Boost (math_c99, spirit) >= 1.58.0
CMake >= 3.6
ensmallen >= 2.10.0
cereal >= 1.1.2
@@ -202,7 +201,6 @@ Options are specified with the -D flag. The allowed options include:
DEBUG=(ON/OFF): compile with debugging symbols
PROFILE=(ON/OFF): compile with profiling symbols
ARMA_EXTRA_DEBUG=(ON/OFF): compile with extra Armadillo debugging symbols
BOOST_ROOT=(/path/to/boost/): path to root of boost installation
ARMADILLO_INCLUDE_DIR=(/path/to/armadillo/include/): path to Armadillo headers
ARMADILLO_LIBRARY=(/path/to/armadillo/libarmadillo.so): Armadillo library
BUILD_CLI_EXECUTABLES=(ON/OFF): whether or not to build command-line programs
@@ -104,12 +104,12 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>false</ConformanceMode>
<AdditionalIncludeDirectories>C:\boost\boost_1_66_0;C:\mlpack\armadillo-8.500.1\include;C:\mlpack\mlpack-3.4.2\build\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>C:\mlpack\armadillo-8.500.1\include;C:\mlpack\mlpack-3.4.2\build\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>C:\mlpack\mlpack-3.4.2\build\Debug\mlpack.lib;C:\boost\boost_1_66_0\lib64-msvc-14.1\libboost_serialization-vc141-mt-gd-x64-1_66.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>C:\mlpack\mlpack-3.4.2\build\Debug\mlpack.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>xcopy /y "C:\mlpack\mlpack-3.4.2\build\Debug\mlpack.dll" $(OutDir)
+1 -1
View File
@@ -1314,7 +1314,7 @@ will be able to pass a pointer to the model itself. This is generally
best---users should not expect to be able to manipulate the model in the target
language, but they should expect that they can pass a model back and forth
without paying a runtime penalty. So, for example, serializing a model using a
@c boost::text_oarchive and then returning the string that represents the model
cereal text archive and then returning the string that represents the model
is not acceptable, because that string can be extremely large and the time it
takes to decode the model can be very large.
+4 -7
View File
@@ -96,7 +96,6 @@ mlpack depends on the following libraries, which need to be installed on the
system and have headers present:
- Armadillo >= 9.800 (with LAPACK support)
- Boost (math_c99, spirit) >= 1.58
- cereal >= 1.1.2
- ensmallen >= 2.10.0 (will be downloaded if not found)
@@ -117,9 +116,8 @@ In Ubuntu (>= 18.04) and Debian (>= 10) all of these dependencies can be
installed through apt:
@code
# apt-get install libboost-math-dev libcereal-dev
libarmadillo-dev binutils-dev python3-pandas python3-numpy cython3
python3-setuptools
# apt-get install libcereal-dev libarmadillo-dev binutils-dev python3-pandas
python3-numpy cython3 python3-setuptools
@endcode
If you are using Ubuntu 19.10 or newer, you can also install @c libensmallen-dev
@@ -140,8 +138,8 @@ source as apt installs an older version. So you need to omit
On Fedora, Red Hat, or CentOS, these same dependencies can be obtained via dnf:
@code
# dnf install boost-devel boost-math armadillo-devel binutils-devel
python3-Cython python3-setuptools python3-numpy python3-pandas ensmallen-devel
# dnf install armadillo-devel binutils-devel python3-Cython python3-setuptools
python3-numpy python3-pandas ensmallen-devel
stbi-devel cereal-devel
@endcode
@@ -225,7 +223,6 @@ and libraries. These also use the '-D' flag.
- ARMADILLO_INCLUDE_DIR=(/path/to/armadillo/include/): path to Armadillo headers
- ARMADILLO_LIBRARY=(/path/to/armadillo/libarmadillo.so): location of Armadillo
library
- BOOST_ROOT=(/path/to/boost/): path to root of boost installation
- CEREAL_INCLUDE_DIR=(/path/to/cereal/include): path to include directory for
cereal
- ENSMALLEN_INCLUDE_DIR=(/path/to/ensmallen/include): path to include directory
+1 -29
View File
@@ -48,7 +48,6 @@ This tutorial has been designed and tested using:
- Visual Studio 2019 (toolset v142)
- mlpack
- OpenBLAS.0.2.14.1
- boost_1_71_0-msvc-14.2-64
- armadillo (newest version)
- and x64 configuration
@@ -100,18 +99,6 @@ It you choose to build `OpenBLAS` from source, make sure that `LAPACK` functions
sure that the `openblas.lib` library is linked in your `Armadillo` build (see below), as well as the library
path used for the CMake options `BLAS_LIBRARIES` and `LAPACK_LIBRARIES` in the mlpack CMake project.
<b> Boost Dependency </b>
You can either get Boost via NuGet or you can download the prebuilt Windows binaries separately.
This tutorial follows the second approach for simplicity.
- Download the "Prebuilt Windows binaries" of the Boost library ("boost_1_71_0-msvc-14.2-64") from
<a href="https://sourceforge.net/projects/boost/files/boost-binaries/">Sourceforge</a>
@note Make sure you download the MSVC version that matches your Visual Studio
- Install or unzip to "C:\boost\"
<b> Armadillo Dependency </b>
- Download the newest version of Armadillo from <a href="http://arma.sourceforge.net/download.html">Sourceforge</a>
@@ -140,7 +127,7 @@ compiler version, check if the Visual Studio compiler and Windows SDK are instal
- Run cmake:
@code
cmake -G "Visual Studio 16 2019" -A x64 -DBLAS_LIBRARIES:FILEPATH="C:/mlpack/mlpack/packages/OpenBLAS.0.2.14.1/lib/native/lib/x64/libopenblas.dll.a" -DLAPACK_LIBRARIES:FILEPATH="C:/mlpack/mlpack/packages/OpenBLAS.0.2.14.1/lib/native/lib/x64/libopenblas.dll.a" -DARMADILLO_INCLUDE_DIR="C:/mlpack/armadillo/include" -DARMADILLO_LIBRARY:FILEPATH="C:/mlpack/armadillo/build/Debug/armadillo.lib" -DBOOST_INCLUDEDIR:PATH="C:/boost/" -DBOOST_LIBRARYDIR:PATH="C:/boost/lib64-msvc-14.2" -DDEBUG=OFF -DPROFILE=OFF ..
cmake -G "Visual Studio 16 2019" -A x64 -DBLAS_LIBRARIES:FILEPATH="C:/mlpack/mlpack/packages/OpenBLAS.0.2.14.1/lib/native/lib/x64/libopenblas.dll.a" -DLAPACK_LIBRARIES:FILEPATH="C:/mlpack/mlpack/packages/OpenBLAS.0.2.14.1/lib/native/lib/x64/libopenblas.dll.a" -DARMADILLO_INCLUDE_DIR="C:/mlpack/armadillo/include" -DARMADILLO_LIBRARY:FILEPATH="C:/mlpack/armadillo/build/Debug/armadillo.lib" -DDEBUG=OFF -DPROFILE=OFF ..
@endcode
@note cmake will attempt to automatically download the ensmallen dependency. If for some reason cmake can't download the dependency, you will need to manually download ensmallen from http://ensmallen.org/ and extract it to "C:\mlpack\mlpack\deps\". Then, specify the path to ensmallen using the flag: -DENSMALLEN_INCLUDE_DIR=C:/mlpack/mlpack/deps/ensmallen/include
@@ -166,7 +153,6 @@ must provide to Visual Studio's CMake are:
- `ARMADILLO_INCLUDE_DIR`
- `ARMADILLO_LIBRARY`
- `BOOST_ROOT`
- `CEREAL_INCLUDE_DIR`
- `BLAS_LIBRARIES`
- `LAPACK_LIBRARIES`
@@ -215,16 +201,6 @@ Here is a full example of the `CMakeSettings.json`file:
"value": "PATH/TO/CPP/DEPENDENCY/cereal-1.3.0/include",
"type": "PATH"
},
{
"name": "BUILD_ROOT",
"value": "PATH/TO/CPP/DEPENDENCY/boost_1_66_0",
"type": "PATH"
},
{
"name": "BOOST_INCLUDEDIR",
"value": "PATH/TO/CPP/DEPENDENCY/boost_1_66_0",
"type": "PATH"
},
{
"name": "BLAS_LIBRARIES",
"value": "PATH/TO/CPP/DEPENDENCY/OpenBLAS/lib/openblas.lib",
@@ -255,10 +231,6 @@ If you prefer to use cmake GUI, follow these instructions:
- Name: `ARMADILLO_LIBRARY`; type `FILEPATH`; value `C:/mlpack/armadillo/build/Debug/armadillo.lib`
- Name: `BLAS_LIBRARY`; type `FILEPATH`; value `C:/mlpack/mlpack/packages/OpenBLAS.0.2.14.1/lib/native/lib/x64/libopenblas.dll.a`
- Name: `LAPACK_LIBRARY`; type `FILEPATH`; value `C:/mlpack/mlpack/packages/OpenBLAS.0.2.14.1/lib/native/lib/x64/libopenblas.dll.a`
- If there is an error and Boost is not found, try "Add Entry" with the
following variables and reconfigure:
- Name: `BOOST_INCLUDEDIR`; type `PATH`; value `C:/boost/`
- Name: `BOOST_LIBRARYDIR`; type `PATH`; value `C:/boost/lib64-msvc-14.2`
- Once CMake has configured successfully, hit "Generate" to create the `.sln` file.
@section build_windows_additional_information Additional Information
+1 -1
View File
@@ -30,7 +30,7 @@ have to install the dependencies (the code below is for Ubuntu), then we can
build and install mlpack. You can copy-paste the commands into your shell.
@code{.sh}
sudo apt-get install libboost-all-dev g++ cmake libarmadillo-dev python-pip wget
sudo apt-get install g++ cmake libarmadillo-dev python-pip wget
sudo pip install cython setuptools distutils numpy pandas
wget https://www.mlpack.org/files/mlpack-3.4.2.tar.gz
tar -xvzpf mlpack-3.4.2.tar.gz
-1
View File
@@ -27,7 +27,6 @@ mlpack and dependencies in Release Mode).
- Right click on the project and select Properties, select the x64 Debug profile
- Under C/C++ > General > Additional Include Directories add:
@code
- C:\boost\boost_1_71_0\lib\native\include
- C:\mlpack\armadillo-9.800.3\include
- C:\mlpack\mlpack-3.4.2\build\include
@endcode
+2 -12
View File
@@ -231,7 +231,7 @@ class ExampleTree
template<typename Archive>
ExampleTree(
Archive& ar,
const typename boost::enable_if<typename Archive::is_loading>::type* = 0);
const typename std::enable_if_c<typename Archive::is_loading>::type* = 0);
// Release any resources held by the tree.
~ExampleTree();
@@ -477,9 +477,6 @@ a default-constructed metric should be used. The constructor *must* return a
valid, fully-constructed, ready-to-use tree that satisfies the definition
of *space tree* that was \ref whatistree "given earlier".
It is possible to implement both these constructors as one by using \c
boost::optional.
The third constructor requires the tree to be initializable from a \c
cereal archive:
@@ -490,7 +487,7 @@ cereal archive:
template<typename Archive>
ExampleTree(
Archive& ar,
const typename boost::enable_if<typename Archive::is_loading>::type* = 0);
const typename std::enable_if_c<typename Archive::is_loading>::type* = 0);
@endcode
This has implications on how the tree must be stored. In this case, the dataset
@@ -794,13 +791,6 @@ On the other hand, the specifics of the functionality required for the
\c Serialize() function are somewhat more difficult. The \c Serialize()
function will be called either when a tree is being saved to disk or loaded from
disk. The \c cereal documentation is fairly comprehensive.
when writing a \c Serialize() method for mlpack trees you should use
\c data::CreateNVP() instead of \c BOOST_SERIALIZATION_NVP(). This is because
mlpack classes implement \c Serialize() instead of \c serialize() in order to
conform to the mlpack style guidelines, and making this work requires some
interesting shim code, which is hidden inside of \c data::CreateNVP(). It may
be useful to look at other \c Serialize() methods contained in other mlpack
classes as an example.
An important note is that it is very difficult to use references with
\c cereal, because \c serialize() may be called at any time during
+2 -3
View File
@@ -731,11 +731,10 @@ model.Parameters();
which will return the complete model parameters as an armadillo matrix object;
however often it is useful to not only have the parameters for the complete
network, but the parameters of a specific layer. The parameters for a specific
layer @c x can be accessed via @c boost::visitor:
layer @c x can be accessed via the @c Parameters() member:
@code
arma::mat parametersX;
boost::apply_visitor(ParametersVisitor(parametersX), model.Model()[x]);
arma::mat parametersX = model.Model()[x].Parameters();
@endcode
In the example above, we get the weights of the second layer.
@@ -14,9 +14,6 @@
#include <Rcpp.h>
// To suppress Found __assert_fail, possibly from assert (C).
#define BOOST_DISABLE_ASSERTS
// Rcpp has its own stream object which cooperates more nicely with R's i/o
// And as of armadillo and mlpack, we can use this stream object as well.
#if !defined(ARMA_COUT_STREAM)
@@ -12,8 +12,6 @@
#include <mlpack/core/util/io.hpp>
#include <mlpack/core/util/binding_details.hpp>
#include <boost/algorithm/string/replace.hpp>
#include "binding_info.hpp"
#include "print_docs.hpp"
#include "print_doc_functions.hpp"
-441
View File
@@ -1,441 +0,0 @@
/**
* @file methods/ann/layer_names.hpp
* @author Sreenik Seal
*
* Implementation of a class that converts a given ann layer to string format.
*
* mlpack is free software; you may redistribute it and/or modify it under the
* terms of the 3-clause BSD license. You should have received a copy of the
* 3-clause BSD license along with mlpack. If not, see
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
*/
#include <mlpack/core.hpp>
#include <mlpack/methods/ann/layer/layer.hpp>
#include <mlpack/methods/ann/layer/layer_types.hpp>
#include <boost/variant/static_visitor.hpp>
#include <string>
/**
* Implementation of a class that returns the string representation of the
* name of the given layer.
*/
class LayerNameVisitor : public boost::static_visitor<std::string>
{
public:
//! Create the LayerNameVisitor object.
LayerNameVisitor()
{
}
/**
* Return the name of the given layer of type AdaptiveMaxPooling as string.
*
* @param * Given layer of type AdaptiveMaxPooling.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::AdaptiveMaxPooling<> * /*layer*/) const
{
return "adaptivemaxpooling";
}
/**
* Return the name of the given layer of type AdaptiveMeanPooling as string.
*
* @param * Given layer of type AdaptiveMeanPooling.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::AdaptiveMeanPooling<> * /*layer*/) const
{
return "adaptivemeanpooling";
}
/**
* Return the name of the given layer of type AtrousConvolution as a string.
*
* @param * Given layer of type AtrousConvolution.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::AtrousConvolution<>* /*layer*/) const
{
return "atrousconvolution";
}
/**
* Return the name of the given layer of type AlphaDropout as a string.
*
* @param * Given layer of type AlphaDropout.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::AlphaDropout<>* /*layer*/) const
{
return "alphadropout";
}
/**
* Return the name of the given layer of type BatchNorm as a string.
*
* @param * Given layer of type BatchNorm.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::BatchNorm<>* /*layer*/) const
{
return "batchnorm";
}
/**
* Return the name of the given layer of type Constant as a string.
*
* @param * Given layer of type Constant.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::Constant<>* /*layer*/) const
{
return "constant";
}
/**
* Return the name of the given layer of type Convolution as a string.
*
* @param * Given layer of type Convolution.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::Convolution<>* /*layer*/) const
{
return "convolution";
}
/**
* Return the name of the given layer of type DropConnect as a string.
*
* @param * Given layer of type DropConnect.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::DropConnect<>* /*layer*/) const
{
return "dropconnect";
}
/**
* Return the name of the given layer of type Dropout as a string.
*
* @param * Given layer of type Dropout.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::Dropout<>* /*layer*/) const
{
return "dropout";
}
/**
* Return the name of the given layer of type FlexibleReLU as a string.
*
* @param * Given layer of type FlexibleReLU.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::FlexibleReLU<>* /*layer*/) const
{
return "flexiblerelu";
}
/**
* Return the name of the given layer of type LayerNorm as a string.
*
* @param * Given layer of type LayerNorm.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::LayerNorm<>* /*layer*/) const
{
return "layernorm";
}
/**
* Return the name of the given layer of type Linear as a string.
*
* @param * Given layer of type Linear.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::Linear<>* /*layer*/) const
{
return "linear";
}
/**
* Return the name of the given layer of type LinearNoBias as a string.
*
* @param * Given layer of type LinearNoBias.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::LinearNoBias<>* /*layer*/) const
{
return "linearnobias";
}
/**
* Return the name of the given layer of type NoisyLinear as a string.
*
* @param * Given layer of type NoisyLinear.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::NoisyLinear<>* /*layer*/) const
{
return "noisylinear";
}
/**
* Return the name of the given layer of type MaxPooling as a string.
*
* @param * Given layer of type MaxPooling.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::MaxPooling<>* /*layer*/) const
{
return "maxpooling";
}
/**
* Return the name of the given layer of type MeanPooling as a string.
*
* @param * Given layer of type MeanPooling.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::MeanPooling<>* /*layer*/) const
{
return "meanpooling";
}
/**
* Return the name of the given layer of type LpPooling as a string.
*
* @param * Given layer of type LpPooling.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::LpPooling<>* /*layer*/) const
{
return "lppooling";
}
/**
* Return the name of the given layer of type MultiplyConstant as a string.
*
* @param * Given layer of type MultiplyConstant.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::MultiplyConstant<>* /*layer*/) const
{
return "multiplyconstant";
}
/**
* Return the name of the given layer of type ReLULayer as a string.
*
* @param * Given layer of type ReLULayer.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::ReLULayer<>* /*layer*/) const
{
return "relu";
}
/**
* Return the name of the given layer of type TransposedConvolution as a
* string.
*
* @param * Given layer of type TransposedConvolution.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::TransposedConvolution<>* /*layer*/) const
{
return "transposedconvolution";
}
/**
* Return the name of the given layer of type IdentityLayer as a string.
*
* @param * Given layer of type IdentityLayer.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::IdentityLayer<>* /*layer*/) const
{
return "identity";
}
/**
* Return the name of the given layer of type TanHLayer as a string.
*
* @param * Given layer of type TanHLayer.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::TanHLayer<>* /*layer*/) const
{
return "tanh";
}
/**
* Return the name of the given layer of type ELU as a string.
*
* @param * Given layer of type ELU.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::ELU<>* /*layer*/) const
{
return "elu";
}
/**
* Return the name of the given layer of type HardTanH as a string.
*
* @param * Given layer of type HardTanH.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::HardTanH<>* /*layer*/) const
{
return "hardtanh";
}
/**
* Return the name of the given layer of type LeakyReLU as a string.
*
* @param * Given layer of type LeakyReLU.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::LeakyReLU<>* /*layer*/) const
{
return "leakyrelu";
}
/**
* Return the name of the given layer of type PReLU as a string.
*
* @param * Given layer of type PReLU.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::PReLU<>* /*layer*/) const
{
return "prelu";
}
/**
* Return the name of the given layer of type SigmoidLayer as a string.
*
* @param * Given layer of type SigmoidLayer.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::SigmoidLayer<>* /*layer*/) const
{
return "sigmoid";
}
/**
* Return the name of the given layer of type LogSoftMax as a string.
*
* @param * Given layer of type LogSoftMax.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::LogSoftMax<>* /*layer*/) const
{
return "logsoftmax";
}
/*
* Return the name of the given layer of type LSTM as a string.
*
* @param * Given layer of type LSTM.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::LSTM<>* /*layer*/) const
{
return "lstm";
}
/**
* Return the name of the given layer of type CReLU as a string.
*
* @param * Given layer of type CReLU.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::CReLU<>* /*layer*/) const
{
return "crelu";
}
/**
* Return the name of the given layer of type Highway as a string.
*
* @param * Given layer of type Highway.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::Highway<>* /*layer*/) const
{
return "highway";
}
/**
* Return the name of the given layer of type GRU as a string.
*
* @param * Given layer of type GRU.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::GRU<>* /*layer*/) const
{
return "gru";
}
/**
* Return the name of the given layer of type Glimpse as a string.
*
* @param * Given layer of type Glimpse.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::Glimpse<>* /*layer*/) const
{
return "glimpse";
}
/**
* Return the name of the given layer of type FastLSTM as a string.
*
* @param * Given layer of type FastLSTM.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::FastLSTM<>* /*layer*/) const
{
return "fastlstm";
}
/**
* Return the name of the given layer of type WeightNorm as a string.
*
* @param * Given layer of type WeightNorm.
* @return The string representation of the layer.
*/
std::string LayerString(mlpack::ann::WeightNorm<>* /*layer*/) const
{
return "weightnorm";
}
/**
* Return the name of the layer of specified type as a string.
*
* @param * Given layer of any type.
* @return A string declaring that the layer is unsupported.
*/
template<typename T>
std::string LayerString(T* /*layer*/) const
{
return "unsupported";
}
//! Overload function call.
std::string operator()(mlpack::ann::MoreTypes layer) const
{
return layer.apply_visitor(*this);
}
//! Overload function call.
template<typename LayerType>
std::string operator()(LayerType* layer) const
{
return LayerString(layer);
}
};
@@ -181,8 +181,7 @@ class CategoricalDQN
{
for (size_t i = 0; i < noisyLayerIndex.size(); ++i)
{
boost::get<ann::NoisyLinear<>*>
(network.Model()[noisyLayerIndex[i]])->ResetNoise();
(network.Model()[noisyLayerIndex[i]])->ResetNoise();
}
}
@@ -243,10 +243,8 @@ class DuelingDQN
{
for (size_t i = 0; i < noisyLayerIndex.size(); i++)
{
boost::get<ann::NoisyLinear<>*>
(valueNetwork->Model()[noisyLayerIndex[i]])->ResetNoise();
boost::get<ann::NoisyLinear<>*>
(advantageNetwork->Model()[noisyLayerIndex[i]])->ResetNoise();
(valueNetwork->Model()[noisyLayerIndex[i]])->ResetNoise();
(advantageNetwork->Model()[noisyLayerIndex[i]])->ResetNoise();
}
}
@@ -223,8 +223,7 @@ void SAC<
learningQ2Network.Predict(qInput, Q2);
// Get the size of the first hidden layer in the Q network.
size_t hidden1 = boost::get<mlpack::ann::Linear<> *>
(learningQ1Network.Model()[0])->OutputSize();
size_t hidden1 = (learningQ1Network.Model()[0])->OutputSize();
arma::mat gradient;
for (size_t i = 0; i < sampledStates.n_cols; i++)