Tensorflow Slim: TypeError: Expected int32, got list containing Tensors of type '_Message' instead

前端 未结 4 1881
名媛妹妹
名媛妹妹 2020-12-08 13:58

I am following this tutorial for learning TensorFlow Slim but upon running the following code for Inception:

import numpy as np
import os
import tensorflow a         


        
4条回答
  •  失恋的感觉
    2020-12-08 14:49

    I got same error when I did the work.

    I found that

    logits = tf.nn.xw_plus_b(tf.concat(outputs, 0), w, b)
    loss = tf.reduce_mean(
      tf.nn.softmax_cross_entropy_with_logits(
        labels=tf.concat(train_labels, 0), logits=logits))
    

    The output is shape=(10, 64, 64).

    The code want concat outputs[0] to outputs[9] => get a new shape(640,64).

    But the "tf.concat" API may not allow to do this.

    (train_labels same to this)

    So I write to

    A = tf.concat(0,[outputs[0],outputs[1]])
    A = tf.concat(0,[A,outputs[2]])
    A = tf.concat(0,[A,outputs[3]])
    A = tf.concat(0,[A,outputs[4]])
    A = tf.concat(0,[A,outputs[5]])
    A = tf.concat(0,[A,outputs[6]])
    A = tf.concat(0,[A,outputs[7]])
    A = tf.concat(0,[A,outputs[8]])
    A = tf.concat(0,[A,outputs[9]])
    B = tf.concat(0,[train_labels[0],train_labels[1]])
    B = tf.concat(0,[B,train_labels[2]])
    B = tf.concat(0,[B,train_labels[3]])
    B = tf.concat(0,[B,train_labels[4]])
    B = tf.concat(0,[B,train_labels[5]])
    B = tf.concat(0,[B,train_labels[6]])
    B = tf.concat(0,[B,train_labels[7]])
    B = tf.concat(0,[B,train_labels[8]])
    B = tf.concat(0,[B,train_labels[9]])
    
    logits = tf.nn.xw_plus_b(tf.concat(0, A), w, b)
    loss = tf.reduce_mean(
      tf.nn.softmax_cross_entropy_with_logits(
        labels=tf.concat(0, B), logits=logits))
    

    It can run!

提交回复
热议问题