Every line of 'torch reshape' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
417 def _reshape(input, shape, shape_like=None): 418 if shape_like is not None: shape = shape_like.shape 419 dev = MakeDevice(inputs=[input]); ndim = len(shape) 420 key = 'Reshape/{}/ndim:{}'.format(dev, ndim) 421 module = get_module(Reshape, key, dev, ndim=ndim) 422 return module.forward(input, shape)
Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code
409 def reshape(input): 410 return torch.reshape(input, (1, 1, *shape))
10 def reshape(self): 11 assert 0 <= self.axis < self.X.ndim 12 self.cshape = [1] * self.X.ndim 13 self.cshape[self.axis] = self.X.shape[self.axis] 14 self.valid_axes = tuple([i for i in range(self.X.ndim) if i != self.axis]) 15 16 self.Y = np.zeros(self.X.shape) 17 # (1, C, 1, 1) 18 self.W = np.ones(self.cshape) 19 # (1, C, 1, 1) 20 self.b = np.zeros(self.cshape) 21 # Current Mean 22 self.moving_mean = np.zeros(self.cshape) 23 self.moving_var = np.ones(self.cshape)
43 def forward(self, inputs): 44 x, = inputs 45 return x.reshape(self.shape),
272 def _reshape_from_tensor(g, input, shape): 273 return g.op('Reshape', input, shape)
69 def backward(self, grad): 70 return grad.reshape(self._x_shape)
271 def reshape(self, x: BKTensor, newshape: Any) \ 272 -> BKTensor: 273 return self.lib.reshape(x, newshape) # type: ignore
7 def reshape(self): 8 self.Y = np.dot(self.X[0], self.X[1])