def backward(self, x, gy): # Unpack 1-length tuples gy, = gy # Gradient is - x^-T (dx) x^-T ret = matmul._matmul(-self.invx, gy, transa=True) ret2 = matmul._matmul(ret, self.invx, transb=True) return ret2,
def backward(self, x, gy): a, = x ga = _matmul(gy[0], self.b, transb=not self.transb, transout=self.transa).reshape(a.shape) return ga,
def backward(self, x, gy): if gy[0].ndim == 0: gx1 = gy[0] * self.value else: gx1 = _matmul._matmul( self.value, gy[0], transa=True, transout=False ).reshape(self._x_shape) return gx1,
def backward_cpu(self, x, gy): a, = x b = self.b ga = numpy.empty_like(a) a0shape = a[0].shape for i in six.moves.range(len(a)): ga[i] = _matmul( gy[0][i], b[i], transb=not self.transb, transout=self.transa).reshape(a0shape) return ga,
def forward_cpu(self, x): a, = x b = self.b batch_size = a.shape[0] shape = self._output_shape(a, b) ret_dtype = numpy.find_common_type([a.dtype, b.dtype], []) ret = numpy.empty(shape, dtype=ret_dtype) for i in six.moves.range(batch_size): ret[i] = _matmul( a[i], b[i], transa=self.transa, transb=self.transb) return ret,
def forward(self, x): return _matmul._matmul(x[0], self.value),
def forward(self, x): self.retain_inputs(()) self._x_shape = x[0].shape return utils.force_array(_matmul._matmul(self.value, x[0])),
def forward(self, x): self.retain_inputs(()) self._x_shape = x[0].shape return _matmul._matmul(self.value, x[0]),
def forward(self, x): a, = x return _matmul(a, self.b, transa=self.transa, transb=self.transb),
def backward(self, x, gy): gx0 = _matmul._matmul(gy[0], self.value, transb=True, transout=False).reshape(x[0].shape) return (gx0,)
def backward(self, x, gy): gx1 = _matmul._matmul( self.value, gy[0], transa=True, transout=False ).reshape(x[0].shape) return gx1,
def forward(self, x): return _matmul._matmul(self.value, x[0]),
def backward(self, x, gy): gx0 = _matmul._matmul(gy[0], self.value, transb=True, transout=False).reshape(self._x_shape) return gx0,
def forward(self, x): self.retain_inputs((0, )) return utils.force_array(_matmul._matmul(self.value, x[0])),
def forward(self, x): self.retain_inputs((0,)) return utils.force_array(_matmul._matmul(self.value, x[0])),
def backward(self, x, gy): gx0 = _matmul( gy[0], self.b, transb=not self.transb, transout=self.transa ).reshape(x[0].shape) return gx0,