【发布时间】:2020-06-09 14:06:54
【问题描述】:
我想将 TensorVariable 转换为 numpy 数组并尝试:
feature_vector = keras_model.get_layer(blob_name).output.numpy()
但得到错误。
AttributeError: 'TensorVariable' 对象没有属性 'numpy'
我也试过了:
feature_vector = keras_model.get_layer(blob_name).output
init = tf.compat.v1.global_variables_initializer()
with tf.compat.v1.Session() as sess:
sess.run(init)
print(feature_vector.eval())
但报错
theano.gof.fg.MissingInputError: 图表的输入 0(索引开始 从 0),用于计算 Shape(/input_1),没有提供,也没有 给定一个值。使用 Theano 标志 exception_verbosity='high',对于 有关此错误的更多信息。
【问题讨论】:
-
您的错误消息指出,您将 theano 后端用于 keras。如果您提供导入,我们可以解决此问题。
标签: numpy tensorflow keras keras-layer tensor