LoginSignup
1
1

More than 3 years have passed since last update.

TypeError: The added layer must be an instance of class Layer. Found: <keras.engine.training.Model object at XXXXXXXX>

Posted at

エラー内容

コード

from keras.applications.resnet50 import ResNet50
from tensorflow.keras.models import Sequential

resnet = ResNet50(include_top=False, pooling='avg', weights='imagenet')
my_new_model = Sequential()
my_new_model.add(resnet)

エラー

TypeError: The added layer must be an instance of class Layer. Found: <keras.engine.training.Model object at XXXXXXXX>

原因

kerasとtensorflow.kerasを同時に使っていたからだと思う。

解決

from tensorflow.keras.applications.resnet50 import ResNet50
from tensorflow.keras.models import Sequential

resnet = ResNet50(include_top=False, pooling='avg', weights='imagenet')
my_new_model = Sequential()
my_new_model.add(resnet)
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1