![]() ![]() Note: Although you may see reference to a "tensor of two dimensions", a rank-2 tensor does not usually describe a 2D space. Size: The total number of items in the tensor, the product of the shape vector's elements. ![]() Axis or Dimension: A particular dimension of a tensor.A scalar has rank 0, a vector has rank 1, a matrix is rank 2. Shape: The length (number of elements) of each of the axes of a tensor.Note: Typically, anywhere a TensorFlow function expects a Tensor as input, the function will also accept anything that can be converted to a Tensor using tf.convert_to_tensor. Tensors are used in all kinds of operations (or "Ops"). Print(a * b, "\n") # element-wise multiplication Print(a + b, "\n") # element-wise addition ]) # Could have also said `tf.ones(, dtype=tf.int32)` You can do basic math on tensors, including addition, element-wise multiplication, and matrix multiplication. Sparse tensors (see SparseTensor below).Ragged tensors (see RaggedTensor below).However, there are specialized types of tensors that can handle different shapes: The base tf.Tensor class requires tensors to be "rectangular"-that is, along each axis, every element is the same size. Tensors often contain floats and ints, but have many other types, including: You can convert a tensor to a NumPy array either using np.array or the tensor.numpy method: np.array(rank_2_tensor) There are many ways you might visualize a tensor with more than two axes. Tensors may have more axes here is a tensor with three axes: # There can be an arbitrary number of Tf.Tensor(, shape=(3,), dtype=float32)Ī "matrix" or "rank-2" tensor has two axes: # If you want to be specific, you can set the dtype (see below) at creation time A vector has one axis: # Let's make this a float tensor. # This will be an int32 tensor by default see "dtypes" below.Ī "vector" or "rank-1" tensor is like a list of values. A scalar contains a single value, and no "axes". If you're familiar with NumPy, tensors are (kind of) like np.arrays.Īll tensors are immutable like Python numbers and strings: you can never update the contents of a tensor, only create a new one. You can see all supported dtypes at tf.dtypes.DType. Tensors are multi-dimensional arrays with a uniform type (called a dtype). WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow/python/ops/distributions/bernoulli.py:165: RegisterKL._init_ (from .kullback_leibler) is deprecated and will be removed after. You should update all references to use `tfp.distributions` instead of `tf.distributions`. The TensorFlow Distributions library has moved to TensorFlow Probability (). WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow/python/ops/distributions/distribution.py:259: ReparameterizationType._init_ (from .distribution) is deprecated and will be removed after. 01:25:47.544633: E tensorflow/compiler/xla/stream_executor/cuda/cuda_:1518] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered 01:25:47.544600: E tensorflow/compiler/xla/stream_executor/cuda/cuda_fft.cc:609] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered 01:25:47.544553: E tensorflow/compiler/xla/stream_executor/cuda/cuda_dnn.cc:9342] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |