So I'm trying to print the value of the model.output (which is a tensor) of pretrained VGG16 model, but unfortunately all the below listed methods didn't work in my case, which I found from the previously answered similar questions.
1) Firstly on the basis of this post I tried using
print(K.eval(model.output()))
but it threw an error as
TypeError: 'Tensor' object is not callable
2) Then upon going through this post I tried using
K.print_tensor(model.output, message='model.output = ')
approach but this time there was no output printed.
Here is my code:
from keras.applications.vgg16 import VGG16
from keras.applications.vgg16 import preprocess_input
from keras.preprocessing.image import load_img
from keras.preprocessing.image import img_to_array
from keras.models import Model
import keras.backend as K
from matplotlib import pyplot
from numpy import expand_dims
import numpy as np
# load the model
model = VGG16()
img = load_img('../input/treebird/bird.jpg', target_size=(224, 224))
img = img_to_array(img)
img = expand_dims(img, axis=0)
img = preprocess_input(img)
prediction = model.predict(img)
print(model.output) #Tensor("predictions_19/Softmax:0", shape=(?, 1000), dtype=float32)
print(K.eval(model.output())) # throws TypeError: 'Tensor' object is not callable
K.print_tensor(model.output, message='model.output = ')
Am I lacking somewhere in the implementation of the above methods or are there other methods that I am supposed to use to print the tensor in this case?