Skip to content
Snippets Groups Projects
NeuronLinear.cpp 867 B
Newer Older
  • Learn to ignore specific revisions
  • //
    // Created by fluffymoo on 11.6.18.
    //
    
    #include "NeuronLinear.h"
    
    
    NeuronLinear::NeuronLinear(double a, double b) {
    
        this->activation_function_parameters = new double[2];
    
        this->activation_function_parameters[0] = a;
        this->activation_function_parameters[1] = b;
    
    }
    
    
    void NeuronLinear::activate( ) {
    
        double x = this->potential;
        double a = this->activation_function_parameters[0];
        double b = this->activation_function_parameters[1];
    
        this->state = b * x + a;
    
    
    }
    
    double NeuronLinear::activation_function_get_partial_derivative(int param_idx) {
    
        if(param_idx == 0){
            return 1.0;
        }
    
        else if(param_idx == 1){
            double x = this->potential;
            return x;
        }
    
        return 0.0;
    
    double NeuronLinear::activation_function_get_derivative( ) {
        double b = this->activation_function_parameters[1];
    
        return b;