-2
inputs = tf.keras.layers.Input(shape=(32,32,3))
resize = tf.keras.layers.UpSampling2D(size=(7,7))(inputs)
feature_extractor = tf.keras.applications.resnet.ResNet50(input_shape=(224, 224,3),include_top=False,weights='imagenet')(resize)
feature_extractor.summary()

The code above results an error AttributeError: 'KerasTensor' object has no attribute 'summary.

But if I remove resize parameter from ResNet50() as below, It displays the summary without error. Why ?

tf.keras.applications.resnet.ResNet50(input_shape=(224, 224, 3),
                                               include_top=False,
                                               weights='imagenet')
krenerd
  • 741
  • 4
  • 22

1 Answers1

0

This is because you didn't complete building your model by defining a tf.keras.models.Model model.

inputs = tf.keras.layers.Input(shape=(32,32,3))
resize = tf.keras.layers.UpSampling2D(size=(7,7))(inputs)
feature_extractor = tf.keras.applications.resnet.ResNet50(input_shape=(224, 224,3),include_top=False,weights='imagenet')(resize)

model=tf.keras.models.Model(inputs,feature_extractor)
model.summary()
krenerd
  • 741
  • 4
  • 22