简体   繁体   English

使用预先训练的举重训练

[英]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.

相关问题 为什么我的训练损失在使用预训练权重训练 AlexNet 的最后一层时会发生振荡? - Why does my training loss oscillate while training the final layer of AlexNet with pre-trained weights? 如何使用预先训练的权重为 keras 中的特定通道设置权重? - How to set weights for specific channels in keras with pre-trained weights? 如何访问和可视化预训练的 TensorFlow 2 模型中的权重? - How to access and visualize the weights in a pre-trained TensorFlow 2 model? TensorFlow:在预训练的砝码上添加一点噪音 - TensorFlow: Adding a small noise to pre-trained weights 在Keras的Alexnet模型中使用预先训练的权重 - Using pre-trained weights in Alexnet model in Keras 更改预训练模型的输入形状及其权重 - Changing the input shape of pre-trained models along with its weights 在 AlexNet (Keras) 中使用预训练权重的问题 - Problem in using pre-trained weights in AlexNet (Keras) 加载预训练的 keras 模型以在谷歌云上继续训练 - Load pre-trained keras model for continued training on google cloud 数据集训练:融合参数调整和预训练模型 - dataset training: converging on parameter tuning and pre-trained models 如何对预训练的 model 的附加数据进行部分训练? - How to partial training on the additional data for pre-trained model?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM