在keras模型中train_on_batch()有什么作用? [英] What does train_on_batch() do in keras model?

查看:367
本文介绍了在keras模型中train_on_batch()有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到了一个示例代码(太大了,无法在此处粘贴),其中的作者使用了model.train_on_batch(in, out)而不是model.fit(in, out). Keras的官方文档说:

I saw a sample of code (too big to paste here) where the author used model.train_on_batch(in, out) instead of model.fit(in, out). The official documentation of Keras says:

对一批样品进行单个梯度更新.

Single gradient update over one batch of samples.

但是我不明白.它与fit()相同吗,但是它没有执行许多前馈和反向传播步骤,而是执行一次?还是我错了?

But I don't get it. Is it the same as fit(), but instead of doing many feed-forward and backprop steps, it does it once? Or am I wrong?

推荐答案

是的,train_on_batch仅使用一次批处理进行训练.

Yes, train_on_batch trains using a single batch only and once.

fit同时为许多时期训练许多批次. (每批次都会导致重量更新).

While fit trains many batches for many epochs. (Each batch causes an update in weights).

使用train_on_batch的想法可能是在每个批次之间自己做更多的事情.

The idea of using train_on_batch is probably to do more things yourself between each batch.

这篇关于在keras模型中train_on_batch()有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆