问题描述
我看到了一个示例代码(太大了,无法在此处粘贴),其中的作者使用了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:
但是我不明白.它与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()有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!