BossSensor
BossSensor copied to clipboard
UnboundLocalError: local variable 'epoch_logs' referenced before assignment
boss_train.py errors have occurred.
/Users/icent/Documents/BossSensor/data/boss/dummy.jpg X_train shape: (0, 64, 64, 3) 0 train samples 0 valid samples 1 test samples ~~ Total params: 6489634
Using real-time data augmentation.
Epoch 1/10
Traceback (most recent call last):
File "/Users/icent/Documents/BossSensor/boss_train.py", line 181, in
UnboundLocalError: local variable 'epoch_logs' referenced before assignment
Help me!
I have the same error:
Total params: 6,489,634
Trainable params: 6,489,634
Non-trainable params: 0
____________________________________________________________________________________________________
Using real-time data augmentation.
Epoch 1/10
Exception in thread Thread-1:
Traceback (most recent call last):
File "D:\tools\Anaconda3\envs\bossSensor\lib\threading.py", line 914, in _bootstrap_inner
self.run()
File "D:\tools\Anaconda3\envs\bossSensor\lib\threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "D:\tools\Anaconda3\envs\bossSensor\lib\site-packages\keras\engine\training.py", line 429, in data_generator_task
generator_output = next(self._generator)
File "D:\tools\Anaconda3\envs\bossSensor\lib\site-packages\keras\preprocessing\image.py", line 662, in __next__
return self.next(*args, **kwargs)
File "D:\tools\Anaconda3\envs\bossSensor\lib\site-packages\keras\preprocessing\image.py", line 708, in next
index_array, current_index, current_batch_size = next(self.index_generator)
File "D:\tools\Anaconda3\envs\bossSensor\lib\site-packages\keras\preprocessing\image.py", line 645, in _flow_index
current_index = (self.batch_index * batch_size) % n
ZeroDivisionError: integer division or modulo by zero
Traceback (most recent call last):
File "D:/tools/PyCharm-Project/BossSensor/boss_train.py", line 178, in <module>
model.train(dataset, nb_epoch=10)
File "D:/tools/PyCharm-Project/BossSensor/boss_train.py", line 143, in train
validation_data=(dataset.X_valid, dataset.Y_valid))
File "D:\tools\Anaconda3\envs\bossSensor\lib\site-packages\keras\models.py", line 935, in fit_generator
initial_epoch=initial_epoch)
File "D:\tools\Anaconda3\envs\bossSensor\lib\site-packages\keras\engine\training.py", line 1600, in fit_generator
callbacks.on_epoch_end(epoch, epoch_logs)
UnboundLocalError: local variable 'epoch_logs' referenced before assignment
How can I fix it??
-----------------------------------update-------------------------------------------------
It's my problem, I gave wrong photos's format *.png instead of *.jpg, so I saw this after read all photos:
X_train shape: (0, 64, 64, 3)
0 train samples
0 valid samples
0 test samples
When I changed all the extension of photos, It can work.
Me too... get the same error:
Total params: 6,489,634
Trainable params: 6,489,634
Non-trainable params: 0
_________________________________________________________________
Using real-time data augmentation.
boss_train.py:143: UserWarning: Update your `fit_generator` call to the Keras 2 API: `fit_generator(<keras.pre..., epochs=10, steps_per_epoch=0, validation_data=(array([[[...)`
validation_data=(dataset.X_valid, dataset.Y_valid))
Epoch 1/10
Traceback (most recent call last):
File "boss_train.py", line 175, in <module>
model.train(dataset, nb_epoch=10)
File "boss_train.py", line 143, in train
validation_data=(dataset.X_valid, dataset.Y_valid))
File "/Users/darryl/Applications/miniconda2/envs/venv/lib/python3.5/site-packages/keras/legacy/interfaces.py", line 88, in wrapper
return func(*args, **kwargs)
File "/Users/darryl/Applications/miniconda2/envs/venv/lib/python3.5/site-packages/keras/models.py", line 1107, in fit_generator
initial_epoch=initial_epoch)
File "/Users/darryl/Applications/miniconda2/envs/venv/lib/python3.5/site-packages/keras/legacy/interfaces.py", line 88, in wrapper
return func(*args, **kwargs)
File "/Users/darryl/Applications/miniconda2/envs/venv/lib/python3.5/site-packages/keras/engine/training.py", line 1914, in fit_generator
callbacks.on_epoch_end(epoch, epoch_logs)
UnboundLocalError: local variable 'epoch_logs' referenced before assignment
eventhough already have the proper images as the resource
X_train shape: (4, 64, 64, 3)
4 train samples
3 valid samples
3 test samples
Can anyone explain what had happened?
Hello! I wanted to report that I got this error too, and I've found that in my case it was (at least partially) caused by having steps_per_epoch = 0. In this case line 1852 of "training.py" fails to enter the while loop which defines 'epochs_log'.
check this issue: https://github.com/keras-team/keras/issues/450 for more details. The root cause is that steps_per_epoch = 0
, as mentioned in https://github.com/Hironsan/BossSensor/issues/17#issuecomment-312389567.
BTW, this issue has been fixed by https://github.com/keras-team/keras/pull/8854. Use the latest codes of keras shall fix this issue.