简体   繁体   English

如何在 tensorflow 1.x 的每个训练时期保持模型的输出?

[英]How to hold the output of a model at each training epoch in tensorflow 1.x?

I am trying to implement a constraint on the output of a neural network using the output of the previous training epoch.我正在尝试使用前一个训练时期的输出对神经网络的输出实施约束。 I tried using tf.assign() to update the value of a variable that holds the output, but it turned out that it holds the initial value.我尝试使用 tf.assign() 来更新保存输出的变量的值,但结果证明它保存了初始值。

You must use callbacks.您必须使用回调。 It's my example for maximum scorу:这是我获得最大分数的示例:

checkpoint_precision = ModelCheckpoint(filepath='best-weights, precision_selu_pr.hdf5', monitor='val_precision', mode='max', verbose=1, save_best_only=True)

checkpoint_auc = ModelCheckpoint(filepath='best-weights-auc_selu_pr.hdf5', monitor='val_auc', mode='max', verbose=1, save_best_only=True)

model.fit(x=data_x, y=Y, batch_size=100, epochs=100000, validation_data (x_val_scaled, Y_val), callbacks=[checkpoint_precision, checkpoint_auc])

For more information you can use this link: https://www.tensorflow.org/api_docs/python/tf/keras/callbacks有关更多信息,您可以使用此链接: https : //www.tensorflow.org/api_docs/python/tf/keras/callbacks

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Tensorflow 1.x 中的训练期间打印值 - How to print value during Training in Tensorflow 1.x Tensorflow 每个 epoch 后的分布式训练暂停 - Tensorflow distributed training pause after each epoch Tensorflow 每个时期对数据集的不同子集进行训练 - Tensorflow training on different subset of dataset each epoch 如何在tensorflow中使用transformers bert保存每个时期的最佳模型 - How to save the best model of each epoch with transformers bert in tensorflow 如何在训练运行之间的中间层内的每个时期更新参数? (张量流急切执行) - How to update parameter at each epoch within an intermediate Layer between training runs ? (tensorflow eager execution) 在训练期间如何在每个 epoch 结束时调用测试集? 我正在使用张量流 - How can I call a test set at the end of each epoch during the training? I am using tensorflow tensorflow-keras 如何计算每个 epoch 的训练成本? - How does tensorflow-keras calculate the cost during training in each epoch? 加载 model,使用 Tensorflow 2.0 保存,使用 Tensorflow 1.x - Loading a model, saved using Tensorflow 2.0, using Tensorflow 1.x 在每个训练时期后获得 memory 用法 - Tensorflow 版本 1.15 - Get memory usage after each training epoch - Tensorflow version 1.15 如何在 Keras 的每个训练周期后进行预测? - How to predict after each epoch of training in Keras?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM