NeuronBinary.cpp 737 Bytes
Newer Older
1 2 3 4 5 6 7 8 9
//
// Created by fluffymoo on 11.6.18.
//

#include "NeuronBinary.h"

NeuronBinary::NeuronBinary(double threshold) {
    this->activation_function_parameters = new double[1];
    this->activation_function_parameters[0] = threshold;
10 11 12

    this->edges_in = new std::vector<Connection*>(0);
    this->edges_out = new std::vector<Connection*>(0);
13 14
}

15
void NeuronBinary::activate( ) {
16

17 18 19 20
    double x = this->potential;
    double threshold = this->activation_function_parameters[0];

    if(x >= threshold){
21 22 23 24 25 26 27
        this->state = 1.0;
    }
    else{
        this->state = 0.0;
    }
}

28 29 30 31
template<class Archive>
void NeuronBinary::serialize(Archive & ar, const unsigned int version) {
    ar & boost::serialization::base_object<Neuron>(*this);
}