Skip to content
Snippets Groups Projects
Commit 8e69ae2d authored by Martin Beseda's avatar Martin Beseda
Browse files

ENH: Now it's possible to specify different neuron types for different hidden...

ENH: Now it's possible to specify different neuron types for different hidden layers in FullyConnectedFFNs.
parent 14c286ba
No related branches found
No related tags found
No related merge requests found
......@@ -1007,6 +1007,21 @@ namespace lib4neuro {
}
FullyConnectedFFN::FullyConnectedFFN(std::vector<unsigned int>* neuron_numbers, NEURON_TYPE hidden_layer_neuron_type) : NeuralNetwork() {
std::vector<NEURON_TYPE> tmp;
for(auto i = 0; i < neuron_numbers->size(); i++) {
tmp.emplace_back(hidden_layer_neuron_type);
}
this->init(neuron_numbers, &tmp);
}
FullyConnectedFFN::FullyConnectedFFN(std::vector<unsigned int>* neuron_numbers,
std::vector<lib4neuro::NEURON_TYPE>* hidden_layer_neuron_types) : NeuralNetwork() {
this->init(neuron_numbers, hidden_layer_neuron_types);
}
void FullyConnectedFFN::init(std::vector<unsigned int>* neuron_numbers, std::vector<NEURON_TYPE>* hidden_layer_neuron_types) {
if(neuron_numbers->size() < 2) {
THROW_INVALID_ARGUMENT_ERROR("Parameter 'neuron_numbers' specifying numbers of neurons in network's layers "
"doesn't specify input and output layers, which are compulsory!");
......@@ -1065,9 +1080,10 @@ namespace lib4neuro {
size_t neuron_id;
/* Create new hidden neuron */
switch (hidden_layer_neuron_type) {
switch (hidden_layer_neuron_types->at(i-1)) {
case NEURON_TYPE::BINARY: {
neuron_id = this->add_neuron(new NeuronBinary, BIAS_TYPE::NEXT_BIAS);
COUT_DEBUG("Added BINARY neuron." << std::endl);
break;
}
......@@ -1078,11 +1094,13 @@ namespace lib4neuro {
case NEURON_TYPE::LINEAR: {
neuron_id = this->add_neuron(new NeuronLinear, BIAS_TYPE::NEXT_BIAS);
COUT_DEBUG("Added LINEAR neuron." << std::endl);
break;
}
case NEURON_TYPE::LOGISTIC: {
neuron_id = this->add_neuron(new NeuronLogistic, BIAS_TYPE::NEXT_BIAS);
COUT_DEBUG("Added LOGISTIC neuron." << std::endl);
break;
}
}
......
......@@ -420,6 +420,16 @@ namespace lib4neuro {
* @param hidden_layer_neuron_type
*/
LIB4NEURO_API explicit FullyConnectedFFN(std::vector<unsigned int>* neuron_numbers, NEURON_TYPE hidden_layer_neuron_type);
/**
*
* @param neuron_numbers
* @param hidden_layer_neuron_types
*/
LIB4NEURO_API explicit FullyConnectedFFN(std::vector<unsigned int>* neuron_numbers, std::vector<NEURON_TYPE>* hidden_layer_neuron_types);
private:
void init(std::vector<unsigned int>* neuron_numbers, std::vector<NEURON_TYPE>* hidden_layer_neuron_types);
};
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment