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

Method set_value

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

Set all elements of the tensor to be the give value. Args: x (float): a float value to be set to all elements. inplace: inplace flag Returns: this tensor

(self, x, inplace=True)

Source from the content-addressed store, hash-verified

310 return self.data.L1()
311
312 def set_value(self, x, inplace=True):
313 '''Set all elements of the tensor to be the give value.
314
315 Args:
316 x (float): a float value to be set to all elements.
317 inplace: inplace flag
318
319 Returns:
320 this tensor
321 '''
322 # assert type(x) == float, 'set value only accepts float input'
323 # if isinstance(x, float):
324 if not inplace:
325 # return new tensor filled with value
326 raise NotImplementedError
327
328 self.data.SetFloatValue(float(x))
329 return self
330
331 def copy_from_numpy(self, np_array, offset=0):
332 ''' Copy the data from the numpy array.

Callers 15

__radd__Method · 0.95
__rsub__Method · 0.95
__rmul__Method · 0.95
__rdiv__Method · 0.95
__rtruediv__Method · 0.95
zeros_likeFunction · 0.95
ones_likeFunction · 0.95
sumFunction · 0.95
zerosFunction · 0.95
onesFunction · 0.95
trainMethod · 0.95
trainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected