harvitronix / five-video-classification-methods

Code that accompanies my blog post outlining five video classification methods in Keras and TensorFlow
https://medium.com/@harvitronix/five-video-classification-methods-implemented-in-keras-and-tensorflow-99cad29cc0b5
MIT License
1.18k stars 478 forks source link

Error in train.py #76

Closed moonikwe closed 6 years ago

moonikwe commented 6 years ago

I ran train.py and this is what I got

Using TensorFlow backend.
2018-02-27 12:22:38.975784: I C:\tf_jenkins\home\workspace\rel-win\M\windows\PY\36\tensorflow
\core\platform\cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow
binary was not compiled to use: AVX AVX2
Loading LSTM model.
_________________________________________________________________
Layer (type)                 Output Shape              Param #
=================================================================
lstm_1 (LSTM)                (None, 2048)              33562624
_________________________________________________________________
dense_1 (Dense)              (None, 512)               1049088
_________________________________________________________________
dropout_1 (Dropout)          (None, 512)               0
_________________________________________________________________
dense_2 (Dense)              (None, 14)                7182
=================================================================
Total params: 34,618,894
Trainable params: 34,618,894
Non-trainable params: 0
_________________________________________________________________
None
Creating train generator with 850 samples.
Epoch 1/1000
Exception in thread Thread-2:
Traceback (most recent call last):
  File "C:\Users\Munic\AppData\Local\Programs\Python\Python36\lib\threading.py", line 916, in
 _bootstrap_inner
    self.run()
  File "C:\Users\Munic\AppData\Local\Programs\Python\Python36\lib\threading.py", line 864, in
 run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\Munic\AppData\Local\Programs\Python\Python36\lib\site-packages\keras\utils\d
ata_utils.py", line 579, in data_generator_task
    generator_output = next(self._generator)
  File "C:\Users\Munic\Documents\Popping-Dance-Style-Classification\data.py", line 25, in __n
ext__
    return next(self.iterator)
  File "C:\Users\Munic\Documents\Popping-Dance-Style-Classification\data.py", line 191, in fr
ame_generator
    y.append(self.get_class_one_hot(sample[1]))
  File "C:\Users\Munic\Documents\Popping-Dance-Style-Classification\data.py", line 103, in ge
t_class_one_hot
    assert len(label_hot) == len(self.classes)
AssertionError

Traceback (most recent call last):
  File "C:\Users\Munic\Documents\Popping-Dance-Style-Classification\train.py", line 110, in <
module>
    main()
  File "C:\Users\Munic\Documents\Popping-Dance-Style-Classification\train.py", line 107, in m
ain
    load_to_memory=load_to_memory, batch_size=batch_size, nb_epoch=nb_epoch)
  File "C:\Users\Munic\Documents\Popping-Dance-Style-Classification\train.py", line 81, in tr
ain
    workers=4)
  File "C:\Users\Munic\AppData\Local\Programs\Python\Python36\lib\site-packages\keras\legacy\
interfaces.py", line 87, in wrapper
    return func(*args, **kwargs)
  File "C:\Users\Munic\AppData\Local\Programs\Python\Python36\lib\site-packages\keras\models.
py", line 1156, in fit_generator
    initial_epoch=initial_epoch)
  File "C:\Users\Munic\AppData\Local\Programs\Python\Python36\lib\site-packages\keras\legacy\
interfaces.py", line 87, in wrapper
    return func(*args, **kwargs)
  File "C:\Users\Munic\AppData\Local\Programs\Python\Python36\lib\site-packages\keras\engine\
training.py", line 2046, in fit_generator
    generator_output = next(output_generator)
StopIteration

What could have went wrong?

harvitronix commented 6 years ago

Is this on your own dataset? The assertion error in data.py on line 103 seems to be the problem. Make sure you've set your number of classes to be equal to the list of classes in your dataset. If you can post more information about your dataset, I can probably help further.

huawang123 commented 6 years ago

you only need to fix assert len(label_hot) == len(self.classes) return label_hot as assert len(label_hot[0]) == len(self.classes) return label_hot[0] hope it works for you!

13293824182 commented 6 years ago

I am using your data and code, why is the same problem? i hope you answer.

huawang123 commented 6 years ago

chinese? ------------------ 原始邮件 ------------------ 发件人: "13293824182"notifications@github.com; 发送时间: 2018年6月29日(星期五) 晚上10:43 收件人: "harvitronix/five-video-classification-methods"five-video-classification-methods@noreply.github.com; 抄送: "JUST FOR YOU"752448068@qq.com; "Comment"comment@noreply.github.com; 主题: Re: [harvitronix/five-video-classification-methods] Error in train.py(#76)

I am using your data and code, why is the same problem? i hope you answer.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.