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

Method forward

python/singa/autograd.py:1222–1234  ·  view source on GitHub ↗

Args: x (CTensor): 1d or 2d tensor, the prediction data(output) of current network. t (CTensor): 1d or 2d tensor, the target data for training. Returns: loss (CTensor): scalar.

(self, x)

Source from the content-addressed store, hash-verified

1220 """
1221
1222 def forward(self, x):
1223 """
1224 Args:
1225 x (CTensor): 1d or 2d tensor, the prediction data(output)
1226 of current network.
1227 t (CTensor): 1d or 2d tensor, the target data for training.
1228 Returns:
1229 loss (CTensor): scalar.
1230 """
1231 loss = singa.SumAll(singa.__mul__(self.t, singa.Log(x)))
1232 loss /= -x.shape()[0]
1233 self.x = x
1234 return loss
1235
1236 def backward(self, dy=1.0):
1237 """

Callers

nothing calls this directly

Calls 2

shapeMethod · 0.80
__mul__Method · 0.45

Tested by

no test coverage detected