我试图用tf.contrib.estimator
构建张量流中的神经网络
但
logits = tf.reduce_mean(conv2, axis=[1, 2])
y = tf.argmax(logits, axis=1),
# If prediction mode, early return
if mode == tf.estimator.ModeKeys.PREDICT:
return tf.estimator.EstimatorSpec(mode, predictions=y)
loss_op = tf.losses.softmax_cross_entropy(onehot_labels=y_onehot, logits=logits)
optimizer = tf.train.AdamOptimizer(learning_rate=0.001)
train_op = optimizer.minimize(loss_op, global_step=tf.train.get_global_step())
# Add evaluation metrics (for EVAL mode)
acc_op = tf.contrib.metrics.accuracy(labels=y_, predictions=tf.cast(y, tf.uint8))
返回错误:
raise TypeError('{} must be Tensor, given: {}'.format(tensor_name, x)) TypeError: predictions must be Tensor, given: (<tf.Tensor 'ArgMax:0' shape=(10,) dtype=int64>,)
答案 0 :(得分:0)
问题出在结尾处的逗号
y = tf.argmax(logits, axis=1),