Learn R Programming

LBBNN (version 0.1.2)

get_local_explanations_gradient: Function to get gradient based local explanations for input-skip LBBNNs.

Description

Works by computing the gradient wrt to input, given we have relu activation functions.

Usage

get_local_explanations_gradient(
  model,
  input_data,
  num_samples = 1,
  magnitude = TRUE,
  include_potential_contribution = FALSE,
  device = "cpu"
)

Value

A list with the following elements:

explanations

A torch::tensor of shape (num_samples, p, num_classes).

p

integer, the number of input features.

predictions

A torch::tensor of shape (num_samples, num_classes).

Arguments

model

A LBBNN_Net with input-skip

input_data

The data to be explained (one sample).

num_samples

integer, how many samples to use to produce credible intervals.

magnitude

If TRUE, only return explanations. If FALSE, multiply by input values.

include_potential_contribution

IF TRUE, If covariate=0, we assume that the contribution is negative (good/bad that it is not included) if FALSE, just removes zero covariates.

device

character, the device to be trained on. Default is 'cpu', can be 'mps' or 'gpu'.