MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / numpy

Method numpy

tensorflow/python/framework/ops.py:918–934  ·  view source on GitHub ↗

Returns a numpy array or a scalar with the same contents as the Tensor. TODO(ashankar,agarwal): Perhaps this should NOT reference the underlying buffer but instead always explicitly copy? Note that currently it may or may not copy based on whether the numpy data is properly aligned or n

(self)

Source from the content-addressed store, hash-verified

916 return dtypes._INTERN_TABLE[self._datatype_enum()] # pylint: disable=protected-access
917
918 def numpy(self):
919 """Returns a numpy array or a scalar with the same contents as the Tensor.
920
921 TODO(ashankar,agarwal): Perhaps this should NOT reference the underlying
922 buffer but instead always explicitly copy? Note that currently it may or may
923 not copy based on whether the numpy data is properly aligned or not.
924
925 Returns:
926 A numpy array or a scalar. Numpy array may share memory with the
927 Tensor object. Any changes to one may be reflected in the other. A scalar
928 value is returned when self has rank 0.
929
930 Raises:
931 ValueError: if the type of this Tensor is not representable in numpy.
932 """
933 maybe_arr = self._numpy() # pylint: disable=protected-access
934 return maybe_arr.copy() if isinstance(maybe_arr, np.ndarray) else maybe_arr
935
936 @property
937 def backing_device(self):

Callers 15

testBasicsMethod · 0.45
testSaveByDictMethod · 0.45
testRestoreOnCreateMethod · 0.45
testMeanMethod · 0.45
testInitVariablesMethod · 0.45
testWeightedMeanMethod · 0.45
testMeanDtypeMethod · 0.45
testAccuracyMethod · 0.45

Calls 2

_numpyMethod · 0.95
copyMethod · 0.45

Tested by 15

testBasicsMethod · 0.36
testSaveByDictMethod · 0.36
testRestoreOnCreateMethod · 0.36
testMeanMethod · 0.36
testInitVariablesMethod · 0.36
testWeightedMeanMethod · 0.36
testMeanDtypeMethod · 0.36
testAccuracyMethod · 0.36