mirror of
https://github.com/davidalbertonogueira/MLP.git
synced 2025-12-16 20:07:07 +03:00
FIX bug in the layer create method.
This commit is contained in:
3
deps/microunit.h
vendored
3
deps/microunit.h
vendored
@@ -59,6 +59,7 @@
|
||||
#ifndef _MICROUNIT_MICROUNIT_H_
|
||||
#define _MICROUNIT_MICROUNIT_H_
|
||||
#include <string.h>
|
||||
#include <unordered_map>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -302,7 +303,7 @@ private:
|
||||
static UnitTester instance;
|
||||
return instance;
|
||||
}
|
||||
std::map<std::string, UnitFunction> unitfunction_map_;
|
||||
std::unordered_map<std::string, UnitFunction> unitfunction_map_;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
11
src/Layer.h
11
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() {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user