Before we define the NeuralNetwork
class, let's take a look at an example of Java code with interface:
public interface IActivationFunction { double calc(double x); public enum ActivationFunctionENUM { STEP, LINEAR, SIGMOID, HYPERTAN } }
The calc()
signature method is used by a specific Activation Function that implements this interface, the Sigmoid
function, for example:
public class Sigmoid implements IActivationFunction { private double a=1.0; public Sigmoid(double _a){this.a=_a;} @Override public double calc(double x){ return 1.0/(1.0+Math.exp(-a*x)); } }
This is one example of polymorphism, whereby a class or method may present different behavior, but yet under the same signature, allowing a flexible application.