Network class constructor. Size of input array dims indicates the total number of layers (input + hidden + output), and the value of its elements corresponds the size of each layer.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=ik), | intent(in) | :: | dims(:) | |||
| character(len=*), | intent(in), | optional | :: | activation |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer(kind=ik), | public, | allocatable | :: | dims(:) | |||
| type(layer_type), | public, | allocatable | :: | layers(:) |
| private function net_constructor(dims, activation) | Network class constructor. Size of input array dims indicates the total number of layers (input + hidden + output), and the value of its elements corresponds the size of each layer. |
| procedure, public, pass(self) :: accuracy | |
| procedure, public, pass(self) :: backprop | |
| procedure, public, pass(self) :: fwdprop | |
| procedure, public, pass(self) :: init | |
| procedure, public, pass(self) :: load | |
| procedure, public, pass(self) :: loss | |
| generic, public :: output => output_batch, output_single | |
| procedure, public, pass(self) :: output_batch | |
| procedure, public, pass(self) :: output_single | |
| procedure, public, pass(self) :: save | |
| generic, public :: set_activation => set_activation_equal, set_activation_layers | |
| procedure, public, pass(self) :: set_activation_equal | |
| procedure, public, pass(self) :: set_activation_layers | |
| procedure, public, pass(self) :: sync | |
| generic, public :: train => train_batch, train_epochs, train_single | |
| procedure, public, pass(self) :: train_batch | |
| procedure, public, pass(self) :: train_epochs | |
| procedure, public, pass(self) :: train_single | |
| procedure, public, pass(self) :: update |
Given input x and output y, evaluates the position of the maximum value of the output and returns the number of matches relative to the size of the dataset.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(network_type), | intent(in) | :: | self | |||
| real(kind=rk), | intent(in) | :: | x(:,:) | |||
| real(kind=rk), | intent(in) | :: | y(:,:) |
Given input x and expected output y, returns the loss of the network.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(network_type), | intent(in) | :: | self | |||
| real(kind=rk), | intent(in) | :: | x(:) | |||
| real(kind=rk), | intent(in) | :: | y(:) |
Network class constructor. Size of input array dims indicates the total number of layers (input + hidden + output), and the value of its elements corresponds the size of each layer.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=ik), | intent(in) | :: | dims(:) | |||
| character(len=*), | intent(in), | optional | :: | activation |
Use forward propagation to compute the output of the network. This specific procedure is for a batch of 1-d input data.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(network_type), | intent(in) | :: | self | |||
| real(kind=rk), | intent(in) | :: | x(:,:) |
Use forward propagation to compute the output of the network. This specific procedure is for a single sample of 1-d input data.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(network_type), | intent(in) | :: | self | |||
| real(kind=rk), | intent(in) | :: | x(:) |
Applies a backward propagation through the network and returns the weight and bias gradients.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(network_type), | intent(inout) | :: | self | |||
| real(kind=rk), | intent(in) | :: | y(:) | |||
| type(array2d), | intent(out), | allocatable | :: | dw(:) | ||
| type(array1d), | intent(out), | allocatable | :: | db(:) |
Performs the forward propagation and stores arguments to activation functions and activations themselves for use in backprop.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(network_type), | intent(inout) | :: | self | |||
| real(kind=rk), | intent(in) | :: | x(:) |
Allocates and initializes the layers with given dimensions dims.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(network_type), | intent(inout) | :: | self | |||
| integer(kind=ik), | intent(in) | :: | dims(:) |
Loads the network from file.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(network_type), | intent(inout) | :: | self | |||
| character(len=*), | intent(in) | :: | filename |
Saves the network to a file.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(network_type), | intent(inout) | :: | self | |||
| character(len=*), | intent(in) | :: | filename |
A thin wrapper around layer % set_activation(). This method can be used to set an activation function for all layers at once.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(network_type), | intent(inout) | :: | self | |||
| character(len=*), | intent(in) | :: | activation |
A thin wrapper around layer % set_activation(). This method can be used to set different activation functions for each layer separately.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(network_type), | intent(inout) | :: | self | |||
| character(len=*), | intent(in) | :: | activation(size(self%layers)) |
Broadcasts network weights and biases from specified image to all others.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(network_type), | intent(inout) | :: | self | |||
| integer(kind=ik), | intent(in) | :: | image |
Trains a network using input data x and output data y, and learning rate eta. The learning rate is normalized with the size of the data batch. mini-batch size number of layers
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(network_type), | intent(inout) | :: | self | |||
| real(kind=rk), | intent(in) | :: | x(:,:) | |||
| real(kind=rk), | intent(in) | :: | y(:,:) | |||
| real(kind=rk), | intent(in) | :: | eta |
Trains for num_epochs epochs with mini-bachtes of size equal to batch_size.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(network_type), | intent(inout) | :: | self | |||
| real(kind=rk), | intent(in) | :: | x(:,:) | |||
| real(kind=rk), | intent(in) | :: | y(:,:) | |||
| real(kind=rk), | intent(in) | :: | eta | |||
| integer(kind=ik), | intent(in) | :: | num_epochs | |||
| integer(kind=ik), | intent(in) | :: | batch_size |
Trains a network using a single set of input data x and output data y, and learning rate eta.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(network_type), | intent(inout) | :: | self | |||
| real(kind=rk), | intent(in) | :: | x(:) | |||
| real(kind=rk), | intent(in) | :: | y(:) | |||
| real(kind=rk), | intent(in) | :: | eta |
Updates network weights and biases with gradients dw and db, scaled by learning rate eta. update biases update weights
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(network_type), | intent(inout) | :: | self | |||
| class(array2d), | intent(in) | :: | dw(:) | |||
| class(array1d), | intent(in) | :: | db(:) | |||
| real(kind=rk), | intent(in) | :: | eta |