mindspore.ops.DropoutGenMask

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

Generates the mask value for the input shape.

Droupt means tha neural network units are temporarily dropped from the network according to a certain probability during the deep learning network training. Generally, The effect of Dropout is the same as that of DropoutGenMask and DropoutDoMask. The DropoutGenMask generates a mask shape that is specified based on the input. Next, The DropoutDoMask is a mask generated using DropoutGenMask. The input tensor is randomly set to zero based on the probability p.

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 Inputs 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,)