mindspore.ops.DropoutGenMask

class mindspore.ops.DropoutGenMask(*args, **kwargs)[source]

Generates the mask value for the input shape.

Parameters
  • Seed0 (int) – Seed0 value for random generating. Default: 0.

  • Seed1 (int) – Seed1 value for random generating. Default: 0.

Inputs:
  • shape (tuple[int]) - The shape of target mask.

  • keep_prob (Tensor) - The keep rate, greater than 0 and less equal than 1, e.g. keep_prob = 0.9, means dropping out 10% of input units.

Outputs:

Tensor, the value of generated mask for input shape.

Raises
  • TypeError – If neither seed0 nor seed1 is an int.

  • TypeError – If shape is not a tuple.

  • TypeError – If keep_prob is not a Tensor.

Supported Platforms:

Ascend

Examples

>>> dropout_gen_mask = ops.DropoutGenMask()
>>> shape = (2, 4, 5)
>>> keep_prob = Tensor(0.5, mindspore.float32)
>>> output = dropout_gen_mask(shape, keep_prob)
>>> print(output.shape)
(16,)