getter for activation and basis function of neuron added
This commit is contained in:
@@ -82,7 +82,16 @@ namespace NeuralNetwork
|
|||||||
* @brief Function returns clone of object
|
* @brief Function returns clone of object
|
||||||
*/
|
*/
|
||||||
virtual NeuronInterface* clone() const = 0;
|
virtual NeuronInterface* clone() const = 0;
|
||||||
protected:
|
|
||||||
|
/*
|
||||||
|
* @brief getter for basis function of neuron
|
||||||
|
*/
|
||||||
|
virtual BasisFunction::BasisFunction& getBasisFunction() =0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief getter for activation function of neuron
|
||||||
|
*/
|
||||||
|
virtual ActivationFunction::ActivationFunction& getActivationFunction() =0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -192,6 +201,14 @@ namespace NeuralNetwork
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual BasisFunction::BasisFunction& getBasisFunction() override {
|
||||||
|
return *basis;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ActivationFunction::ActivationFunction& getActivationFunction() override {
|
||||||
|
return *activation;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
BasisFunction::BasisFunction *basis;
|
BasisFunction::BasisFunction *basis;
|
||||||
@@ -206,6 +223,19 @@ namespace NeuralNetwork
|
|||||||
|
|
||||||
class BiasNeuron: public NeuronInterface {
|
class BiasNeuron: public NeuronInterface {
|
||||||
public:
|
public:
|
||||||
|
class usageException : public std::exception {
|
||||||
|
public:
|
||||||
|
usageException(const std::string &text_):text(text_) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual const char* what() const noexcept override {
|
||||||
|
return text.c_str();
|
||||||
|
}
|
||||||
|
protected:
|
||||||
|
std::string text;
|
||||||
|
};
|
||||||
|
|
||||||
virtual float getBias() const override { return 0; };
|
virtual float getBias() const override { return 0; };
|
||||||
|
|
||||||
virtual float getWeight(const NeuronInterface&) const override { return 0; }
|
virtual float getWeight(const NeuronInterface&) const override { return 0; }
|
||||||
@@ -228,10 +258,32 @@ namespace NeuralNetwork
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual BiasNeuron* clone() const { return new BiasNeuron(); }
|
virtual BiasNeuron* clone() const { return new BiasNeuron(); }
|
||||||
|
|
||||||
|
virtual BasisFunction::BasisFunction& getBasisFunction() override {
|
||||||
|
throw usageException("basis function");
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ActivationFunction::ActivationFunction& getActivationFunction() override {
|
||||||
|
throw usageException("activation function");
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class InputNeuron: public NeuronInterface {
|
class InputNeuron: public NeuronInterface {
|
||||||
public:
|
public:
|
||||||
|
class usageException : public std::exception {
|
||||||
|
public:
|
||||||
|
usageException(const std::string &text_):text(text_) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual const char* what() const noexcept override {
|
||||||
|
return text.c_str();
|
||||||
|
}
|
||||||
|
protected:
|
||||||
|
std::string text;
|
||||||
|
};
|
||||||
|
|
||||||
InputNeuron(long unsigned int _id): id_(_id) {
|
InputNeuron(long unsigned int _id): id_(_id) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -258,6 +310,14 @@ namespace NeuralNetwork
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual InputNeuron* clone() const { return new InputNeuron(id_); }
|
virtual InputNeuron* clone() const { return new InputNeuron(id_); }
|
||||||
|
|
||||||
|
virtual BasisFunction::BasisFunction& getBasisFunction() override {
|
||||||
|
throw usageException("basis function");
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ActivationFunction::ActivationFunction& getActivationFunction() override {
|
||||||
|
throw usageException("activation function");
|
||||||
|
}
|
||||||
protected:
|
protected:
|
||||||
long unsigned int id_;
|
long unsigned int id_;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user