python – Keras似乎在调用fit_generator后挂起

python – Keras似乎在调用fit_generator后挂起,第1张

概述我试图将 SqueezeDet model的Keras实现适应新的数据集.在对配置文件进行适当的更改后,我尝试运行火车脚本,但是在调用fit_generator()之后它似乎挂起了.当我得到以下输出: /anaconda/envs/py35/lib/python3.5/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of t 我试图将 SqueezeDet model的Keras实现适应新的数据集.在对配置文件进行适当的更改后,我尝试运行火车脚本,但是在调用fit_generator()之后它似乎挂起了.当我得到以下输出:

/anaconda/envs/py35/lib/python3.5/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future,it will be treated as `np.float64 == np.dtype(float).type`.  from ._conv import register_converters as _register_convertersUsing TensorFlow backend.Number of images: 536Number of epochs: 100Number of batches: 53Batch size: 102018-07-04 14:18:49.711606: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your cpu supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA2018-07-04 14:18:54.080912: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1356] Found device 0 with propertIEs:name: Tesla K80 major: 3 minor: 7 memoryClockRate(GHz): 0.8235pciBusID: 52a9:00:00.0totalMemory: 11.17GiB freeMemory: 11.10GiB2018-07-04 14:18:54.080958: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1435] Adding visible gpu devices: 02018-07-04 14:18:54.333214: I tensorflow/core/common_runtime/gpu/gpu_device.cc:923] Device interconnect StreamExecutor with strength 1 edge matrix:2018-07-04 14:18:54.333270: I tensorflow/core/common_runtime/gpu/gpu_device.cc:929]      02018-07-04 14:18:54.333290: I tensorflow/core/common_runtime/gpu/gpu_device.cc:942] 0:   N2018-07-04 14:18:54.333559: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1053] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 10764 MB memory) -> physical GPU (device: 0,name: Tesla K80,pci bus ID: 52a9:00:00.0,compute capability: 3.7)Learning rate: 0.01Weights initialized by name from ../main/model/imagenet.h5Using single GPUBackend Qt5Agg is interactive backend. Turning interactive mode on.Epoch 1/100

然后即使它一天不管它也没有任何反应.它似乎冻结的电话是:

squeeze.model.fit_generator(train_generator,epochs=EPOCHS,verbose=1,steps_per_epoch=nbatches_train,callbacks=cb)

参数是:

train_generator = generator_from_data_path(img_names,gt_names,config=cfg)EPOCHS = 100nbatches_train  = 53callbacks = [# TensorBoard object,ReduceLROnPlateau object,ModelCheckpoint object #]

我的版本:

Python 3.5.4 :: Anaconda custom (64-bit)tensorflow-gpu : 1.8.0tensorflow : 1.8.0Keras : 2.2.0
解决方法 格式化评论中的对话以回答.

罪魁祸首是train_generator.

我前段时间在Keras看过model.fit_generator的来源.它只是从生成器中检索一些数据并将其提交到后端,没什么神奇的:)

因此,我的假设是它无法从生成器检索数据,因为生成器不生成任何内容.

@barker已经确认了这一点,说明对next(train_generator)的调用挂起了.

我个人已经转移到支持索引和长度的keras.utils.Sequence,并且比普通生成器更方便.虽然这个说明与当前的问题无关.

总结

以上是内存溢出为你收集整理的python – Keras似乎在调用fit_generator后挂起全部内容,希望文章能够帮你解决python – Keras似乎在调用fit_generator后挂起所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1192101.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-03
下一篇 2022-06-03

发表评论

登录后才能评论

评论列表(0条)

保存