[英]Error with model.compile and model.fit_generator on Keras
Beginner with Keras -- I'm attempting to train a very simple neural network on a series of images from my local folder, but getting an error when I try to use fit_generator
. 初学者与Keras - 我试图在我的本地文件夹的一系列图像上训练一个非常简单的神经网络,但是当我尝试使用fit_generator
时出现错误。
From 从
model.fit_generator(train_batches,steps_per_epoch=33, validation_data=valid_batches,validation_steps=50,epochs=10,verbose=2)`
I get the error 我收到了错误
RuntimeError: You must compile your model before using it.
despite the fact that I compile the model in the line immediately about it with 尽管事实上我立即在线上编译了模型
model.compile(Adam(0.01),loss="categorical_crossentropy",metrics=["accuracy"])
which runs without errors. 哪个运行没有错误。 (see pictures). (看图片)。
This can be a rare case where pictures are more useful than code sample. 这可能是一种罕见的情况,其中图片比代码示例更有用。
The image says, the compile cell got number [206]
, and fit cell is [210]
. 图像说,编译单元得到数字[206]
,拟合单元格为[210]
。 In between them, you have recreated the model at [209]
, which deletes the previously compiled model and creates a new one. 在它们之间,您已在[209]
重新创建模型,该模型删除先前编译的模型并创建新模型。
I think it will run (unless there is another bug) if you execute the cells from top to bottom again. 如果你再次从上到下执行单元格,我认为它将运行(除非有另一个错误)。
I ran into the same issue. 我遇到了同样的问题。 There is a bug: https://github.com/tensorflow/tensorflow/issues/18287 有一个错误: https : //github.com/tensorflow/tensorflow/issues/18287
Unfortunately the fix is not yet released. 不幸的是,修复程序尚未发布。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.