diff --git a/.teamcity/build.sh b/.teamcity/build.sh index 2f6cec0c6976797572bb9f139e0cd42cde3e5d5e..09d998269b303d8dda1eae2e8eccf6dd066967f2 100755 --- a/.teamcity/build.sh +++ b/.teamcity/build.sh @@ -134,17 +134,17 @@ EOF rm -rf ${REPO_ROOT}/build } -function run_deepes_test { - cd ${REPO_ROOT}/deepes +function run_evo_kit_test { + cd ${REPO_ROOT}/evo_kit cat < PARL

diff --git a/deepes/benchmark/cartpole.h b/evo_kit/benchmark/cartpole.h similarity index 100% rename from deepes/benchmark/cartpole.h rename to evo_kit/benchmark/cartpole.h diff --git a/deepes/core/include/adam_optimizer.h b/evo_kit/core/include/evo_kit/adam_optimizer.h similarity index 85% rename from deepes/core/include/adam_optimizer.h rename to evo_kit/core/include/evo_kit/adam_optimizer.h index 1c40fe6bdd19bea7a92a60eb03ae7487483c5206..b268b69f61d35e5d6df8eeb56b1869e7bcb828ff 100644 --- a/deepes/core/include/adam_optimizer.h +++ b/evo_kit/core/include/evo_kit/adam_optimizer.h @@ -12,14 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef ADAM_OPTIMIZER_H -#define ADAM_OPTIMIZER_H +#ifndef EVO_KIT_ADAM_OPTIMIZER_H +#define EVO_KIT_ADAM_OPTIMIZER_H -#include #include -#include "optimizer.h" +#include +#include "evo_kit/optimizer.h" -namespace deep_es { +namespace evo_kit { /*@brief AdamOptimizer. * Implements Adam algorithm. @@ -44,8 +44,8 @@ private: float _beta1; float _beta2; float _epsilon; - std::map _momentum; - std::map _velocity; + std::unordered_map _momentum; + std::unordered_map _velocity; }; }//namespace diff --git a/deepes/core/include/cached_gaussian_sampling.h b/evo_kit/core/include/evo_kit/cached_gaussian_sampling.h similarity index 91% rename from deepes/core/include/cached_gaussian_sampling.h rename to evo_kit/core/include/evo_kit/cached_gaussian_sampling.h index ffb822b6c786c84c64e63098894905b09ac27f5d..c033fb7f23e9d3d91754237cad61e181a823db2d 100644 --- a/deepes/core/include/cached_gaussian_sampling.h +++ b/evo_kit/core/include/evo_kit/cached_gaussian_sampling.h @@ -12,18 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. // -#ifndef CACHED_GAUSSIAN_SAMPLING_H -#define CACHED_GAUSSIAN_SAMPLING_H +#ifndef EVO_KIT_CACHED_GAUSSIAN_SAMPLING_H +#define EVO_KIT_CACHED_GAUSSIAN_SAMPLING_H +#include #include #include #include #include #include "sampling_method.h" #include "utils.h" -#include -namespace deep_es { +namespace evo_kit { class CachedGaussianSampling: public SamplingMethod { @@ -33,12 +33,12 @@ public: ~CachedGaussianSampling(); /*Initialize the sampling algorithm given the config with the protobuf format. - *DeepES library uses only one configuration file for all sampling algorithms. + *EvoKit library uses only one configuration file for all sampling algorithms. A defalut configuration file can be found at: . // TODO: where? Usally you won't have to modify the configuration items of other algorithms if you are not using them. */ - bool load_config(const DeepESConfig& config); + bool load_config(const EvoKitConfig& config); /*@brief generate Gaussian noise and the related key. * diff --git a/deepes/core/include/gaussian_sampling.h b/evo_kit/core/include/evo_kit/gaussian_sampling.h similarity index 88% rename from deepes/core/include/gaussian_sampling.h rename to evo_kit/core/include/evo_kit/gaussian_sampling.h index 4ed6c614cd76704e71c2e4d09d60d0f8c62e6a0b..c0fc66f058f2d1b9224d19d5c029cdca1853f638 100644 --- a/deepes/core/include/gaussian_sampling.h +++ b/evo_kit/core/include/evo_kit/gaussian_sampling.h @@ -12,17 +12,17 @@ // See the License for the specific language governing permissions and // limitations under the License. // -#ifndef GAUSSIAN_SAMPLING_H -#define GAUSSIAN_SAMPLING_H +#ifndef EVO_KIT_GAUSSIAN_SAMPLING_H +#define EVO_KIT_GAUSSIAN_SAMPLING_H #include #include #include #include -#include "sampling_method.h" -#include "utils.h" +#include "evo_kit/sampling_method.h" +#include "evo_kit/utils.h" -namespace deep_es { +namespace evo_kit { class GaussianSampling: public SamplingMethod { @@ -32,12 +32,12 @@ public: ~GaussianSampling() {} /*Initialize the sampling algorithm given the config with the protobuf format. - *DeepES library uses only one configuration file for all sampling algorithms. + *EvoKit library uses only one configuration file for all sampling algorithms. A defalut configuration file can be found at: . // TODO: where? Usally you won't have to modify the configuration items of other algorithms if you are not using them. */ - bool load_config(const DeepESConfig& config); + bool load_config(const EvoKitConfig& config); /*@brief generate Gaussian noise and the related key. * diff --git a/deepes/core/include/optimizer.h b/evo_kit/core/include/evo_kit/optimizer.h similarity index 94% rename from deepes/core/include/optimizer.h rename to evo_kit/core/include/evo_kit/optimizer.h index ca0a7db359590ee2282aee87ef0c92bec4bde6cb..5c41bc5d405b00bef71affa0fa6cb82a13afd1b2 100644 --- a/deepes/core/include/optimizer.h +++ b/evo_kit/core/include/evo_kit/optimizer.h @@ -12,13 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef OPTIMIZER_H -#define OPTIMIZER_H +#ifndef EVO_KIT_OPTIMIZER_H +#define EVO_KIT_OPTIMIZER_H -#include #include +#include -namespace deep_es { +namespace evo_kit { /*@brief Optimizer. Base class for optimizers. * @@ -71,7 +71,7 @@ protected: virtual void compute_step(float* graident, int size, std::string param_name = "") = 0; float _base_lr; float _update_times; - std::map _params_size; + std::unordered_map _params_size; }; diff --git a/deepes/core/include/optimizer_factory.h b/evo_kit/core/include/evo_kit/optimizer_factory.h similarity index 79% rename from deepes/core/include/optimizer_factory.h rename to evo_kit/core/include/evo_kit/optimizer_factory.h index 9ba7b37a6160bcb20d2fe3219eb480abc632b700..6e3e099110d17efefd8dce9d5090b06fc27c0d21 100644 --- a/deepes/core/include/optimizer_factory.h +++ b/evo_kit/core/include/evo_kit/optimizer_factory.h @@ -12,18 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef OPTIMIZER_FACTORY_H -#define OPTIMIZER_FACTORY_H +#ifndef EVO_KIT_OPTIMIZER_FACTORY_H +#define EVO_KIT_OPTIMIZER_FACTORY_H #include -#include -#include "optimizer.h" -#include "sgd_optimizer.h" -#include "adam_optimizer.h" -#include "deepes.pb.h" #include +#include +#include "evo_kit/adam_optimizer.h" +#include "evo_kit/evo_kit.pb.h" +#include "evo_kit/optimizer.h" +#include "evo_kit/sgd_optimizer.h" -namespace deep_es { +namespace evo_kit { /* @brief: create an optimizer according to the configuration" * @args: * config: configuration for the optimizer @@ -31,6 +31,6 @@ namespace deep_es { */ std::shared_ptr create_optimizer(const OptimizerConfig& optimizer_config); -}//namespace +} // namespace #endif diff --git a/deepes/core/include/sampling_factory.h b/evo_kit/core/include/evo_kit/sampling_factory.h similarity index 67% rename from deepes/core/include/sampling_factory.h rename to evo_kit/core/include/evo_kit/sampling_factory.h index df5bbef5d12e4e5360b5b00632f22de40caf6af9..e7e859cddcb88784b2d01b9642bcbc1b23e378cb 100644 --- a/deepes/core/include/sampling_factory.h +++ b/evo_kit/core/include/evo_kit/sampling_factory.h @@ -12,25 +12,25 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef SAMPLING_FACTORY_H -#define SAMPLING_FACTORY_H +#ifndef EVO_KIT_SAMPLING_FACTORY_H +#define EVO_KIT_SAMPLING_FACTORY_H #include -#include -#include "sampling_method.h" -#include "gaussian_sampling.h" -#include "cached_gaussian_sampling.h" -#include "deepes.pb.h" #include +#include +#include "evo_kit/cached_gaussian_sampling.h" +#include "evo_kit/evo_kit.pb.h" +#include "evo_kit/gaussian_sampling.h" +#include "evo_kit/sampling_method.h" -namespace deep_es { +namespace evo_kit { /* @brief: create an sampling_method according to the configuration" * @args: - * config: configuration for the DeepES + * config: configuration for the EvoKit * */ -std::shared_ptr create_sampling_method(const DeepESConfig& Config); +std::shared_ptr create_sampling_method(const EvoKitConfig& Config); -}//namespace +} // namespace #endif diff --git a/deepes/core/include/sampling_method.h b/evo_kit/core/include/evo_kit/sampling_method.h similarity index 90% rename from deepes/core/include/sampling_method.h rename to evo_kit/core/include/evo_kit/sampling_method.h index 69a11aebc8d8318dddac3d960d87e2fb38b01099..dc07dfe7cfefff694eef6cf7ca17ee35848eea98 100644 --- a/deepes/core/include/sampling_method.h +++ b/evo_kit/core/include/evo_kit/sampling_method.h @@ -12,14 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef SAMPLING_METHOD_H -#define SAMPLING_METHOD_H +#ifndef EVO_KIT_SAMPLING_METHOD_H +#define EVO_KIT_SAMPLING_METHOD_H #include #include -#include "deepes.pb.h" +#include "evo_kit/evo_kit.pb.h" -namespace deep_es { +namespace evo_kit { /*Base class for sampling algorithms. All algorithms are required to override the following functions: * @@ -39,12 +39,12 @@ public: virtual ~SamplingMethod() {} /*Initialize the sampling algorithm given the config with the protobuf format. - *DeepES library uses only one configuration file for all sampling algorithms. + *EvoKit library uses only one configuration file for all sampling algorithms. A defalut configuration file can be found at: . // TODO: where? Usally you won't have to modify the configuration items of other algorithms if you are not using them. */ - virtual bool load_config(const DeepESConfig& config) = 0; + virtual bool load_config(const EvoKitConfig& config) = 0; /*@brief generate Gaussian noise and the related key. * diff --git a/deepes/core/include/sgd_optimizer.h b/evo_kit/core/include/evo_kit/sgd_optimizer.h similarity index 84% rename from deepes/core/include/sgd_optimizer.h rename to evo_kit/core/include/evo_kit/sgd_optimizer.h index 51ae172e4dc8d0519cf2681e9c1457d142937830..cd0d68803775df66d1bc90c748fe9801e17176c9 100644 --- a/deepes/core/include/sgd_optimizer.h +++ b/evo_kit/core/include/evo_kit/sgd_optimizer.h @@ -12,14 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef SGD_OPTIMIZER_H -#define SGD_OPTIMIZER_H +#ifndef EVO_KIT_SGD_OPTIMIZER_H +#define EVO_KIT_SGD_OPTIMIZER_H -#include #include -#include "optimizer.h" +#include +#include "evo_kit/optimizer.h" -namespace deep_es { +namespace evo_kit { /*@brief SGDOptimizer. * Implements stochastic gradient descent (optionally with momentum). @@ -38,9 +38,9 @@ protected: private: float _momentum; - std::map _velocity; + std::unordered_map _velocity; }; -} +} // namespace #endif diff --git a/deepes/core/include/utils.h b/evo_kit/core/include/evo_kit/utils.h similarity index 96% rename from deepes/core/include/utils.h rename to evo_kit/core/include/evo_kit/utils.h index 95e17c407e6563e4d5c61fd2a3dd5df4ab68d2c3..fd704fd384de70683445d65d5609f97b9979907a 100644 --- a/deepes/core/include/utils.h +++ b/evo_kit/core/include/evo_kit/utils.h @@ -12,18 +12,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef UTILS_H -#define UTILS_H +#ifndef EVO_KIT_UTILS_H +#define EVO_KIT_UTILS_H -#include -#include #include +#include #include -#include "deepes.pb.h" #include -#include +#include +#include "evo_kit/evo_kit.pb.h" -namespace deep_es { +namespace evo_kit { /*Return ranks that is normliazed to [-0.5, 0.5] with the rewards as input. Args: diff --git a/deepes/core/proto/deepes.proto b/evo_kit/core/proto/evo_kit/evo_kit.proto similarity index 97% rename from deepes/core/proto/deepes.proto rename to evo_kit/core/proto/evo_kit/evo_kit.proto index aa3efc1ce3923e870b65f1374111150867872fed..fc4f68d9247e63b1d98b35ebd338052ffb7eb9a6 100644 --- a/deepes/core/proto/deepes.proto +++ b/evo_kit/core/proto/evo_kit/evo_kit.proto @@ -14,9 +14,9 @@ syntax = "proto2"; -package deep_es; +package evo_kit; -message DeepESConfig { +message EvoKitConfig { //sampling configuration optional int32 seed = 1 [default = 18]; optional int32 buffer_size = 2 [default = 100000]; diff --git a/deepes/core/src/adam_optimizer.cc b/evo_kit/core/src/adam_optimizer.cc similarity index 97% rename from deepes/core/src/adam_optimizer.cc rename to evo_kit/core/src/adam_optimizer.cc index 42b225a6acf4fa8c511d12269ef0f1aac88378cb..44f36e4d1d3e01ae2cceeba16d95d7aaa24a2c09 100644 --- a/deepes/core/src/adam_optimizer.cc +++ b/evo_kit/core/src/adam_optimizer.cc @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "adam_optimizer.h" +#include "evo_kit/adam_optimizer.h" -namespace deep_es { +namespace evo_kit { AdamOptimizer::~AdamOptimizer() { for (auto iter = _momentum.begin(); iter != _momentum.end(); iter++) { diff --git a/deepes/core/src/cached_gaussian_sampling.cc b/evo_kit/core/src/cached_gaussian_sampling.cc similarity index 79% rename from deepes/core/src/cached_gaussian_sampling.cc rename to evo_kit/core/src/cached_gaussian_sampling.cc index 6b933f88848b3972c918e641bf22439b5ce0b984..844eca20e2935c4b5e7ac39d5fa07df1c2b13913 100644 --- a/deepes/core/src/cached_gaussian_sampling.cc +++ b/evo_kit/core/src/cached_gaussian_sampling.cc @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "cached_gaussian_sampling.h" +#include "evo_kit/cached_gaussian_sampling.h" -namespace deep_es { +namespace evo_kit { CachedGaussianSampling::CachedGaussianSampling() {} @@ -22,16 +22,16 @@ CachedGaussianSampling::~CachedGaussianSampling() { delete[] _noise_cache; } -bool CachedGaussianSampling::load_config(const DeepESConfig& config) { +bool CachedGaussianSampling::load_config(const EvoKitConfig& config) { bool success = true; _std = config.gaussian_sampling().std(); success = set_seed(config.seed()); - CHECK(success) << "[DeepES] Fail to set seed while load config."; + CHECK(success) << "[EvoKit] Fail to set seed while load config."; _cache_size = config.gaussian_sampling().cache_size(); _noise_cache = new float [_cache_size]; memset(_noise_cache, 0, _cache_size * sizeof(float)); success = _create_noise_cache(); - CHECK(success) << "[DeepES] Fail to create noise_cache while load config."; + CHECK(success) << "[EvoKit] Fail to create noise_cache while load config."; return success; } @@ -39,19 +39,19 @@ bool CachedGaussianSampling::sampling(int* key, float* noise, int64_t size) { bool success = true; if (_noise_cache == nullptr) { - LOG(ERROR) << "[DeepES] Please use load_config() first."; + LOG(ERROR) << "[EvoKit] Please use load_config() first."; success = false; return success; } if (noise == nullptr) { - LOG(ERROR) << "[DeepES] Input noise array cannot be nullptr."; + LOG(ERROR) << "[EvoKit] Input noise array cannot be nullptr."; success = false; return success; } if ((size >= _cache_size) || (size < 0)) { - LOG(ERROR) << "[DeepES] Input size " << size << " is out of bounds [0, " << _cache_size << + LOG(ERROR) << "[EvoKit] Input size " << size << " is out of bounds [0, " << _cache_size << "), cache_size: " << _cache_size; success = false; return success; @@ -74,26 +74,27 @@ bool CachedGaussianSampling::resampling(int key, float* noise, int64_t size) { bool success = true; if (_noise_cache == nullptr) { - LOG(ERROR) << "[DeepES] Please use load_config() first."; + LOG(ERROR) << "[EvoKit] Please use load_config() first."; success = false; return success; } if (noise == nullptr) { - LOG(ERROR) << "[DeepES] Input noise array cannot be nullptr."; + LOG(ERROR) << "[EvoKit] Input noise array cannot be nullptr."; success = false; return success; } if ((size >= _cache_size) || (size < 0)) { - LOG(ERROR) << "[DeepES] Input size " << size << " is out of bounds [0, " << _cache_size << + LOG(ERROR) << "[EvoKit] Input size " << size << " is out of bounds [0, " << _cache_size << "), cache_size: " << _cache_size; success = false; return success; } if ((key > _cache_size - size) || (key < 0)) { - LOG(ERROR) << "[DeepES] Resampling key " << key << " is out of bounds [0, " << _cache_size - size << + LOG(ERROR) << "[EvoKit] Resampling key " << key << " is out of bounds [0, " + << _cache_size - size << "], cache_size: " << _cache_size << ", size: " << size; success = false; return success; diff --git a/deepes/core/src/gaussian_sampling.cc b/evo_kit/core/src/gaussian_sampling.cc similarity index 86% rename from deepes/core/src/gaussian_sampling.cc rename to evo_kit/core/src/gaussian_sampling.cc index 0eaf8a69290759e7d60bb1be673aebc6db3961c1..776c2c4da940fafd23e073dd97002876ddfc8673 100644 --- a/deepes/core/src/gaussian_sampling.cc +++ b/evo_kit/core/src/gaussian_sampling.cc @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "gaussian_sampling.h" +#include "evo_kit/gaussian_sampling.h" -namespace deep_es { +namespace evo_kit { -bool GaussianSampling::load_config(const DeepESConfig& config) { +bool GaussianSampling::load_config(const EvoKitConfig& config) { bool success = true; _std = config.gaussian_sampling().std(); success = set_seed(config.seed()); @@ -27,7 +27,7 @@ bool GaussianSampling::sampling(int* key, float* noise, int64_t size) { bool success = true; if (noise == nullptr) { - LOG(ERROR) << "[DeepES] Input noise array cannot be nullptr."; + LOG(ERROR) << "[EvoKit] Input noise array cannot be nullptr."; success = false; return success; } @@ -48,7 +48,7 @@ bool GaussianSampling::resampling(int key, float* noise, int64_t size) { bool success = true; if (noise == nullptr) { - LOG(ERROR) << "[DeepES] Input noise array cannot be nullptr."; + LOG(ERROR) << "[EvoKit] Input noise array cannot be nullptr."; success = false; } else { std::default_random_engine generator(key); diff --git a/deepes/core/src/optimizer_factory.cc b/evo_kit/core/src/optimizer_factory.cc similarity index 96% rename from deepes/core/src/optimizer_factory.cc rename to evo_kit/core/src/optimizer_factory.cc index 028786a47778486831b6a27c525a451190484a43..6137d623fc1b023cc8d8edc8c988aced66a482c0 100644 --- a/deepes/core/src/optimizer_factory.cc +++ b/evo_kit/core/src/optimizer_factory.cc @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "optimizer_factory.h" +#include "evo_kit/optimizer_factory.h" -namespace deep_es { +namespace evo_kit { std::shared_ptr create_optimizer(const OptimizerConfig& optimizer_config) { std::shared_ptr optimizer; diff --git a/deepes/core/src/sampling_factory.cc b/evo_kit/core/src/sampling_factory.cc similarity index 83% rename from deepes/core/src/sampling_factory.cc rename to evo_kit/core/src/sampling_factory.cc index 8f748505c45e0866aa07210f80363ba2c2442992..8a0b8109a61a6ecaa80d82b8a8042c89574ea5a6 100644 --- a/deepes/core/src/sampling_factory.cc +++ b/evo_kit/core/src/sampling_factory.cc @@ -12,12 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "sampling_factory.h" +#include "evo_kit/sampling_factory.h" -namespace deep_es { +namespace evo_kit { -std::shared_ptr create_sampling_method(const DeepESConfig& config) { +std::shared_ptr create_sampling_method(const EvoKitConfig& config) { std::shared_ptr sampling_method; bool cached = config.gaussian_sampling().cached(); @@ -32,7 +32,7 @@ std::shared_ptr create_sampling_method(const DeepESConfig& confi if (success) { return sampling_method; } else { - LOG(ERROR) << "[DeepES] Fail to create sampling_method"; + LOG(ERROR) << "[EvoKit] Fail to create sampling_method"; return nullptr; } diff --git a/deepes/core/src/sgd_optimizer.cc b/evo_kit/core/src/sgd_optimizer.cc similarity index 95% rename from deepes/core/src/sgd_optimizer.cc rename to evo_kit/core/src/sgd_optimizer.cc index 307881fec06c00853c77b372667ef0f1d7771feb..0b3174bffa3d7b3f3b353b18aab8eb428ba70437 100644 --- a/deepes/core/src/sgd_optimizer.cc +++ b/evo_kit/core/src/sgd_optimizer.cc @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "sgd_optimizer.h" +#include "evo_kit/sgd_optimizer.h" -namespace deep_es { +namespace evo_kit { SGDOptimizer::~SGDOptimizer() { for (auto iter = _velocity.begin(); iter != _velocity.end(); iter++) { diff --git a/deepes/core/src/utils.cc b/evo_kit/core/src/utils.cc similarity index 97% rename from deepes/core/src/utils.cc rename to evo_kit/core/src/utils.cc index ad7214dbb5b419609bfb802f57dd39ded3d4b5b0..e47b7d097f0f164a83fb96f6ae538e5a5f2370ea 100644 --- a/deepes/core/src/utils.cc +++ b/evo_kit/core/src/utils.cc @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "utils.h" +#include "evo_kit/utils.h" #include -namespace deep_es { +namespace evo_kit { bool compute_centered_ranks(std::vector& reward) { std::vector> reward_index; diff --git a/deepes/demo/cartpole_config.prototxt b/evo_kit/demo/cartpole_config.prototxt similarity index 88% rename from deepes/demo/cartpole_config.prototxt rename to evo_kit/demo/cartpole_config.prototxt index 90d8b527ff49b60d50d35984d6751267a2757ce8..2707cb60171a47675f1f5a0625de487ad04904f5 100644 --- a/deepes/demo/cartpole_config.prototxt +++ b/evo_kit/demo/cartpole_config.prototxt @@ -1,11 +1,9 @@ seed: 1024 - gaussian_sampling { std: 0.5 cached: true - cache_size : 100000 + cache_size: 100000 } - optimizer { type: "Adam" base_lr: 0.05 @@ -14,7 +12,6 @@ optimizer { beta2: 0.999 epsilon: 1e-08 } - async_es { model_iter_id: 0 } diff --git a/deepes/demo/paddle/cartpole_async_solver.cc b/evo_kit/demo/paddle/cartpole_async_solver.cc similarity index 98% rename from deepes/demo/paddle/cartpole_async_solver.cc rename to evo_kit/demo/paddle/cartpole_async_solver.cc index 2bb7462f5cd6e77b7a0aa635ee02dbf3c5b3913d..22d2507de2ea7f6684e8d835f78f88efd8fc5eb2 100644 --- a/deepes/demo/paddle/cartpole_async_solver.cc +++ b/evo_kit/demo/paddle/cartpole_async_solver.cc @@ -15,11 +15,11 @@ #include #include #include +#include "evo_kit/async_es_agent.h" #include "cartpole.h" -#include "async_es_agent.h" #include "paddle_api.h" -using namespace deep_es; +using namespace evo_kit; using namespace paddle::lite_api; const int ITER = 10; diff --git a/deepes/demo/paddle/cartpole_init_model.zip b/evo_kit/demo/paddle/cartpole_init_model.zip similarity index 100% rename from deepes/demo/paddle/cartpole_init_model.zip rename to evo_kit/demo/paddle/cartpole_init_model.zip diff --git a/deepes/demo/paddle/cartpole_solver_parallel.cc b/evo_kit/demo/paddle/cartpole_solver_parallel.cc similarity index 98% rename from deepes/demo/paddle/cartpole_solver_parallel.cc rename to evo_kit/demo/paddle/cartpole_solver_parallel.cc index d28173e290e74657c9db1032246dd63e02350933..33aa89990f23c744f494b9d9d75002103a0bfbcc 100644 --- a/deepes/demo/paddle/cartpole_solver_parallel.cc +++ b/evo_kit/demo/paddle/cartpole_solver_parallel.cc @@ -16,10 +16,10 @@ #include #include #include "cartpole.h" -#include "es_agent.h" +#include "evo_kit/es_agent.h" #include "paddle_api.h" -using namespace deep_es; +using namespace evo_kit; using namespace paddle::lite_api; const int ITER = 10; diff --git a/deepes/demo/paddle/gen_cartpole_init_model.py b/evo_kit/demo/paddle/gen_cartpole_init_model.py similarity index 100% rename from deepes/demo/paddle/gen_cartpole_init_model.py rename to evo_kit/demo/paddle/gen_cartpole_init_model.py diff --git a/deepes/demo/torch/cartpole_solver_parallel.cc b/evo_kit/demo/torch/cartpole_solver_parallel.cc similarity index 95% rename from deepes/demo/torch/cartpole_solver_parallel.cc rename to evo_kit/demo/torch/cartpole_solver_parallel.cc index f7b071de307fd7f1f0253b3d0c75ef4ebd295ded..2b1c985ddffd8ee7d585b70c92802ce5dbe67310 100644 --- a/deepes/demo/torch/cartpole_solver_parallel.cc +++ b/evo_kit/demo/torch/cartpole_solver_parallel.cc @@ -17,12 +17,12 @@ #include #include #include +#include "evo_kit/gaussian_sampling.h" +#include "evo_kit/es_agent.h" #include "cartpole.h" -#include "gaussian_sampling.h" #include "model.h" -#include "es_agent.h" -using namespace DeepES; +using namespace evo_kit; const int ITER = 10; float evaluate(CartPole& env, std::shared_ptr> agent) { @@ -52,7 +52,7 @@ int main(int argc, char* argv[]) { auto model = std::make_shared(4, 2); std::shared_ptr> agent = std::make_shared>(model, - "../demo/cartpole_config.prototxt"); + "./demo/cartpole_config.prototxt"); // Clone agents to sample (explore). std::vector>> sampling_agents; diff --git a/deepes/demo/torch/model.h b/evo_kit/demo/torch/model.h similarity index 100% rename from deepes/demo/torch/model.h rename to evo_kit/demo/torch/model.h diff --git a/deepes/paddle/include/async_es_agent.h b/evo_kit/paddle/include/evo_kit/async_es_agent.h similarity index 88% rename from deepes/paddle/include/async_es_agent.h rename to evo_kit/paddle/include/evo_kit/async_es_agent.h index f4ca4d9e49517490132d3ecb061de59f3e399da0..a8558820bb86f7d4a6f084aea456e2c9a79ed762 100644 --- a/deepes/paddle/include/async_es_agent.h +++ b/evo_kit/paddle/include/evo_kit/async_es_agent.h @@ -12,15 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef ASYNC_ES_AGENT_H -#define ASYNC_ES_AGENT_H +#ifndef EVO_KIT_ASYNC_ES_AGENT_H +#define EVO_KIT_ASYNC_ES_AGENT_H -#include "es_agent.h" -#include #include +#include +#include "evo_kit/es_agent.h" -namespace deep_es { -/* DeepES agent with PaddleLite as backend. This agent supports asynchronous update. +namespace evo_kit { +/* EvoKit agent with PaddleLite as backend. This agent supports asynchronous update. * Users mainly focus on the following functions: * 1. clone: clone an agent for multi-thread evaluation * 2. add_noise: add noise into parameters. @@ -59,8 +59,8 @@ public: std::vector& noisy_rewards); private: - std::map> _previous_predictors; - std::map _param_delta; + std::unordered_map> _previous_predictors; + std::unordered_map _param_delta; std::string _config_path; /** @@ -97,5 +97,5 @@ private: std::shared_ptr _load_previous_model(std::string model_dir); }; -} //namespace +} // namespace #endif diff --git a/deepes/paddle/include/es_agent.h b/evo_kit/paddle/include/evo_kit/es_agent.h similarity index 88% rename from deepes/paddle/include/es_agent.h rename to evo_kit/paddle/include/evo_kit/es_agent.h index 78240a04af8a8b29414c03b573b9aaa7f91d078b..9a256712a3d99be12ff4a9f409298602192ec21e 100644 --- a/deepes/paddle/include/es_agent.h +++ b/evo_kit/paddle/include/evo_kit/es_agent.h @@ -12,17 +12,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef DEEPES_PADDLE_ES_AGENT_H_ -#define DEEPES_PADDLE_ES_AGENT_H_ +#ifndef EVO_KIT_DEEPES_PADDLE_ES_AGENT_H_ +#define EVO_KIT_DEEPES_PADDLE_ES_AGENT_H_ -#include "paddle_api.h" -#include "optimizer_factory.h" -#include "sampling_factory.h" -#include "utils.h" -#include "deepes.pb.h" #include +#include "evo_kit/evo_kit.pb.h" +#include "evo_kit/optimizer_factory.h" +#include "evo_kit/sampling_factory.h" +#include "evo_kit/utils.h" +#include "paddle_api.h" -namespace deep_es { +namespace evo_kit { typedef paddle::lite_api::PaddlePredictor PaddlePredictor; typedef paddle::lite_api::CxxConfig CxxConfig; @@ -31,7 +31,7 @@ typedef paddle::lite_api::Tensor Tensor; int64_t ShapeProduction(const paddle::lite_api::shape_t& shape); /** - * @brief DeepES agent with PaddleLite as backend. + * @brief EvoKit agent with PaddleLite as backend. * Users mainly focus on the following functions: * 1. clone: clone an agent for multi-thread evaluation * 2. add_noise: add noise into parameters. @@ -88,7 +88,7 @@ protected: std::shared_ptr _sampling_predictor; std::shared_ptr _sampling_method; std::shared_ptr _optimizer; - std::shared_ptr _config; + std::shared_ptr _config; std::shared_ptr _cxx_config; std::vector _param_names; // malloc memory of noise and neg_gradients in advance. @@ -98,6 +98,6 @@ protected: bool _is_sampling_agent; }; -} +} // namespace -#endif /* DEEPES_PADDLE_ES_AGENT_H_ */ +#endif diff --git a/deepes/paddle/src/async_es_agent.cc b/evo_kit/paddle/src/async_es_agent.cc similarity index 91% rename from deepes/paddle/src/async_es_agent.cc rename to evo_kit/paddle/src/async_es_agent.cc index 946bb8da1ef6ca32184511d5080d10b5482a10d3..0bff6e42907f6f83f53ea147051d34d3b4851141 100644 --- a/deepes/paddle/src/async_es_agent.cc +++ b/evo_kit/paddle/src/async_es_agent.cc @@ -12,8 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "async_es_agent.h" -namespace deep_es { +#include "evo_kit/async_es_agent.h" + +namespace evo_kit { AsyncESAgent::AsyncESAgent( const std::string& model_dir, @@ -32,7 +33,8 @@ bool AsyncESAgent::_save() { bool success = true; if (_is_sampling_agent) { - LOG(ERROR) << "[DeepES] Cloned AsyncESAgent cannot call `save`.Please use original AsyncESAgent."; + LOG(ERROR) << + "[EvoKit] Cloned AsyncESAgent cannot call `save`.Please use original AsyncESAgent."; success = false; return success; } @@ -80,9 +82,9 @@ bool AsyncESAgent::_remove_expired_model(int max_to_keep) { int ret = system(rm_command.c_str()); if (ret == 0) { - LOG(INFO) << "[DeepES] remove expired Model: " << dir; + LOG(INFO) << "[EvoKit] remove expired Model: " << dir; } else { - LOG(ERROR) << "[DeepES] fail to remove expired Model: " << dir; + LOG(ERROR) << "[EvoKit] fail to remove expired Model: " << dir; success = false; return success; } @@ -132,7 +134,7 @@ bool AsyncESAgent::_load() { success = model_iter_id == 0 ? true : false; if (!success) { - LOG(WARNING) << "[DeepES] current_model_iter_id is nonzero, but no model is \ + LOG(WARNING) << "[EvoKit] current_model_iter_id is nonzero, but no model is \ found at the dir: " << model_path; } @@ -143,7 +145,7 @@ bool AsyncESAgent::_load() { int model_iter_id = _parse_model_iter_id(dir); if (model_iter_id == -1) { - LOG(WARNING) << "[DeepES] fail to parse model_iter_id: " << dir; + LOG(WARNING) << "[EvoKit] fail to parse model_iter_id: " << dir; success = false; return success; } @@ -152,7 +154,7 @@ bool AsyncESAgent::_load() { if (predictor == nullptr) { success = false; - LOG(WARNING) << "[DeepES] fail to load model: " << dir; + LOG(WARNING) << "[EvoKit] fail to load model: " << dir; return success; } @@ -201,11 +203,11 @@ bool AsyncESAgent::update( std::vector& noisy_info, std::vector& noisy_rewards) { - CHECK(!_is_sampling_agent) << "[DeepES] Cloned ESAgent cannot call update function. \ + CHECK(!_is_sampling_agent) << "[EvoKit] Cloned ESAgent cannot call update function. \ Please use original ESAgent."; bool success = _load(); - CHECK(success) << "[DeepES] fail to load previous models."; + CHECK(success) << "[EvoKit] fail to load previous models."; int current_model_iter_id = _config->async_es().model_iter_id(); @@ -215,7 +217,7 @@ bool AsyncESAgent::update( if (model_iter_id != current_model_iter_id && _previous_predictors.count(model_iter_id) == 0) { - LOG(WARNING) << "[DeepES] The sample with model_dir_id: " << model_iter_id \ + LOG(WARNING) << "[EvoKit] The sample with model_dir_id: " << model_iter_id \ << " cannot match any local model"; success = false; return success; @@ -230,7 +232,7 @@ bool AsyncESAgent::update( float reward = noisy_rewards[i]; int model_iter_id = noisy_info[i].model_iter_id(); bool success = _sampling_method->resampling(key, _noise, _param_size); - CHECK(success) << "[DeepES] resampling error occurs at sample: " << i; + CHECK(success) << "[EvoKit] resampling error occurs at sample: " << i; float* delta = _param_delta[model_iter_id]; // compute neg_gradients @@ -261,7 +263,7 @@ bool AsyncESAgent::update( } success = _save(); - CHECK(success) << "[DeepES] fail to save model."; + CHECK(success) << "[EvoKit] fail to save model."; return true; } diff --git a/deepes/paddle/src/es_agent.cc b/evo_kit/paddle/src/es_agent.cc similarity index 92% rename from deepes/paddle/src/es_agent.cc rename to evo_kit/paddle/src/es_agent.cc index c4d0c72f9dcde6d996cdea74be7f20627c955461..d8f3ebd37299224791f1380f284849195383f65b 100644 --- a/deepes/paddle/src/es_agent.cc +++ b/evo_kit/paddle/src/es_agent.cc @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "es_agent.h" +#include "evo_kit/es_agent.h" #include -namespace deep_es { +namespace evo_kit { int64_t ShapeProduction(const paddle::lite_api::shape_t& shape) { int64_t res = 1; @@ -56,7 +56,7 @@ ESAgent::ESAgent(const std::string& model_dir, const std::string& config_path) { // Original agent can't be used to sample, so keep it same with _predictor for evaluating. _sampling_predictor = _predictor; - _config = std::make_shared(); + _config = std::make_shared(); load_proto_conf(config_path, *_config); _sampling_method = create_sampling_method(*_config); @@ -72,7 +72,7 @@ ESAgent::ESAgent(const std::string& model_dir, const std::string& config_path) { std::shared_ptr ESAgent::clone() { if (_is_sampling_agent) { - LOG(ERROR) << "[DeepES] only original ESAgent can call `clone` function."; + LOG(ERROR) << "[EvoKit] only original ESAgent can call `clone` function."; return nullptr; } @@ -97,7 +97,7 @@ bool ESAgent::update( std::vector& noisy_info, std::vector& noisy_rewards) { if (_is_sampling_agent) { - LOG(ERROR) << "[DeepES] Cloned ESAgent cannot call update function, please use original ESAgent."; + LOG(ERROR) << "[EvoKit] Cloned ESAgent cannot call update function, please use original ESAgent."; return false; } @@ -109,7 +109,7 @@ bool ESAgent::update( int key = noisy_info[i].key(0); float reward = noisy_rewards[i]; bool success = _sampling_method->resampling(key, _noise, _param_size); - CHECK(success) << "[DeepES] resampling error occurs at sample: " << i; + CHECK(success) << "[EvoKit] resampling error occurs at sample: " << i; for (int64_t j = 0; j < _param_size; ++j) { _neg_gradients[j] += _noise[j] * reward; @@ -139,14 +139,14 @@ bool ESAgent::add_noise(SamplingInfo& sampling_info) { if (!_is_sampling_agent) { LOG(ERROR) << - "[DeepES] Original ESAgent cannot call add_noise function, please use cloned ESAgent."; + "[EvoKit] Original ESAgent cannot call add_noise function, please use cloned ESAgent."; success = false; return success; } int key = 0; success = _sampling_method->sampling(&key, _noise, _param_size); - CHECK(success) << "[DeepES] sampling error occurs while add_noise."; + CHECK(success) << "[EvoKit] sampling error occurs while add_noise."; int model_iter_id = _config->async_es().model_iter_id(); sampling_info.add_key(key); sampling_info.set_model_iter_id(model_iter_id); diff --git a/deepes/scripts/build.sh b/evo_kit/scripts/build.sh similarity index 90% rename from deepes/scripts/build.sh rename to evo_kit/scripts/build.sh index 3216f830b401f1a5364b8c6224fcf49973556158..7328847615c9bb60cb528f563e27f5a26e6229b7 100644 --- a/deepes/scripts/build.sh +++ b/evo_kit/scripts/build.sh @@ -1,7 +1,7 @@ #!/bin/bash if [ $# != 1 ]; then - echo "You must choose one framework (paddle/torch) to compile DeepES." + echo "You must choose one framework (paddle/torch) to compile EvoKit." exit 0 fi @@ -36,11 +36,9 @@ else fi #----------------protobuf-------------# -cp ./core/proto/deepes.proto ./ -protoc deepes.proto --cpp_out ./ -mv deepes.pb.h core/include -mv deepes.pb.cc core/src -rm deepes.proto +cd core/proto/ +protoc evo_kit/evo_kit.proto --cpp_out . +cd - #----------------build---------------# echo ${FLAGS} diff --git a/deepes/test/CMakeLists.txt b/evo_kit/test/CMakeLists.txt similarity index 90% rename from deepes/test/CMakeLists.txt rename to evo_kit/test/CMakeLists.txt index be7a983bdd74645ca351a0b6724bf45d98e64429..59a7613695410ff8271bfc35f9910cf75be34c4c 100644 --- a/deepes/test/CMakeLists.txt +++ b/evo_kit/test/CMakeLists.txt @@ -21,11 +21,12 @@ find_package(Torch REQUIRED ON) # include and source file(GLOB test_src "../test/src/*.cc") -file(GLOB core_src "../core/src/*.cc") +file(GLOB core_src "../core/src/*.cc" "../core/proto/evo_kit/*.cc") file(GLOB agent_src "../torch/src/*.cc") include_directories("../torch/include") include_directories("../core/include") +include_directories("../core/proto") include_directories("../benchmark") include_directories("../test/include") diff --git a/deepes/test/include/torch_demo_model.h b/evo_kit/test/include/torch_demo_model.h similarity index 100% rename from deepes/test/include/torch_demo_model.h rename to evo_kit/test/include/torch_demo_model.h diff --git a/deepes/test/prototxt/torch_sin_cached_config.prototxt b/evo_kit/test/prototxt/torch_sin_cached_config.prototxt similarity index 100% rename from deepes/test/prototxt/torch_sin_cached_config.prototxt rename to evo_kit/test/prototxt/torch_sin_cached_config.prototxt diff --git a/deepes/test/prototxt/torch_sin_config.prototxt b/evo_kit/test/prototxt/torch_sin_config.prototxt similarity index 100% rename from deepes/test/prototxt/torch_sin_config.prototxt rename to evo_kit/test/prototxt/torch_sin_config.prototxt diff --git a/deepes/test/run_test.sh b/evo_kit/test/run_test.sh similarity index 85% rename from deepes/test/run_test.sh rename to evo_kit/test/run_test.sh index 52fafdb6d718aa84cd01d6cc6407e28e54f1f822..51872338481772d6fc57b61fbd63816c2c3d65b7 100644 --- a/deepes/test/run_test.sh +++ b/evo_kit/test/run_test.sh @@ -12,10 +12,9 @@ echo "Cannot find the torch library: ../libtorch" fi #----------------protobuf-------------# -cp ./core/proto/deepes.proto ./ -protoc deepes.proto --cpp_out ./ -mv deepes.pb.h core/include -mv deepes.pb.cc core/src +cd core/proto/ +protoc evo_kit/evo_kit.proto --cpp_out . +cd - #----------------build---------------# diff --git a/deepes/test/src/optimizers_test.cc b/evo_kit/test/src/optimizers_test.cc similarity index 92% rename from deepes/test/src/optimizers_test.cc rename to evo_kit/test/src/optimizers_test.cc index 29be5320342532bb1bfaa765c2411946afdd430a..1c561e3085bdf5f9102ba29115e7e8fabbf8ed75 100644 --- a/deepes/test/src/optimizers_test.cc +++ b/evo_kit/test/src/optimizers_test.cc @@ -14,14 +14,13 @@ #include "gtest/gtest.h" #include -#include "optimizer_factory.h" +#include "evo_kit/optimizer_factory.h" #include -namespace deep_es { - +namespace evo_kit { TEST(SGDOptimizersTest, Method_update) { - std::shared_ptr config = std::make_shared(); + std::shared_ptr config = std::make_shared(); auto optimizer_config = config->mutable_optimizer(); optimizer_config->set_base_lr(1.0); optimizer_config->set_type("sgd"); @@ -39,7 +38,7 @@ TEST(SGDOptimizersTest, Method_update) { } TEST(AdamOptimizersTest, Method_update) { - std::shared_ptr config = std::make_shared(); + std::shared_ptr config = std::make_shared(); auto optimizer_config = config->mutable_optimizer(); optimizer_config->set_base_lr(1.0); optimizer_config->set_type("adam"); diff --git a/deepes/test/src/sampling_test.cc b/evo_kit/test/src/sampling_test.cc similarity index 93% rename from deepes/test/src/sampling_test.cc rename to evo_kit/test/src/sampling_test.cc index 6ecd24c64fbd6bc38372cf2a57b4ca3934d1b5d2..e707a63354836f3e70b42d819bab8b0fc3f79e70 100644 --- a/deepes/test/src/sampling_test.cc +++ b/evo_kit/test/src/sampling_test.cc @@ -14,18 +14,17 @@ #include "gtest/gtest.h" #include -#include "sampling_method.h" -#include "gaussian_sampling.h" -#include "cached_gaussian_sampling.h" +#include "evo_kit/sampling_method.h" +#include "evo_kit/gaussian_sampling.h" +#include "evo_kit/cached_gaussian_sampling.h" #include -namespace deep_es { - +namespace evo_kit { class SamplingTest : public ::testing::Test { protected: void init_sampling_method(bool cached) { - config = std::make_shared(); + config = std::make_shared(); config->set_seed(1024); auto sampling_config = config->mutable_gaussian_sampling(); sampling_config->set_std(1.0); @@ -39,7 +38,7 @@ class SamplingTest : public ::testing::Test { } std::shared_ptr sampler; - std::shared_ptr config; + std::shared_ptr config; float array[3] = {1.0, 2.0, 3.0}; int cache_size = 100; // default cache_size 100 int key = 0; diff --git a/deepes/test/src/torch_agent_test.cc b/evo_kit/test/src/torch_agent_test.cc similarity index 98% rename from deepes/test/src/torch_agent_test.cc rename to evo_kit/test/src/torch_agent_test.cc index 2b385907f507030acadb47696207b57eed31c8ed..8210b83492f60c8b8482ece1f1d7ce68ff65bc0f 100644 --- a/deepes/test/src/torch_agent_test.cc +++ b/evo_kit/test/src/torch_agent_test.cc @@ -17,16 +17,16 @@ #include #include -#include "gaussian_sampling.h" +#include "evo_kit/gaussian_sampling.h" +#include "evo_kit/es_agent.h" #include "torch_demo_model.h" -#include "es_agent.h" #include #include #include #include -namespace deep_es { +namespace evo_kit { // The fixture for testing class Foo. diff --git a/deepes/test/src/utils_test.cc b/evo_kit/test/src/utils_test.cc similarity index 95% rename from deepes/test/src/utils_test.cc rename to evo_kit/test/src/utils_test.cc index e6417f4ad24c42afa57acacfb10a70d12478a8a7..a0c8d2c963a698475831a641c3eefc8abcc3693a 100644 --- a/deepes/test/src/utils_test.cc +++ b/evo_kit/test/src/utils_test.cc @@ -14,9 +14,9 @@ #include "gtest/gtest.h" #include -#include "utils.h" +#include "evo_kit/utils.h" -namespace deep_es { +namespace evo_kit { // Tests that the Utils::compute_centered_rank() method. TEST(UtilsTest, Method_compute_centered_ranks) { diff --git a/deepes/test/unit_test.cc b/evo_kit/test/unit_test.cc similarity index 100% rename from deepes/test/unit_test.cc rename to evo_kit/test/unit_test.cc diff --git a/deepes/torch/include/es_agent.h b/evo_kit/torch/include/evo_kit/es_agent.h similarity index 95% rename from deepes/torch/include/es_agent.h rename to evo_kit/torch/include/evo_kit/es_agent.h index 78dab80a49d6775ad0d98d04c88d6c50569cfc0b..856034f75fc2c025cbb3aed74c5eac4edc888178 100644 --- a/deepes/torch/include/es_agent.h +++ b/evo_kit/torch/include/evo_kit/es_agent.h @@ -17,12 +17,12 @@ #include #include -#include "optimizer_factory.h" -#include "sampling_factory.h" -#include "utils.h" -#include "deepes.pb.h" +#include "evo_kit/optimizer_factory.h" +#include "evo_kit/sampling_factory.h" +#include "evo_kit/utils.h" +#include "evo_kit/evo_kit.pb.h" -namespace deep_es{ +namespace evo_kit{ /** * @brief DeepES agent for Torch. @@ -45,7 +45,7 @@ public: ESAgent(std::shared_ptr model, std::string config_path): _model(model) { _is_sampling_agent = false; - _config = std::make_shared(); + _config = std::make_shared(); load_proto_conf(config_path, *_config); _sampling_method = create_sampling_method(*_config); _optimizer = create_optimizer(_config->optimizer()); @@ -145,7 +145,7 @@ public: auto params = _model->named_parameters(); int key = 0; success = _sampling_method->sampling(&key, _noise, _param_size); - CHECK(success) << "[DeepES] sampling error occurs while add_noise."; + CHECK(success) << "[EvoKit] sampling error occurs while add_noise."; sampling_info.add_key(key); int64_t counter = 0; for (auto& param: sampling_params) { @@ -184,7 +184,7 @@ private: bool _is_sampling_agent; std::shared_ptr _sampling_method; std::shared_ptr _optimizer; - std::shared_ptr _config; + std::shared_ptr _config; int64_t _param_size; // malloc memory of noise and neg_gradients in advance. float* _noise;