【发布时间】:2017-06-16 07:03:37
【问题描述】:
我正在使用 Keras 的预训练 VGG16 模型,我想可视化每一层的输出。但是,layer.output 返回一个张量对象 - 我怎样才能将它转换为允许我获取图像输出的东西?
model = VGG16(weights='imagenet', include_top=True)
img_path = 'elephant.jpg'
img = image.load_img(img_path, target_size=(224, 224))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
x = preprocess_input(x)
features = model.predict(x)
layer1 = model.layers[1] #I want the output of the second layer
layer1.output #returns a tensor object
另外,当我尝试访问特定节点的输出时,它会返回一个张量:
layer1.get_output_at(0)
非常感谢任何帮助。谢谢。
【问题讨论】:
标签: tensorflow neural-network theano keras conv-neural-network