英文:
Check whether a variable is instance of ResNet50
问题
以下是翻译好的代码部分:
我正在检查是否
model = ResNet50(weights='imagenet', include_top=False, pooling="avg")
是
keras.applications.ResNet50
的实例。
我已经尝试过:
isinstance(model, ResNet50)
但不幸的是,这引发了以下异常:
> TypeError: isinstance()的第二个参数必须是一个类型、类型元组或联合类型
此外,我也尝试过:
isinstance(model, keras.applications.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?
答案1
得分: 1
keras.applications.ResNet50
是一个返回 keras.models.Model
实例的函数。
尝试:
if model.name == "resnet50":
...
英文:
keras.applications.ResNet50
is a function that returns an instance of keras.models.Model
.
Try:
if model.name == "resnet50":
...
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论