Module for the FTorch torch_model type and associated procedures.
Type for holding a torch neural net (nn.Module).
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| type(c_ptr), | public | :: | p | = | c_null_ptr |
pointer to the neural net in memory |
| final :: torch_model_delete |
| procedure, public :: is_training => torch_model_is_training | |
| procedure, public :: print_parameters => torch_model_print_parameters |
Determines whether a model is set up for training
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(torch_model), | intent(in) | :: | self |
Model to query |
Whether the model is set up for training
Deallocates a TorchScript model
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(torch_model), | intent(inout) | :: | model |
Torch Model to deallocate |
Performs a forward pass of the model with the input tensors
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(torch_model), | intent(in) | :: | model |
Model |
||
| type(torch_tensor), | intent(in), | dimension(:) | :: | input_tensors |
Array of Input tensors |
|
| type(torch_tensor), | intent(in), | dimension(:) | :: | output_tensors |
Returned output tensors |
|
| logical, | intent(in), | optional | :: | requires_grad |
Whether gradients need to be computed for the created tensor |
Loads a TorchScript nn.module (pre-trained PyTorch model saved with TorchScript)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(torch_model), | intent(out) | :: | model |
Returned deserialized model |
||
| character(len=*), | intent(in) | :: | filename |
Filename of saved TorchScript model |
||
| integer(kind=c_int), | intent(in) | :: | device_type |
Device type the tensor will live on ( |
||
| integer(kind=c_int), | intent(in), | optional | :: | device_index |
Device index for GPU devices |
|
| logical, | intent(in), | optional | :: | requires_grad |
Whether gradients need to be computed for the created tensor |
|
| logical, | intent(in), | optional | :: | is_training |
Whether the model is being trained, rather than evaluated |
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.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(torch_model), | intent(in) | :: | self |
Model to print the parameters of |