We start with the simplest form of a neural network, a perceptron. It consists of a single neuron that takes input, applies weights, and outputs a result based on an activation function. This basic unit learns to classify inputs into two categories by adjusting its weights during training. In order to show how it works, I've written a simple code that uses a "perceptron" which is implemented implicitly within the calculation of the output during the forward propagation step and the subsequent adjustment of synaptic weights during the backpropagation step.
There are various activation functions used in neural networks.
The Step Function outputs 1 if the input is 0 or positive, and 0 if the input is negative. It's useful for binary decisions.
The Piecewise Linear Function changes behavior at different input ranges: outputs -0.5 for inputs less than -1, passes inputs through unchanged between -1 and 1, and outputs 0.5 for inputs greater than 1.
The Maxout ReLU takes the maximum of the input and half the input. This can help models learn more complex patterns.
The Parametric ReLU allows the negative slope to be learned, rather than being fixed. It’s useful for allowing the network to adapt better.
where
The Exponential ReLU uses an exponential function for negative inputs and is linear for positive inputs. This helps in avoiding zero gradients for negative values.
The Softplus function smooths the ReLU function. It’s continuous and differentiable everywhere, which helps in training neural networks.
The Swish function is a smooth, self-gated activation function that tends to work well in deep networks. It helps gradients flow better during training.
where
The Sigmoid function compresses input values to a range between 0 and 1, which is useful for probability estimates in binary classification.
The Softmax function converts a vector of raw scores into probabilities that sum to 1. It’s commonly used for multi-class classification problems.
where ( x_i ) is the score for class ( i ), and the denominator is the sum of the exponentials of all scores.
We expand from the single perceptron to a feedforward neural network (FNN) with multiple layers. This FNN consists of an input layer, one or more hidden layers, and an output layer. Each neuron in one layer is connected to every neuron in the next layer, and information flows in one direction without loops. This type of network can handle more complex patterns and tasks compared to a single perceptron.I've written a simple code thst represents a FFN with one layer.
TODO
matplotlib==3.6.3
numpy==1.24.2
TODO
TODO
This project is licensed under the MIT License - see the LICENSE.md file for details