MCPcopy Create free account
hub / github.com/geekcomputers/Python / forward

Method forward

ML/src/python/neuralforge/nn/modules.py:111–119  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

109 self.drop_prob = drop_prob
110
111 def forward(self, x):
112 if self.drop_prob == 0.0 or not self.training:
113 return x
114 keep_prob = 1 - self.drop_prob
115 shape = (x.shape[0],) + (1,) * (x.ndim - 1)
116 random_tensor = keep_prob + torch.rand(shape, dtype=x.dtype, device=x.device)
117 random_tensor.floor_()
118 output = x.div(keep_prob) * random_tensor
119 return output
120
121class GlobalAvgPool2d(nn.Module):
122 def __init__(self):

Callers

nothing calls this directly

Calls 1

divMethod · 0.80

Tested by

no test coverage detected