Keras 2.0.6, VGG16 'Model' object has no attribute 'add'
See original GitHub issue在练习你们文档中"面向小数据集构建图像分类模型"案例时,第三部分微调预训练网络,出错.
top_model = Sequential()
top_model.add(Flatten(input_shape=model.output_shape[1:]))
top_model.add(Dense(256, activation='relu'))
top_model.add(Dropout(0.5))
top_model.add(Dense(1, activation='sigmoid'))
# note that it is necessary to start with a fully-trained
# classifier, including the top classifier,
# in order to successfully do fine-tuning
top_model.load_weights(top_model_weights_path)
# add the model on top of the convolutional base
model.add(top_model)
文章地址:https://blog.keras.io/building-powerful-image-classification-models-using-very-little-data.html 代码地址(59-75行):https://gist.github.com/fchollet/7eb39b44eb9e16e59632d25fb3119975
Keras 2.06, TensorFlow 1.2.x,
Issue Analytics
- State:
- Created 6 years ago
- Comments:6
Top Results From Across the Web
Model has no attribute 'shape' - VGG16 Model - Stack Overflow
The problem is that in error line, you are introducing your VGG16 model as input, and what you want is to introduce the...
Read more >tf.keras.applications.vgg16.VGG16 | TensorFlow v2.11.0
None means that the output of the model will be the 4D tensor output of the last convolutional block.
Read more >Image Augmentation for Deep Learning with Keras
In this post, you will discover how to use data preparation and data augmentation with your image datasets when developing and evaluating deep ......
Read more >Home - Keras 2.0.6. Documentation
Keras is a high-level neural networks API, written in Python and capable of running on top of TensorFlow, CNTK, or Theano. It was...
Read more >NEWS
Any R objects stored in private will only be available to methods, and will not be ... format() method for keras models (and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Use something like this:
I solved by creating a new model (Sequential()) and by copying all the layers of VGG16 into this new model: