Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does it mean for a tensor to have shape [None, x] in TensorFlow? [duplicate]

If I define a tf placeholder as:

tf.placeholder("float", [None, 10])

what does the None do? What is the linear algebra interpretation of this? A horizontal vector?

like image 667
Sahand Avatar asked Mar 14 '18 16:03

Sahand


People also ask

What does shape None mean?

“None” tells that any batch size will be accepted. Set to None, then the bs is not bounded by a specific number. Params means each layer's trainable and non-trainable parameters.

What is none in tensor shape?

Partially-known shape: has a known number of dimensions, and an unknown size for one or more dimension. e.g. TensorShape([None, 256]) Unknown shape: has an unknown number of dimensions, and an unknown size in all dimensions. e.g. TensorShape(None)

What does shape mean in TensorFlow?

The shape of a tensor is the number of elements in each dimension. TensorFlow automatically infers shapes during graph construction. These inferred shapes might have known or unknown rank. If the rank is known, the sizes of each dimension might be known or unknown.

What is TensorFlow?

What is a Tensor? Tensorflow's name is directly derived from its core framework: Tensor. In Tensorflow, all the computations involve tensors. A tensor is a vector or matrix of n-dimensions that represents all types of data.

What is the shape of data in TensorFlow?

The shape of the data is the dimensionality of the matrix or array. A tensor can be originated from the input data or the result of a computation. In TensorFlow, all the operations are conducted inside a graph. The graph is a set of computation that takes place successively. Each operation is called an op node and are connected to each other.

How to create a tensor of dimension 1 in TensorFlow?

A tensor of dimension 1 can be created as follow: You can notice the TensorFlow shape is only composed of 1 column. To create an array of 2 tensor dimensions, you need to close the brackets after each row. Check the Keras Tensor shape example below

What are the different types of tensors?

This article will guide you through the concept of tensor’s shape in both its variants: static and dynamic. Every tensor has a name, a type, a rank and a shape.


1 Answers

A None value in the shape of a tensor means that the tensor can be of any size (large than or equal to 1) in that dimension. E.g., for the tf.placeholder you defined in your question, you could pass a arrays with shapes like

[1234, 10]
[10, 10]
[1, 10]

but not an array of shape [10,] (i.e. a vector).

like image 131
lballes Avatar answered Sep 29 '22 19:09

lballes