Dense Layers#
custom_neural_net_creator.dense#
- class custom_neural_net_creator.dense.Dense(input_shape: int, output_shape: int)#
Bases:
object- backward_prop(dE_dY: ndarray[Any, dtype[_ScalarType_co]], learning_rate: float) ndarray[Any, dtype[_ScalarType_co]]#
Perform backward propagation through the Dense layer and update weights and biases.
This method performs backward propagation through the Dense layer. It calculates the gradients of the error with respect to the layer’s weights, biases, and input. The gradients are then used to update the weights and biases using gradient descent. The method returns the gradient of the error with respect to the layer’s input, to be used for backpropagation in previous layers.
- Parameters:
dE_dY (npt.NDArray) – The gradient of the error function.
learning_rate (float) – The learning rate for perorming gradient descent.
- Returns:
The gradient of the error with respect to current layer’s input.
- Return type:
npt.NDArray
- forward_prop(x: ndarray[Any, dtype[_ScalarType_co]]) ndarray[Any, dtype[_ScalarType_co]]#
Perform forward propagation through the Dense layer.
This method computes the forward propagation of input data through the Dense layer. The output is calculated by performing a dot product between the input and the layer’s weights, adding the bias, and returning the result. It saves the input x for later use in backpropagation.
- Parameters:
x (npt.NDArray) – The input data of the Dense layer.
- Returns:
The output of the Dense layer.
- Return type:
npt.NDArray