lohasupport.blogg.se

Tensor calculus
Tensor calculus












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.Tensors are used in all kinds of operations (ops).

tensor calculus

Print(a * b, "\n") # element-wise multiplication Print(a + b, "\n") # element-wise addition 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.

tensor calculus

A scalar contains a single value, and no "axes".

Tensor calculus update#

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.

tensor calculus

Tensors are multi-dimensional arrays with a uniform type (called a dtype).












Tensor calculus