Tensorflow : logits and labels must have the same first dimension

前端 未结 5 2191
迷失自我
迷失自我 2020-12-16 03:13

I am new in tensoflow and I want to adapt the MNIST tutorial https://www.tensorflow.org/tutorials/layers with my own data (images of 40x40). This is my model function :

5条回答
  •  粉色の甜心
    2020-12-16 03:57

    Your logits shape looks right, batch size of 3, and output layer of size 2, which is what you defined as your output layer. Your labels should be shape [3, 2] also. Batch of 3, and each batch has 2 [1,0] or [0,1].

    Also note that when you have a boolean classification output you shouldn't have 2 neurons on the output/logits layer. You can just output a single value which takes on 0 or 1, you can probably see how 2 outputs of [1,0], and [0,1] is redundant and can be expressed as a simple [0|1] value. Also you tend to get better results when you do it this way.

    Thus, your logits should end up being [3,1] and your labels should be an array of 3 values, one for each of the samples in your batch.

提交回复
热议问题