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)
| 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. |
no outgoing calls