tf.experimental.numpy.ndarray

Equivalent of numpy.ndarray backed by TensorFlow tensors.

This does not support all features of NumPy ndarrays e.g. strides and memory order since, unlike NumPy, the backing storage is not a raw memory buffer.

or if there are any differences in behavior.

Args
shape The shape of the array. Must be a scalar, an iterable of integers or a TensorShape object.
dtype Optional. The dtype of the array. Must be a python type, a numpy type or a tensorflow DType object.
buffer Optional. The backing buffer of the array. Must have shape shape. Must be a ndarray, np.ndarray or a Tensor.
Raises
ValueError If buffer is specified and its shape does not match shape.
Attributes
T
data Tensor object containing the array data.

This has a few key differences from the Python buffer object used in NumPy arrays.

  1. Tensors are immutable. So operations requiring in-place edit, e.g. setitem, are performed by replacing the underlying buffer with a new one.
  2. Tensors do not provide access to their raw buffer.
dtype
ndim
shape Returns a tuple or tf.Tensor of array dimensions.
size Returns the number of elements in the array.

Methods

astype

View source

clip

View source

TensorFlow variant of NumPy's clip.

Unsupported arguments: out, kwargs.

See the NumPy documentation for numpy.clip.

from_tensor

View source

ravel

View source

TensorFlow variant of NumPy's ravel.

Unsupported arguments: order.

See the NumPy documentation for numpy.ravel.

reshape

View source

tolist

View source

transpose

View source

TensorFlow variant of NumPy's transpose.

See the NumPy documentation for numpy.transpose.

__abs__

View source

TensorFlow variant of NumPy's absolute.

Unsupported arguments: out, where, casting, order, dtype, subok, signature, extobj.

See the NumPy documentation for numpy.absolute.

__add__

View source

__bool__

View source

__eq__

View source

__floordiv__

View source

__ge__

View source

__getitem__

View source

Implementation of ndarray.getitem.

__gt__

View source

__invert__

View source

TensorFlow variant of NumPy's logical_not.

Unsupported arguments: out, where, casting, order, dtype, subok, signature, extobj.

See the NumPy documentation for numpy.logical_not.

__iter__

View source

__le__

View source

__len__

View source

__lt__

View source

__matmul__

View source

__mod__

View source

__mul__

View source

__ne__

View source

__neg__

View source

__nonzero__

View source

__pos__

View source

__pow__

View source

__radd__

View source

__rfloordiv__

View source

__rmatmul__

View source

__rmod__

View source

__rmul__

View source

__rpow__

View source

__rsub__

View source

__rtruediv__

View source

__sub__

View source

__truediv__

View source

© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r2.4/api_docs/python/tf/experimental/numpy/ndarray