MCPcopy Create free account
hub / github.com/apache/singa / forward

Method forward

python/singa/autograd.py:3956–3972  ·  view source on GitHub ↗

forward of Dropout Args: x (CTensor): input tensor. Returns: the output CTensor.

(self, x)

Source from the content-addressed store, hash-verified

3954 self.init_seed = False
3955
3956 def forward(self, x):
3957 """
3958 forward of Dropout
3959 Args:
3960 x (CTensor): input tensor.
3961 Returns:
3962 the output CTensor.
3963 """
3964 if not self.init_seed:
3965 x.device().SetRandSeed(self.seed)
3966 self.init_seed = True
3967 if training:
3968 self.scale = 1 / 1 - self.ratio
3969 self.mask = singa.Tensor(list(x.shape()), x.device())
3970 singa.Bernoulli(1 - self.ratio, self.mask)
3971 x = singa.MultFloat(singa.__mul__(self.mask, x), self.scale)
3972 return x
3973
3974 def backward(self, dy):
3975 """

Callers

nothing calls this directly

Calls 5

deviceMethod · 0.80
TensorMethod · 0.80
shapeMethod · 0.80
SetRandSeedMethod · 0.45
__mul__Method · 0.45

Tested by

no test coverage detected