Dense¶
-
class
Dense(output_size: int, activation: Activation, weight_initializer: bluebird.weight_initializers.WeightInitializer = <bluebird.weight_initializers.HeWeightInitializer object>, bias_initializer: bluebird.weight_initializers.WeightInitializer = <bluebird.weight_initializers.ZerosWeightInitializer object>)¶ Bases:
bluebird.layers.layer.LayerCombination of linear and activation layer.
It takes activation later, and output dimension for an argument, so that you don’t have to specify them seperably.
Also ihnerits the base Layer class.
Example:
dense = Dense(50, activation=Relu()) net = NeuralNet([ ... dense, ... ])
-
__init__(output_size: int, activation: Activation, weight_initializer: bluebird.weight_initializers.WeightInitializer = <bluebird.weight_initializers.HeWeightInitializer object>, bias_initializer: bluebird.weight_initializers.WeightInitializer = <bluebird.weight_initializers.ZerosWeightInitializer object>) → None¶ Initializes the object.
- Parameters
output_size (int) – dimension of the output
activation (
Activation) – activation functionweight_initializer (
WeightInitializer, optional) – defines how weights are initialized, defaults to HeWeightInitializerbias_initializer (
WeightInitializer, optional) – defines how weights are initialized, defaults to ZerosWeightInitializer
Methods
__init__(output_size, activation[, …])Initializes the object.
backward(grad)Used to calculate the gradients of weights and biases.
build(input_size)Called by the model, before its training step.
forward(inputs[, training])Called each time the data passes throughout the nework.
Returns params of layer.
-
backward(grad: numpy.ndarray) → numpy.ndarray¶ Used to calculate the gradients of weights and biases.
- Parameters
grad (
Tensor) – gradient from previous layer or loss function.- Returns
Gradient
- Return type
Tensor
-
build(input_size: int) → None¶ Called by the model, before its training step.
It sets the input size and initializes the weights.
- Parameters
input_size (int) – output size from previous layer
-
forward(inputs: numpy.ndarray, training: bool = False) → numpy.ndarray¶ Called each time the data passes throughout the nework.
- Parameters
inputs (
Tensor) – output from the previous layertraining (bool, optional) – set to true during training, and is false when network predicts
- Returns
processed input data
- Return type
Tensor
-
get_params() → Dict¶ Returns params of layer.
- Returns
all params of layer
- Return type
dict
-