Orderbook Simulation
OrderbookSim is a C++ application simulating a financial market order book. It efficiently manages and matches buy and sell orders while calculating the Volume-Weighted Average Price (VWAP).
|
Represents a single neuron within a neural network layer. More...
#include <Neuron.hpp>
Public Member Functions | |
Neuron (unsigned numOutputs, unsigned myIdx) | |
Constructs a Neuron with a specified number of outputs. More... | |
void | setOutputVal (double val) |
Sets the neuron's output value. More... | |
double | getOutputVal () const |
Retrieves the neuron's output value. More... | |
void | feedForward (const Layer &prevLayer) |
Feeds the input values forward through the neuron. More... | |
void | calcOutputGradients (double targetVal) |
Calculates the gradient for output layer neurons. More... | |
void | calcHiddenGradients (const Layer &nextLayer) |
Calculates gradients for hidden layer neurons. More... | |
void | updateInputWeights (Layer &prevLayer) |
Updates the weights of connections from the previous layer. More... | |
Represents a single neuron within a neural network layer.
The Neuron class handles the neuron's output value, weights for connections to subsequent neurons, and methods for updating weights and calculating gradients.
Neuron::Neuron | ( | unsigned | numOutputs, |
unsigned | myIdx | ||
) |
Constructs a Neuron with a specified number of outputs.
Constructor for the Neuron class.
Initializes a neuron with a certain number of connections (outputs) and an index within its layer.
numOutputs | The number of connections from this neuron to the next layer. |
myIdx | The index of this neuron in its layer. |
Initializes a neuron with a specified number of outputs and index. Each output connection is initialized with a random weight.
numOutputs | The number of connections from this neuron to the next layer. |
myIdx | The index of this neuron in its layer. |
void Neuron::calcHiddenGradients | ( | const Layer & | nextLayer | ) |
Calculates gradients for hidden layer neurons.
Computes the gradient for hidden neurons based on the sum of weights and gradients from the next layer and the derivative of the transfer function.
nextLayer | The next layer of neurons, used to compute the gradient. |
void Neuron::calcOutputGradients | ( | double | targetVal | ) |
Calculates the gradient for output layer neurons.
Uses the difference between the target and actual output values, adjusted by the derivative of the transfer function, to set the gradient.
targetVal | The target value for the output neuron. |
void Neuron::feedForward | ( | const Layer & | prevLayer | ) |
Feeds the input values forward through the neuron.
Calculates the neuron's output by summing the products of inputs and weights, then applies the transfer function.
prevLayer | The previous layer of neurons, used as inputs to this neuron. |
Calculates the neuron's output by summing the products of inputs and weights, and then applies the transfer function to the result.
prevLayer | The previous layer of neurons, used as inputs to this neuron. |
|
inline |
Retrieves the neuron's output value.
|
inline |
Sets the neuron's output value.
val | The output value to be set. |
void Neuron::updateInputWeights | ( | Layer & | prevLayer | ) |
Updates the weights of connections from the previous layer.
Adjusts each weight based on the neuron's gradient and learning parameters (eta and alpha).
prevLayer | The layer of neurons from which the current neuron receives inputs. |