评估每个训练时期之后测试集的模型
我正在训练图像数据集上的TensorFlow模型进行分类任务,我们通常将培训集和验证集提供给model.fit
方法,我们以后可以输出培训和验证的趋势模型收敛图。我想对测试集进行相同的操作,换句话说,我想在每个时期之后获得测试集上的模型的准确性和丢失(未验证集 - 我无法用测试替换验证集设置是因为我需要这两个图形)。
我设法通过使用一些回调来保存模型的检查点来做到这一点其他回调或与model.fit
方法一起使用。
I'm training a tensorflow model on image dataset for a classification task, we usually provide the training set and validation set to the model.fit
method, we can later output model convergence graph of training and validation. I want to do the same with the testing set, in other words, I want to get the accuracy and loss of my model on the testing set after each epoch(not validation set - and I can't replace the validation set with the testing set because I need graphs of both of them).
I managed to do that by saving the checkpoints of my model after each epoch using some callback and later load each checkpoint to my model and compute accuracy and loss, but I want to know if there exists some easier way of doing that, maybe with some other callback or some work around with the model.fit
method.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用自定义
回调
并传递测试数据并做任何您喜欢的事情:您还可以在回调中使用
model.evaluate
。另请参阅此 post 。You could use a custom
Callback
and pass your test data and do whatever you like:You can also just use
model.evaluate
in the callback. See also this post.您可以通过将XTEST和YTEST数据提供给验证_data =(Xtest,ytest)来评估每个时期的模型:
在上代码时代= 20中只是一个标本,您可以将其更改为想要数量的时期。 batch_size = 5也是样品。
You evaluate a model every epoch by giving xTest and yTest data to validation_data=(xTest, yTest):
In the upper code epochs=20 is just a specimem, you can change it to a wanted number of epochs. The batch_size=5 is the specimen as well.