如何将 TensorVariable 转换为 numpy
How to convert TensorVariable to numpy
我想将 TensorVariable 转换为 numpy 数组并尝试:
feature_vector = keras_model.get_layer(blob_name).output.numpy()
但是得到错误。
AttributeError: 'TensorVariable' object has no attribute '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: Input 0 of the graph (indices start
from 0), used to compute Shape(/input_1), was not provided and not
given a value. Use the Theano flag exception_verbosity='high', for
more information on this error.
谢谢@Lau。是的,我使用 theano 并修复了这个错误,如 this
我想将 TensorVariable 转换为 numpy 数组并尝试:
feature_vector = keras_model.get_layer(blob_name).output.numpy()
但是得到错误。
AttributeError: 'TensorVariable' object has no attribute '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: Input 0 of the graph (indices start from 0), used to compute Shape(/input_1), was not provided and not given a value. Use the Theano flag exception_verbosity='high', for more information on this error.
谢谢@Lau。是的,我使用 theano 并修复了这个错误,如 this