View source: R/approach_vaeac_torch_modules.R
specified_prob_mask_generator | R Documentation |
torch::nn_module()
Representing a specified_prob_mask_generatorA mask generator which masks the entries based on specified probabilities.
specified_prob_mask_generator(masking_probs, paired_sampling = FALSE)
masking_probs |
An M+1 numerics containing the probabilities masking 'd' of the (0,...M) entries for each observation. |
paired_sampling |
Boolean. If we are doing paired sampling. So include both S and |
A class that takes in the probabilities of having d masked observations. I.e., for M dimensional data, masking_probs is of length M+1, where the d'th entry is the probability of having d-1 masked values.
A mask generator that first samples the number of entries 'd' to be masked in the 'M'-dimensional observation 'x' in the batch based on the given M+1 probabilities. The 'd' masked are uniformly sampled from the 'M' possible feature indices. The d'th entry of the probability of having d-1 masked values.
Note that mcar_mask_generator with p = 0.5 is the same as using specified_prob_mask_generator()
with
masking_ratio
= choose(M, 0:M), where M is the number of features. This function was initially created to check if
increasing the probability of having a masks with many masked features improved vaeac's performance by focusing more
on these situations during training.
## Not run:
probs <- c(1, 8, 6, 3, 2)
mask_gen <- specified_prob_mask_generator(probs)
masks <- mask_gen(torch::torch_randn(c(10000, length(probs)) - 1))
empirical_prob <- table(as.array(masks$sum(2)))
empirical_prob / sum(empirical_prob)
probs / sum(probs)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.