I'm using Keras' pre-trained VGG16 model, and I want to to visualise the output of each layer. However, layer.output returns a tensor object - how can I convert it something that allows me to get the image outputs?
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
Also, when I try to access specific node's output, it returns a tensor:
layer1.get_output_at(0)
Any help is greatly appreciated. Thank you.