torch_model Derived Type

type, public :: torch_model

Type for holding a torch neural net (nn.Module).


Inherits

type~~torch_model~~InheritsGraph type~torch_model torch_model c_ptr c_ptr type~torch_model->c_ptr p

Components

Type Visibility Attributes Name Initial
type(c_ptr), public :: p = c_null_ptr

pointer to the neural net in memory


Finalization Procedures

final :: torch_model_delete

  • public subroutine torch_model_delete(model)

    Deallocates a TorchScript model

    Arguments

    Type IntentOptional Attributes Name
    type(torch_model), intent(inout) :: model

    Torch Model to deallocate


Type-Bound Procedures

procedure, public :: is_training => torch_model_is_training

  • public function torch_model_is_training(self) result(is_training)

    Determines whether a model is set up for training

    Arguments

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

    Model to query

    Return Value logical

    Whether the model is set up for training

procedure, public :: print_parameters => torch_model_print_parameters

  • public subroutine torch_model_print_parameters(self)

    Prints the parameters associated with a model NOTE: While viewing parameters in this way can be helpful for small toy models, it will produce large amounts of output for models with many, large, or high-dimensional parameters. In particular, tensors of 3 or more dimensions will be represented in terms of 2D arrays.

    Arguments

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

    Model to print the parameters of

Source Code

  type torch_model
    type(c_ptr) :: p = c_null_ptr  !! pointer to the neural net in memory
  contains
    procedure :: print_parameters => torch_model_print_parameters
    procedure :: is_training => torch_model_is_training
    final :: torch_model_delete
  end type torch_model