View source: R/approach_vaeac_torch_modules.R
specified_masks_mask_generator | R Documentation |
torch::nn_module()
Representing a specified_masks_mask_generatorA mask generator which masks the entries based on sampling provided 1D masks with corresponding probabilities. Used for Shapley value estimation when only a subset of coalitions are used to compute the Shapley values.
specified_masks_mask_generator(masks, masks_probs, paired_sampling = FALSE)
masks |
Matrix/Tensor of possible/allowed 'masks' which we sample from. |
masks_probs |
Array of 'probabilities' for each of the masks specified in 'masks'. Note that they do not need to be between 0 and 1 (e.g. sampling frequency). They are scaled, hence, they only need to be positive. |
paired_sampling |
Boolean. If we are doing paired sampling. So include both S and |
Lars Henry Berge Olsen
## Not run:
masks <- torch_tensor(matrix(c(0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1),
nrow = 3, ncol = 4, byrow = TRUE
))
masks_probs <- c(3, 1, 6)
mask_gen <- specified_masks_mask_generator(masks = masks, masks_probs = masks_probs)
empirical_prob <-
table(as.array(mask_gen(torch::torch_randn(c(10000, ncol(masks))))$sum(-1)))
empirical_prob / sum(empirical_prob)
masks_probs / sum(masks_probs)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.