neural_network_m Module

Define an abstraction that supports inference operations on a neural network


Uses

  • module~~neural_network_m~~UsesGraph module~neural_network_m neural_network_m julienne_m julienne_m module~neural_network_m->julienne_m module~activation_m activation_m module~neural_network_m->module~activation_m module~double_precision_file_m double_precision_file_m module~neural_network_m->module~double_precision_file_m module~kind_parameters_m kind_parameters_m module~neural_network_m->module~kind_parameters_m module~metadata_m metadata_m module~neural_network_m->module~metadata_m module~mini_batch_m mini_batch_m module~neural_network_m->module~mini_batch_m module~tensor_m tensor_m module~neural_network_m->module~tensor_m module~tensor_map_m tensor_map_m module~neural_network_m->module~tensor_map_m module~activation_m->julienne_m iso_c_binding iso_c_binding module~activation_m->iso_c_binding module~double_precision_file_m->julienne_m module~double_precision_string_m double_precision_string_m module~double_precision_file_m->module~double_precision_string_m julienne_string_m julienne_string_m module~metadata_m->julienne_string_m module~metadata_m->module~double_precision_string_m module~mini_batch_m->module~kind_parameters_m module~input_output_pair_m input_output_pair_m module~mini_batch_m->module~input_output_pair_m module~tensor_m->module~kind_parameters_m module~tensor_map_m->julienne_m module~tensor_map_m->module~kind_parameters_m module~tensor_map_m->module~tensor_m module~tensor_map_m->module~double_precision_string_m module~double_precision_string_m->julienne_m module~input_output_pair_m->module~kind_parameters_m module~input_output_pair_m->module~tensor_m

Used by

  • module~~neural_network_m~~UsedByGraph module~neural_network_m neural_network_m module~fiats_m fiats_m module~fiats_m->module~neural_network_m module~trainable_network_m trainable_network_m module~fiats_m->module~trainable_network_m module~layer_m layer_m module~layer_m->module~neural_network_m module~neural_network_s neural_network_s module~neural_network_s->module~neural_network_m module~neural_network_s->module~layer_m module~trainable_network_m->module~neural_network_m module~unmapped_network_s unmapped_network_s module~unmapped_network_s->module~neural_network_m module~workspace_s workspace_s module~workspace_s->module~neural_network_m module~addition_m addition_m module~addition_m->module~fiats_m module~exponentiation_m exponentiation_m module~exponentiation_m->module~fiats_m module~layer_s layer_s module~layer_s->module~layer_m module~multiply_inputs multiply_inputs module~multiply_inputs->module~fiats_m module~power_series power_series module~power_series->module~fiats_m module~saturated_mixing_ratio_m saturated_mixing_ratio_m module~saturated_mixing_ratio_m->module~fiats_m module~trainable_network_s trainable_network_s module~trainable_network_s->module~trainable_network_m program~concurrent_inferences concurrent_inferences program~concurrent_inferences->module~fiats_m program~learn_addition learn_addition program~learn_addition->module~fiats_m program~learn_addition->module~addition_m program~learn_exponentiation learn_exponentiation program~learn_exponentiation->module~fiats_m program~learn_exponentiation->module~exponentiation_m program~learn_multiplication learn_multiplication program~learn_multiplication->module~fiats_m program~learn_multiplication->module~multiply_inputs program~learn_power_series learn_power_series program~learn_power_series->module~fiats_m program~learn_power_series->module~power_series program~print_training_configuration print_training_configuration program~print_training_configuration->module~fiats_m program~read_query_infer read_query_infer program~read_query_infer->module~fiats_m program~train_and_write train_and_write program~train_and_write->module~fiats_m program~train_saturated_mixture_ratio train_saturated_mixture_ratio program~train_saturated_mixture_ratio->module~fiats_m program~train_saturated_mixture_ratio->module~saturated_mixing_ratio_m program~write_read_infer write_read_infer program~write_read_infer->module~fiats_m

Interfaces

public interface assert_consistency

  • private pure module subroutine default_real_consistency(self)

    Arguments

    Type IntentOptional Attributes Name
    class(neural_network_t), intent(in) :: self
  • private pure module subroutine double_precision_consistency(self)

    Arguments

    Type IntentOptional Attributes Name
    class(neural_network_t(double_precision)), intent(in) :: self

public interface neural_network_t

  • private module function default_real_construct_from_components(metadata, weights, biases, nodes, input_map, output_map) result(neural_network)

    Arguments

    Type IntentOptional Attributes Name
    type(string_t), intent(in) :: metadata(:)
    real, intent(in) :: weights(:,:,:)
    real, intent(in) :: biases(:,:)
    integer, intent(in) :: nodes(0:)
    type(tensor_map_t), intent(in), optional :: input_map
    type(tensor_map_t), intent(in), optional :: output_map

    Return Value type(neural_network_t)

  • private impure elemental module function default_real_from_json(file_) result(neural_network)

    Arguments

    Type IntentOptional Attributes Name
    type(file_t), intent(in) :: file_

    Return Value type(neural_network_t)

  • private module function double_precision_construct_from_components(metadata, weights, biases, nodes, input_map, output_map) result(neural_network)

    Arguments

    Type IntentOptional Attributes Name
    type(metadata_t), intent(in) :: metadata
    double precision, intent(in) :: weights(:,:,:)
    double precision, intent(in) :: biases(:,:)
    integer, intent(in) :: nodes(0:)
    type(tensor_map_t(double_precision)), intent(in), optional :: input_map
    type(tensor_map_t(double_precision)), intent(in), optional :: output_map

    Return Value type(neural_network_t(double_precision))

  • private impure elemental module function double_precision_from_json(file) result(neural_network)

    Arguments

    Type IntentOptional Attributes Name
    type(double_precision_file_t), intent(in) :: file

    Return Value type(neural_network_t(double_precision))

public interface unmapped_network_t

public interface workspace_t

  • private pure module function default_real_workspace(neural_network) result(workspace)

    Arguments

    Type IntentOptional Attributes Name
    type(neural_network_t), intent(in) :: neural_network

    Return Value type(workspace_t)

interface

  • private elemental module function default_real_activation_name(self) result(activation_name)

    Arguments

    Type IntentOptional Attributes Name
    class(neural_network_t), intent(in) :: self

    Return Value type(string_t)

interface

  • private module subroutine default_real_allocate(self, neural_network)

    Arguments

    Type IntentOptional Attributes Name
    class(workspace_t), intent(inout) :: self
    type(neural_network_t), intent(in) :: neural_network

interface

  • private pure module function default_real_allocated(self) result(all_allocated)

    Arguments

    Type IntentOptional Attributes Name
    class(workspace_t), intent(in) :: self

    Return Value logical

interface

  • private elemental module function default_real_approximately_equal(lhs, rhs) result(lhs_eq_rhs)

    The result is true if lhs and rhs are the same to within a tolerance

    Arguments

    Type IntentOptional Attributes Name
    class(neural_network_t), intent(in) :: lhs
    class(neural_network_t), intent(in) :: rhs

    Return Value logical

interface

  • private elemental module function default_real_infer(self, inputs) result(outputs)

    Arguments

    Type IntentOptional Attributes Name
    class(neural_network_t), intent(in) :: self
    type(tensor_t), intent(in) :: inputs

    Return Value type(tensor_t)

interface

  • private elemental module function default_real_infer_unmapped(self, inputs) result(outputs)

    Arguments

    Type IntentOptional Attributes Name
    class(unmapped_network_t), intent(in) :: self
    type(tensor_t), intent(in) :: inputs

    Return Value type(tensor_t)

interface

  • private pure module subroutine default_real_learn(self, mini_batches_arr, cost, adam, learning_rate, workspace)

    Arguments

    Type IntentOptional Attributes Name
    class(neural_network_t), intent(inout) :: self
    type(mini_batch_t), intent(in) :: mini_batches_arr(:)
    real, intent(out), optional, allocatable :: cost(:)
    logical, intent(in) :: adam
    real, intent(in) :: learning_rate
    type(workspace_t), intent(inout) :: workspace

interface

  • private elemental module function default_real_map_from_output_range(self, normalized_tensor) result(tensor)

    The result contains the output tensor values unmapped via the inverse of the mapping used in training

    Arguments

    Type IntentOptional Attributes Name
    class(neural_network_t), intent(in) :: self
    type(tensor_t), intent(in) :: normalized_tensor

    Return Value type(tensor_t)

interface

  • private elemental module function default_real_map_to_input_range(self, tensor) result(normalized_tensor)

    The result contains the input tensor values normalized to fall on the range used during training

    Arguments

    Type IntentOptional Attributes Name
    class(neural_network_t), intent(in) :: self
    type(tensor_t), intent(in) :: tensor

    Return Value type(tensor_t)

interface

  • private pure module function default_real_nodes_per_layer(self) result(node_count)

    Arguments

    Type IntentOptional Attributes Name
    class(neural_network_t), intent(in) :: self

    Return Value integer, allocatable, (:)

interface

  • private elemental module function default_real_num_hidden_layers(self) result(hidden_layer_count)

    Arguments

    Type IntentOptional Attributes Name
    class(neural_network_t), intent(in) :: self

    Return Value integer

interface

  • private elemental module function default_real_num_inputs(self) result(input_count)

    Arguments

    Type IntentOptional Attributes Name
    class(neural_network_t), intent(in) :: self

    Return Value integer

interface

  • private elemental module function default_real_num_outputs(self) result(output_count)

    Arguments

    Type IntentOptional Attributes Name
    class(neural_network_t), intent(in) :: self

    Return Value integer

interface

  • private pure module function default_real_skip(self) result(use_skip_connections)

    Arguments

    Type IntentOptional Attributes Name
    class(neural_network_t), intent(in) :: self

    Return Value logical

interface

  • private impure elemental module function default_real_to_json(self) result(json_file)

    Arguments

    Type IntentOptional Attributes Name
    class(neural_network_t), intent(in) :: self

    Return Value type(file_t)

interface

  • private elemental module function double_precision_activation_name(self) result(activation_name)

    Arguments

    Type IntentOptional Attributes Name
    class(neural_network_t(double_precision)), intent(in) :: self

    Return Value type(string_t)

interface

  • private elemental module function double_precision_approximately_equal(lhs, rhs) result(lhs_eq_rhs)

    The result is true if lhs and rhs are the same to within a tolerance

    Arguments

    Type IntentOptional Attributes Name
    class(neural_network_t(double_precision)), intent(in) :: lhs
    class(neural_network_t(double_precision)), intent(in) :: rhs

    Return Value logical

interface

  • private elemental module function double_precision_infer(self, inputs) result(outputs)

    Arguments

    Type IntentOptional Attributes Name
    class(neural_network_t(double_precision)), intent(in) :: self
    type(tensor_t(double_precision)), intent(in) :: inputs

    Return Value type(tensor_t(double_precision))

interface

  • private elemental module function double_precision_infer_unmapped(self, inputs) result(outputs)

    Arguments

    Type IntentOptional Attributes Name
    class(unmapped_network_t(double_precision)), intent(in) :: self
    type(tensor_t(double_precision)), intent(in) :: inputs

    Return Value type(tensor_t(double_precision))

interface

  • private elemental module function double_precision_map_from_output_range(self, normalized_tensor) result(tensor)

    The result contains the output tensor values unmapped via the inverse of the mapping used in training

    Arguments

    Type IntentOptional Attributes Name
    class(neural_network_t(double_precision)), intent(in) :: self
    type(tensor_t(double_precision)), intent(in) :: normalized_tensor

    Return Value type(tensor_t(double_precision))

interface

  • private elemental module function double_precision_map_to_input_range(self, tensor) result(normalized_tensor)

    The result contains the input tensor values normalized to fall on the range used during training

    Arguments

    Type IntentOptional Attributes Name
    class(neural_network_t(double_precision)), intent(in) :: self
    type(tensor_t(double_precision)), intent(in) :: tensor

    Return Value type(tensor_t(double_precision))

interface

  • private pure module function double_precision_nodes_per_layer(self) result(node_count)

    Arguments

    Type IntentOptional Attributes Name
    class(neural_network_t(double_precision)), intent(in) :: self

    Return Value integer, allocatable, (:)

interface

  • private elemental module function double_precision_num_hidden_layers(self) result(hidden_layer_count)

    Arguments

    Type IntentOptional Attributes Name
    class(neural_network_t(double_precision)), intent(in) :: self

    Return Value integer

interface

  • private elemental module function double_precision_num_inputs(self) result(input_count)

    Arguments

    Type IntentOptional Attributes Name
    class(neural_network_t(double_precision)), intent(in) :: self

    Return Value integer

interface

  • private elemental module function double_precision_num_outputs(self) result(output_count)

    Arguments

    Type IntentOptional Attributes Name
    class(neural_network_t(double_precision)), intent(in) :: self

    Return Value integer

interface

  • private pure module function double_precision_skip(self) result(use_skip_connections)

    Arguments

    Type IntentOptional Attributes Name
    class(neural_network_t(double_precision)), intent(in) :: self

    Return Value logical

interface

  • private impure elemental module function double_precision_to_json(self) result(json_file)

    Arguments

    Type IntentOptional Attributes Name
    class(neural_network_t(double_precision)), intent(in) :: self

    Return Value type(file_t)


Derived Types

type, public ::  neural_network_t

Encapsulate the information needed to perform inference

Components

Type Visibility Attributes Name Initial
integer, public, kind :: k = default_real
type(activation_t), private :: activation_
real(kind=k), private, allocatable :: biases_(:,:)
type(tensor_map_t(k)), private :: input_map_
type(metadata_t), private :: metadata_
integer, private, allocatable :: nodes_(:)
type(tensor_map_t(k)), private :: output_map_
real(kind=k), private, allocatable :: weights_(:,:,:)

Constructor

private module function default_real_construct_from_components (metadata, weights, biases, nodes, input_map, output_map)
private impure, elemental, module function default_real_from_json (file_)
private module function double_precision_construct_from_components (metadata, weights, biases, nodes, input_map, output_map)
private impure, elemental, module function double_precision_from_json (file)

Type-Bound Procedures

generic, public :: activation_function_name => default_real_activation_name, double_precision_activation_name
generic, public :: infer => default_real_infer, double_precision_infer
generic, public :: map_from_output_range => default_real_map_from_output_range, double_precision_map_from_output_range
generic, public :: map_to_input_range => default_real_map_to_input_range, double_precision_map_to_input_range
generic, public :: nodes_per_layer => default_real_nodes_per_layer, double_precision_nodes_per_layer
generic, public :: num_hidden_layers => default_real_num_hidden_layers, double_precision_num_hidden_layers
generic, public :: num_inputs => default_real_num_inputs, double_precision_num_inputs
generic, public :: num_outputs => default_real_num_outputs, double_precision_num_outputs
generic, public :: operator(==) => default_real_approximately_equal, double_precision_approximately_equal
generic, public :: skip => default_real_skip, double_precision_skip
generic, public :: to_json => default_real_to_json, double_precision_to_json
procedure, private, non_overridable :: default_real_activation_name
procedure, private, non_overridable :: default_real_approximately_equal
procedure, private, non_overridable :: default_real_infer
procedure, private, non_overridable :: default_real_learn
procedure, private, non_overridable :: default_real_map_from_output_range
procedure, private, non_overridable :: default_real_map_to_input_range
procedure, private, non_overridable :: default_real_nodes_per_layer
procedure, private, non_overridable :: default_real_num_hidden_layers
procedure, private, non_overridable :: default_real_num_inputs
procedure, private, non_overridable :: default_real_num_outputs
procedure, private, non_overridable :: default_real_skip
procedure, private, non_overridable :: default_real_to_json
procedure, private, non_overridable :: double_precision_activation_name
procedure, private, non_overridable :: double_precision_approximately_equal
procedure, private, non_overridable :: double_precision_infer
procedure, private, non_overridable :: double_precision_map_from_output_range
procedure, private, non_overridable :: double_precision_map_to_input_range
procedure, private, non_overridable :: double_precision_nodes_per_layer
procedure, private, non_overridable :: double_precision_num_hidden_layers
procedure, private, non_overridable :: double_precision_num_inputs
procedure, private, non_overridable :: double_precision_num_outputs
procedure, private, non_overridable :: double_precision_skip
procedure, private, non_overridable :: double_precision_to_json
generic, private :: learn => default_real_learn

type, public ::  unmapped_network_t

Components

Type Visibility Attributes Name Initial
integer, public, kind :: k = default_real
type(neural_network_t(k)), private :: neural_network_

Constructor

private impure, elemental, module function double_precision_unmapped_from_json (file)

Type-Bound Procedures

generic, public :: infer => default_real_infer_unmapped, double_precision_infer_unmapped
procedure, private, non_overridable :: default_real_infer_unmapped
procedure, private, non_overridable :: double_precision_infer_unmapped

type, public ::  workspace_t

Components

Type Visibility Attributes Name Initial
real(kind=k), public, allocatable, dimension(:,:) :: a
real(kind=k), public, allocatable, dimension(:,:) :: dcdb
real(kind=k), public, allocatable, dimension(:,:,:) :: dcdw
real(kind=k), public, allocatable, dimension(:,:) :: delta
integer, public, kind :: k = default_real
real(kind=k), public, allocatable, dimension(:,:) :: sdb
real(kind=k), public, allocatable, dimension(:,:) :: sdbc
real(kind=k), public, allocatable, dimension(:,:,:) :: sdw
real(kind=k), public, allocatable, dimension(:,:,:) :: sdwc
real(kind=k), public, allocatable, dimension(:,:) :: vdb
real(kind=k), public, allocatable, dimension(:,:) :: vdbc
real(kind=k), public, allocatable, dimension(:,:,:) :: vdw
real(kind=k), public, allocatable, dimension(:,:,:) :: vdwc
real(kind=k), public, allocatable, dimension(:,:) :: z

Constructor

private pure, module function default_real_workspace (neural_network)

Type-Bound Procedures

generic, public :: allocate_if_necessary => default_real_allocate
generic, public :: fully_allocated => default_real_allocated
procedure, private, non_overridable :: default_real_allocate
procedure, private, non_overridable :: default_real_allocated