UnboundLocalError:赋值之前引用了局部变量'outs'-durnig训练模型

时间:2018-10-12 14:18:51

标签: python-2.7 tensorflow keras deep-learning

我是keras初学者

Epoch 9/100
99/100 [============================>.] - ETA: 0s - loss: 0.4229 - acc: 0.8649Epoch 00008: val_loss did not improve
100/100 [==============================] - 72s - loss: 0.4222 - acc: 0.8650 - val_loss: 1.2091 - val_acc: 0.5000
Traceback (most recent call last):
File "Train.py", line 382, in <module>
train(args)
File "Train.py", line 351, in train
scores = model.evaluate_generator(validation_generator, workers=5, steps = None)
File "/home/Grace/kerasenv/local/lib/python2.7/site-packages/keras/legacy/interfaces.py", line 87, in wrapper
return func(*args, **kwargs)
File "/home/Grace/kerasenv/local/lib/python2.7/site-packages/keras/engine/training.py", line 1991, in evaluate_generator
if not isinstance(outs, list):
UnboundLocalError: local variable 'outs' referenced before assignment

我的代码在这里。

    scores = model.evaluate_generator(validation_generator, workers=5, steps = None)

    history_ft = model.fit_generator(
    train_generator,
    epochs=nb_epoch,
    steps_per_epoch=steps_per_epoch,
    validation_steps = 3,
    validation_data=validation_generator,
    callbacks = [tensorboard, checkpointer, EarlyStopping(monitor='val_loss', min_delta=0.01, patience=5)],
    class_weight = 'auto',
    workers = 5,
    use_multiprocessing = True)

参数

  • steps_per_epoch = 100
  • nb_epoch = 100
  • 批量大小:8

    • 找到1134张属于4类的图像(火车组)
    • 找到174个属于4类的图像。(验证集)
  • 我的keras 2.0.6版本

  • tensorflow:1.3.0

有人知道为什么吗?谢谢

0 个答案:

没有答案