I'm trying to make a model with two outputs, one for classification and other for regression. I'm using pre-trained VGG16 from Keras as the convolutional feature extractor. But when I try to build the next flatten layer in both the output sequence, I get error that the input is not a tensor. How do I make sure I'm feeding only the last layer of the convolutional base as input to the next layers?
conv_base = VGG16(include_top = False,
weights = 'imagenet')
conv_base.trainable = False
with tf.variable_scope('classification_head', reuse=tf.AUTO_REUSE):
x = Flatten()(conv_base.layers[-1])
x = Dense()(x)
Error :
ValueError: Layer flatten_1 was called with an input that isn't a symbolic tensor. Received type: class 'keras.layers.pooling.MaxPooling2D'. Full input: [keras.layers.pooling.MaxPooling2D object at 0xc2855c9b0]. All inputs to the layer should be tensors.
Got the required tensor as :
features = conv_base.output
print(features)
Tensor("block5_pool/MaxPool:0", shape=(?, 11, 14, 512), dtype=float32)