| ConvertedModel | R Documentation |
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, graph, input_nodes, output_nodes, dtype = "float")
modules_list |
( |
graph |
(
|
input_nodes |
( |
output_nodes |
( |
dtype |
( |
forward()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,
save_input = FALSE,
save_preactivation = FALSE,
save_output = FAlSE,
save_last_layer = FALSE)
xThe input torch tensor for this model.
channels_firstIf 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.
save_inputLogical value whether the inputs from each layer
are to be saved or not. Default: FALSE.
save_preactivationLogical value whether the preactivations
from each layer are to be saved or not. Default: FALSE.
save_outputLogical value whether the outputs from each layer
are to be saved or not. Default: FALSE.
save_last_layerLogical value whether the inputs,
preactivations and outputs from the last layer are to be saved or not.
Default: FALSE.
Returns a list of the output values of the model with respect to the given inputs.
update_ref()This method updates the intermediate values in each module from the
list modules_list for the reference input x_ref and returns the
output from it in the same way as in the forward method.
self$update_ref(x_ref,
channels_first = TRUE,
save_input = FALSE,
save_preactivation = FALSE,
save_output = FAlSE,
save_last_layer = FALSE)
x_refReference input of the model.
channels_firstIf the tensor x_ref 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.
save_inputLogical value whether the inputs from each layer
are to be saved or not. Default: FALSE.
save_preactivationLogical value whether the preactivations
from each layer are to be saved or not. Default: FALSE.
save_outputLogical value whether the outputs from each layer
are to be saved or not. Default: FALSE.
save_last_layerLogical value whether the inputs,
preactivations and outputs from the last layer are to be saved or not.
Default: FALSE.
Returns a list of the output values of the model with respect to the given reference input.
set_dtype()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)
dtypeThe data type for all the calculations and defined tensors.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.