tfmri.sampling.random_mask

random_mask(shape, density=1.0, seed=None, rng=None, name=None)[source]

Returns a random sampling mask with the given density.

Parameters
  • shape – A 1D integer Tensor or array. The shape of the output mask.

  • density – A Tensor. A density grid. After broadcasting with shape, each point in the grid represents the probability that a given point will be sampled. For example, if density is a scalar, then each point in the mask will be sampled with probability density. A non-scalar density may be used to create variable-density sampling masks. tfmri.sampling.density_grid can be used to create density grids.

  • seed – A Tensor of shape [2]. The seed for the stateless RNG. seed and rng may not be specified at the same time.

  • rng – A tf.random.Generator. The stateful RNG to use. seed and rng may not be specified at the same time. If neither seed nor rng are provided, the global RNG will be used.

  • name – A name for this op.

Returns

A boolean tensor containing the sampling mask.

Raises

ValueError – If both seed and rng are specified.