What is the shape of an image tensor in TensorFlow

Noel De Martin

I recently started learning Tensorflow, in particular I want to use Convolutional Neural Networks for image classification. I have been looking at the android demo in the official repository, in particular this example: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/android/src/org/tensorflow/demo/TensorFlowImageClassifier.java

On line 145, it creates a tensor with the input data of the image, as such:

inferenceInterface.feed(inputName, floatValues, 1, inputSize, inputSize, 3);

Now, I have been trying to understand what this is doing, and it ends up calling this method: Tensor.create. The thing I don't understand is why the shape of this tensor, given by the input parameters to this function (also called "dimensions"), is {1, inputSize, inputSize, 3}. the second and third dimensions are the image width and height, and the fourth dimension is the RGB data of the image. But why does it have the first dimension as 1? Shouldn't the shape of this Tensor be {inputSize, inputSize, 3} instead? I guess since the dimension is 1 it makes no difference, but I suppose there has to be a reason for this notation and I don't understand it.

nessuno

Tensorflow works with batches of images. The model, thus, accepts a batch of images each with shape inputSize x inputSize x 3.

The 1 is the batch size. Thus, in practice, you're feeding the network a batch with a single image that's a tensor with shape 1 x inputSize x inputSize x 3

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

TensorFlow:AttributeError: 'Tensor' object has no attribute 'shape'

分類Dev

TensorFlow 2.0 Layer with None type shape Tensor

分類Dev

In Tensorflow How can I add a Tensor to another Tensor with different shape?

分類Dev

PIL image _crop to tensor、in tensorflow

分類Dev

How to explicitly broadcast a tensor to match another's shape in tensorflow?

分類Dev

TensorFlow cannot feed value of shape (538, 1) for Tensor 'Placeholder_21:0', which has shape '(?, 8)'?

分類Dev

In tensorflow.js, what is recommended way of reshaping a tensor?

分類Dev

Tensorflow:Tensor Tensor( "Placeholder:0"、shape =(?, 3)、dtype = float32)はこのグラフの要素ではありません

分類Dev

Slicing tensor with list - TensorFlow

分類Dev

Drop a dimension of a tensor in Tensorflow

分類Dev

Slice tensor in Keras Tensorflow

分類Dev

Creating tensorflow::Tensor from Eigen::Tensor

分類Dev

tf.shape(image)はTensorflow2.0でNoneを返します

分類Dev

AttributeError:モジュール 'tensorflow.python.framework.tensor_shape'に属性 'scalar'がありません

分類Dev

How to check if a tensor is empty in Tensorflow

分類Dev

Operations on Specific Columns on a Tensor in TensorFlow

分類Dev

Iterate over a tensor dimension in Tensorflow

分類Dev

Flipping tensor and fill with zeros in tensorflow

分類Dev

image resize with certain shape

分類Dev

What RGB format do tensorflow image ops expect?

分類Dev

Tensorflow avoid shape information with crop

分類Dev

Tensorflow tf.placeholder with shape = []

分類Dev

/ image / Tensor Tensor( "activation_5 / Softmax:0"、shape =(?, 4)、dtype = float32)のValueErrorは、このグラフの要素ではありません

分類Dev

Split image tensor into small patches

分類Dev

How to fill a tensor of values based on tensor of indices in tensorflow?

分類Dev

tf.Tensor.set_shape()の説明

分類Dev

tf.Tensor.set_shape()の説明

分類Dev

tf.Tensor.set_shape()の説明

分類Dev

how to shape tensor from fully connected to to 4-D

Related 関連記事

  1. 1

    TensorFlow:AttributeError: 'Tensor' object has no attribute 'shape'

  2. 2

    TensorFlow 2.0 Layer with None type shape Tensor

  3. 3

    In Tensorflow How can I add a Tensor to another Tensor with different shape?

  4. 4

    PIL image _crop to tensor、in tensorflow

  5. 5

    How to explicitly broadcast a tensor to match another's shape in tensorflow?

  6. 6

    TensorFlow cannot feed value of shape (538, 1) for Tensor 'Placeholder_21:0', which has shape '(?, 8)'?

  7. 7

    In tensorflow.js, what is recommended way of reshaping a tensor?

  8. 8

    Tensorflow:Tensor Tensor( "Placeholder:0"、shape =(?, 3)、dtype = float32)はこのグラフの要素ではありません

  9. 9

    Slicing tensor with list - TensorFlow

  10. 10

    Drop a dimension of a tensor in Tensorflow

  11. 11

    Slice tensor in Keras Tensorflow

  12. 12

    Creating tensorflow::Tensor from Eigen::Tensor

  13. 13

    tf.shape(image)はTensorflow2.0でNoneを返します

  14. 14

    AttributeError:モジュール 'tensorflow.python.framework.tensor_shape'に属性 'scalar'がありません

  15. 15

    How to check if a tensor is empty in Tensorflow

  16. 16

    Operations on Specific Columns on a Tensor in TensorFlow

  17. 17

    Iterate over a tensor dimension in Tensorflow

  18. 18

    Flipping tensor and fill with zeros in tensorflow

  19. 19

    image resize with certain shape

  20. 20

    What RGB format do tensorflow image ops expect?

  21. 21

    Tensorflow avoid shape information with crop

  22. 22

    Tensorflow tf.placeholder with shape = []

  23. 23

    / image / Tensor Tensor( "activation_5 / Softmax:0"、shape =(?, 4)、dtype = float32)のValueErrorは、このグラフの要素ではありません

  24. 24

    Split image tensor into small patches

  25. 25

    How to fill a tensor of values based on tensor of indices in tensorflow?

  26. 26

    tf.Tensor.set_shape()の説明

  27. 27

    tf.Tensor.set_shape()の説明

  28. 28

    tf.Tensor.set_shape()の説明

  29. 29

    how to shape tensor from fully connected to to 4-D

ホットタグ

アーカイブ