This is a super class for all data-based interpreting methods. Implemented are the following methods:
Deep Learning Important Features (DeepLift)
Layer-wise Relevance Propagation (LRP)
Gradient-based methods:
Vanilla gradients including 'Gradients x Input' (Gradient)
Smoothed gradients including 'SmoothGrad x Input' (SmoothGrad)
data
The passed data as a torch tensor in the given data type
(dtype
) to be interpreted with the selected method.
converter
An instance of the R6 class Converter
.
dtype
The data type for the calculations. Either 'float'
for torch::torch_float or 'double'
for torch::torch_double.
channels_first
The format of the given date, i.e. channels on
last dimension (FALSE
) or after the batch dimension (TRUE
). If the
data has no channels, the default value TRUE
is used.
ignore_last_act
A boolean value to include the last
activation into all the calculations, or not (default: TRUE
). In some
cases, the last activation leads to a saturation problem.
result
The methods result of the given data as a
torch tensor of size (batch_size, dim_in, dim_out) in the given data type
(dtype
).
output_idx
This vector determines for which outputs the method
will be applied. By default (NULL
), all outputs (but limited to the
first 10) are considered.
new()
Create a new instance of this super class.
InterpretingMethod$new( converter, data, channels_first = TRUE, output_idx = NULL, ignore_last_act = TRUE, dtype = "float" )
converter
An instance of the R6 class Converter
.
data
The data for which this method is to be applied. It has to be an array or array-like format of size (batch_size, dim_in).
channels_first
The format of the given data, i.e. channels on
last dimension (FALSE
) or after the batch dimension (TRUE
). If the
data has no channels, use the default value TRUE
.
output_idx
This vector determines for which output indices the
method will be applied. By default (NULL
), all outputs (but limited to
the first 10) are considered.
ignore_last_act
A boolean value to include the last
activation into all the calculations, or not (default: TRUE
). In
some cases, the last activation leads to a saturation problem.
dtype
dtype The data type for the calculations. Use
either 'float'
for torch::torch_float or 'double'
for
torch::torch_double.
get_result()
This function returns the result of this method for the given data
either as an array ('array'
), a torch tensor ('torch.tensor'
,
or 'torch_tensor'
) of size (batch_size, dim_in, dim_out) or as a
data.frame ('data.frame'
).
InterpretingMethod$get_result(type = "array")
type
The data type of the result. Use one of 'array'
,
'torch.tensor'
, 'torch_tensor'
or 'data.frame'
(default: 'array'
).
The result of this method for the given data in the chosen type.
clone()
The objects of this class are cloneable with this method.
InterpretingMethod$clone(deep = FALSE)
deep
Whether to make a deep clone.