在对 tensorflow 对象执行操作时获取 TypeError

下面是代码的简化版本,我在行中遇到错误 res = input - var


import tensorflow.contrib.slim as slim

import tensorflow as tf


x = tf.placeholder(tf.float32, shape=[None, 150, 220, 3], name='x')


input = slim.conv2d(x,  num_outputs=96, kernel_size=11, stride=4, padding=padding, scope=scope, weights_initializer=tf.truncated_normal_initializer(stddev=0.01), biases_initializer=None, activation_fn=None)


var = tf.zeros_initializer()


res = input - var

变量类型


input type: <tensorflow.python.ops.init_ops.Zeros object at 0x7f1a017fdb38>

var_type: Tensor("conv1/Conv2D:0", shape=(?, 35, 53, 96), dtype=float32)

错误


TypeError: Expected float32, got <tensorflow.python.ops.init_ops.Zeros object at 0x7f1a017fdb38> of type 'Zeros' instead.

我该如何解决它,任何建议都会有所帮助。


芜湖不芜
浏览 256回答 1
1回答

烙印99

在这一行中,您试图从张量中减去一个方法。var = tf.zeros_initializer()res = input - var
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python