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

Method set_value

python/singa/tensor.py:341–358  ·  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

339 return self.data.L1()
340
341 def set_value(self, x, inplace=True):
342 '''Set all elements of the tensor to be the give value.
343
344 Args:
345 x (float): a float value to be set to all elements.
346 inplace: inplace flag
347
348 Returns:
349 this tensor
350 '''
351 # assert type(x) == float, 'set value only accepts float input'
352 # if isinstance(x, float):
353 if not inplace:
354 # return new tensor filled with value
355 raise NotImplementedError
356
357 self.data.SetFloatValue(float(x))
358 return self
359
360 def copy_from_numpy(self, np_array, offset=0):
361 ''' Copy the data from the numpy array.

Callers 15

callMethod · 0.95
callMethod · 0.95
initializeMethod · 0.95
initializeMethod · 0.95
__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

Calls

no outgoing calls

Tested by 15

test_raddMethod · 0.76
test_rsubMethod · 0.76
test_rmulMethod · 0.76
test_rdivMethod · 0.76
test_sgd_const_lrMethod · 0.36
test_RMSProp_const_lrMethod · 0.36
test_AdaGrad_const_lrMethod · 0.36
test_Adam_const_lrMethod · 0.36