用新课程重新训练模型

编程入门 行业动态 更新时间:2024-10-23 18:20:50
本文介绍了用新课程重新训练模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我建立了一个具有2个类别的图像分类器,例如"A"和"B".我还使用model.save()保存了该模型.

I have built an image classifier with 2 classes, say 'A' and 'B'. I have also saved this model, using model.save().

现在,经过一定时间后,出现了增加一个"C"类的要求.是否可以load_model()然后仅将一个类添加到先前保存的模型中,以便我们最终的模型具有3个类("A","B"和"C"),而不必重新训练整个模型,再次使用"A"和"B"类?

Now, after a certain time, the requirement arose to add one more class 'C'. Is it possible to load_model() and then add only one class to the previously saved model so that we have the final model with 3 classes ('A','B' and 'C'), without having to retrain the whole model, for classes 'A and 'B' again?

任何人都可以帮忙吗?

我已经尝试过了:

我使用vgg16作为基本模型,弹出其最后一层,冻结权重,并添加了一个密集层(DL2),对其进行了训练以预测2类.

I used vgg16 as a base model and pop out its last layer, freeze weights and added one dense layer (DL2), trained it for predicting 2 classes.

然后我在DL2的顶部添加了一个更密集的层,例如DL3,冻结了重量并仅使用C类进行训练,但现在它始终可以预测C类.

Then I added one more dense layer on top of DL2 say DL3, freeze weights and train with class C only but now its always predicting class C.

推荐答案

只需使用转移学习,然后创建一个新模型即可.

Just use a transfer learning, and create a new model.

model = VGG16(weights='imagenet', include_top=False, input_shape=(150, 150, 3)) model.pop() base_model_layers = model.output pred = Dense(11, activation='softmax')(base_model_layers) model = Model(inputs=model.input, outputs=pred) # Freeze the first layers, before train it for layer in model.layers[:-2]: layer.trainable = False

更多推荐

用新课程重新训练模型

本文发布于:2023-11-10 09:45:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1575040.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:新课程   模型

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!