mirror of
https://github.com/davidalbertonogueira/MLP.git
synced 2025-12-18 12:54:41 +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_
|
#ifndef _MICROUNIT_MICROUNIT_H_
|
||||||
#define _MICROUNIT_MICROUNIT_H_
|
#define _MICROUNIT_MICROUNIT_H_
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unordered_map>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -302,7 +303,7 @@ private:
|
|||||||
static UnitTester instance;
|
static UnitTester instance;
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
std::map<std::string, UnitFunction> unitfunction_map_;
|
std::unordered_map<std::string, UnitFunction> unitfunction_map_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,10 +29,13 @@ public:
|
|||||||
double constant_weight_init = 0.5) {
|
double constant_weight_init = 0.5) {
|
||||||
m_num_nodes = num_nodes;
|
m_num_nodes = num_nodes;
|
||||||
m_num_inputs_per_node = num_inputs_per_node;
|
m_num_inputs_per_node = num_inputs_per_node;
|
||||||
m_nodes.resize(num_nodes,
|
m_nodes.resize(num_nodes);
|
||||||
std::move(Node(num_inputs_per_node,
|
|
||||||
|
for (int i = 0; i < num_nodes; i++) {
|
||||||
|
m_nodes[i].WeightInitialization(num_inputs_per_node,
|
||||||
use_constant_weight_init,
|
use_constant_weight_init,
|
||||||
constant_weight_init)));
|
constant_weight_init);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
~Layer() {
|
~Layer() {
|
||||||
|
|||||||
@@ -43,9 +43,10 @@ public:
|
|||||||
m_weights.clear();
|
m_weights.clear();
|
||||||
};
|
};
|
||||||
|
|
||||||
void WeightInitialization(int m_num_inputs,
|
void WeightInitialization(int num_inputs,
|
||||||
bool use_constant_weight_init = true,
|
bool use_constant_weight_init = true,
|
||||||
double constant_weight_init = 0.5) {
|
double constant_weight_init = 0.5) {
|
||||||
|
m_num_inputs = num_inputs;
|
||||||
//initialize weight vector
|
//initialize weight vector
|
||||||
if (use_constant_weight_init) {
|
if (use_constant_weight_init) {
|
||||||
m_weights.resize(m_num_inputs, constant_weight_init);
|
m_weights.resize(m_num_inputs, constant_weight_init);
|
||||||
|
|||||||
Reference in New Issue
Block a user