[英]Training with pre-trained weights
I want to use a set of pre-trained weights to train my model for MNIST classification. 我想使用一组预先训练的权重来为MNIST分类训练我的模型。 More specifically, I train my model on one dataset.
更具体地说,我在一个数据集上训练模型。 I want to use the final weights as the starting weights to train the model on a different dataset.
我想将最终权重用作开始权重,以在不同的数据集上训练模型。 To do this, I use
为此,我使用
intial_weights = model1.get_weights()
model2 = create_model()
model2.set_weights(initial_weights)
model2.fit(x=x_train59,y=y_train59, epochs=20,callbacks = [cp_callback2])
My question is that whether model.fit() will ignore the initial weights set using model2.set_weights() or not. 我的问题是model.fit()是否将忽略使用model2.set_weights()设置的初始权重。 And if it does ignore, is there a way to make sure that model2.fit() uses the weights obtained previously.
并且如果确实忽略了,那么有一种方法可以确保model2.fit()使用先前获得的权重。 Also, is there a way to visualize the starting weights before model.fit() starts training.
另外,在model.fit()开始训练之前,有没有办法可视化起始权重。 Thanks much in advance!
在此先感谢!
When you do model2.set_weights
, you changed the weights of model2
. 执行
model2.set_weights
,更改了model2
的权重。 That's all. 就这样。
You can see the weights the same way: w2 = model2.get_weights()
. 您可以用相同的方式查看权重:
w2 = model2.get_weights()
。 Then print w2
in a convenient way. 然后以方便的方式打印
w2
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.