From be4d839c983e1794df4c244154361c58b40c62f7 Mon Sep 17 00:00:00 2001 From: davidjacnogueira Date: Thu, 3 Nov 2016 21:50:46 +0000 Subject: [PATCH] FIX bug in the layer create method. --- deps/microunit.h | 3 ++- src/Layer.h | 11 +++++++---- src/Node.h | 3 ++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/deps/microunit.h b/deps/microunit.h index 0c5358a..a389e21 100644 --- a/deps/microunit.h +++ b/deps/microunit.h @@ -59,6 +59,7 @@ #ifndef _MICROUNIT_MICROUNIT_H_ #define _MICROUNIT_MICROUNIT_H_ #include +#include #include #include #include @@ -302,7 +303,7 @@ private: static UnitTester instance; return instance; } - std::map unitfunction_map_; + std::unordered_map unitfunction_map_; }; } diff --git a/src/Layer.h b/src/Layer.h index 297f9eb..cd504d8 100644 --- a/src/Layer.h +++ b/src/Layer.h @@ -29,10 +29,13 @@ public: double constant_weight_init = 0.5) { m_num_nodes = num_nodes; m_num_inputs_per_node = num_inputs_per_node; - m_nodes.resize(num_nodes, - std::move(Node(num_inputs_per_node, - use_constant_weight_init, - constant_weight_init))); + m_nodes.resize(num_nodes); + + for (int i = 0; i < num_nodes; i++) { + m_nodes[i].WeightInitialization(num_inputs_per_node, + use_constant_weight_init, + constant_weight_init); + } }; ~Layer() { diff --git a/src/Node.h b/src/Node.h index b6eedd8..5aacbdb 100644 --- a/src/Node.h +++ b/src/Node.h @@ -43,9 +43,10 @@ public: m_weights.clear(); }; - void WeightInitialization(int m_num_inputs, + void WeightInitialization(int num_inputs, bool use_constant_weight_init = true, double constant_weight_init = 0.5) { + m_num_inputs = num_inputs; //initialize weight vector if (use_constant_weight_init) { m_weights.resize(m_num_inputs, constant_weight_init);