This class stores all layers converted to torch in a module which can be used like the original model (but torch-based). In addition, it provides other functions that are useful for interpreting individual predictions or explaining the entire model. This model is part of the class Converter and is the core for all the necessary calculations in the methods provided in this package.
ConvertedModel(modules_list, dtype = "float")
A list of all accepted layers created by the 'Converter' class during initialization.
The data type for all the calculations and defined tensors. Use
either 'float'
for torch::torch_float or 'double'
for
torch::torch_double.
modules_list
A list of all accepted layers created by the 'Converter' class during initialization.
dtype
The datatype for all the calculations and defined
tensors. Either 'float'
for torch::torch_float or 'double'
for
torch::torch_double
The forward method of the whole model, i.e. it calculates the output
\(y=f(x)\) of a given input \(x\). In doing so, all intermediate
values are stored in the individual torch modules from modules_list
.
self(x, channels_first = TRUE)
x
The input torch tensor of dimensions (batch_size, dim_in).
channels_first
If the input tensor x
is given in the format
'channels first' use TRUE
. Otherwise, if the channels are last,
use FALSE
and the input will be transformed into the format 'channels
first'. Default: TRUE
.
Returns the output of the model with respect to the given inputs with dimensions (batch_size, dim_out).
This method updates the stored intermediate values in each module from the
list modules_list
when the reference input x_ref
has changed.
self$update_ref(x_ref, channels_first = TRUE)
x_ref
Reference input of the model of dimensions (1, dim_in).
channels_first
If the reference input tensor x
is given in
the format 'channels first' use TRUE
. Otherwise, if the channels are
last, use FALSE
and the input will be transformed into the format
'channels first'. Default: TRUE
.
Returns the output of the reference input with dimension (1, dim_out) after passing through the model.
This method changes the data type for all the layers in modules_list
.
Use either 'float'
for torch::torch_float or 'double'
for
torch::torch_double.
self$set_dtype(dtype)
dtype
The data type for all the calculations and defined tensors.