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

Method reshape

examples/model_selection/Trails/singa_pkg_code/tensor.py:231–247  ·  view source on GitHub ↗

Return a new tensor with the given shape, and the original tensor is not changed. Args: shape (list ): new shape, which should have the same volumn as the original shape. Returns: new tensor reshaped

(self, shape)

Source from the content-addressed store, hash-verified

229 return t
230
231 def reshape(self, shape):
232 '''Return a new tensor with the given shape, and the original
233 tensor is not changed.
234
235 Args:
236 shape (list<int>): new shape, which should have the same
237 volumn as the original shape.
238
239 Returns:
240 new tensor reshaped
241 ''&#x27;
242 t = Tensor(self.shape, self.device, self.dtype)
243 assert product(self.shape) == product(shape), \
244 'product of shape should be equal'
245 t.shape = shape
246 t.data = singa.Reshape(self.data, shape)
247 return t
248
249 def reset_like(self, t):
250 ''&#x27;Reset the shape, dtype and device as the given tensor.

Callers 15

to_numpyFunction · 0.45
einsumFunction · 0.45
tensordotFunction · 0.45
updateMethod · 0.45
runFunction · 0.45
runFunction · 0.45
load_datasetFunction · 0.45
load_datasetFunction · 0.45
read_label_fileFunction · 0.45
read_image_fileFunction · 0.45
read_label_fileFunction · 0.45

Calls 2

TensorClass · 0.70
productFunction · 0.70

Tested by

no test coverage detected