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

Method forward

python/singa/autograd.py:748–766  ·  view source on GitHub ↗

Args: x (CTensor): matrix. Return: the result CTensor

(self, x)

Source from the content-addressed store, hash-verified

746 self.shape = shape
747
748 def forward(self, x):
749 """
750 Args:
751 x (CTensor): matrix.
752 Return:
753 the result CTensor
754 """
755 self._shape = x.shape()
756 shape = list(self.shape)
757 # handle the shape with 0
758 shape = [
759 self._shape[i]
760 if i < len(self._shape) and shape[i] == 0 else shape[i]
761 for i in range(len(shape))
762 ]
763 # handle the shape with -1
764 hidden_shape = int(np.prod(self._shape) // np.abs(np.prod(shape)))
765 self.cache = [int(s) if s != -1 else hidden_shape for s in shape]
766 return singa.Reshape(x, self.cache)
767
768 def backward(self, dy):
769 """

Callers

nothing calls this directly

Calls 1

shapeMethod · 0.80

Tested by

no test coverage detected