Search code examples
pythonkerasinstance

Check whether a variable is instance of ResNet50


I am checking whether

model = ResNet50(weights='imagenet', include_top=False, pooling="avg")

is instance of

keras.applications.ResNet50

What I have done is:

isinstance(model, ResNet50)

but unfortunately this is raising me the following exception:

TypeError: isinstance() arg 2 must be a type, a tuple of types, or a union

Moreover, I have tried:

isinstance(model, keras.applications.ResNet50())

but, again, this is raising me the same exception.

  • What am I missing?

Solution

  • keras.applications.ResNet50 is a function that returns an instance of keras.models.Model.

    Try:

    if model.name == "resnet50":
        ...