Home>

It is assumed that 3DCNN is implemented using keras to automatically classify videos.
The model is built with keras, and the generator is self-made.
The environment uses google colab.

After that, it was in a state to just learn, so when I started learning with fit_generator (), the following error statement appeared.
I don't know why the input was suddenly different on 6/165 even though I was already learning halfway.
Please give me some advice.

Error message
6/165 [>.............................]-ETA: 7:57-loss: 16.1181-acc: 0.0000e + 00Traceback (most recent call last):
 File "main.py", line 64, in<module>
    epochs = 1)
...
...
...
ValueError: Error when checking input: expected conv3d_1_input to have 5 dimensions, but got array with shape (8, 1)
Applicable source code
validation_ratio = 0.3
num_sample = len (lists)
sample_idxs = range (0, num_sample)
sample_idxs = np.random.permutation (sample_idxs)
train_sample_idx = sample_idxs [0: int ((1-validation_ratio) * num_sample)]
valid_sample_idx = sample_idxs [int ((1-validation_ratio) * num_sample):]
train_generator = video_generator.generate_train_from_directory (8, 'data', train_sample_idx)
valid_generator = video_generator.generate_valid_from_directory (8, 'data', valid_sample_idx)
model = C3d_model.get_model (summary = True)
print ("Start learning")
history = model.fit_generator (train_generator, steps_per_epoch = len (train_sample_idx)/8,
                                epochs = 1)
acc = model.evaluate_generator (valid_generator, steps = 10,
                                verbos = 1)
print ("loss:", acc [0])
print ("accuracy:", acc [1])

I tried to reduce the calculation load once by changing the batch size from 32 to 8.

Supplemental information (FW/tool version etc.)

Please provide more detailed information here.

  • Answer # 1

    Maybe one of the samples loaded in the 6th iteration does not match the shape of the model input?
    The number of frames is different from the others, the size of the frames is different from the others, etc.

  • Answer # 2

    The input of conv3d_1 needs to be five dimensions, but this time it is (8,1) Two-dimensional array? That ’s why it ’s not good.
    It would be good to examine and improve the shape of the input data.