简体   繁体   English

ValueError: 层序列 10 的输入 0 与层不兼容:预期 ndim=5,发现 ndim=4。 Alexnet(cnn) + LSTM

[英]ValueError: Input 0 of layer sequential_10 is incompatible with the layer: expected ndim=5, found ndim=4. Alexnet(cnn) + LSTM

currently making human action recognition to detect a cheating kind on exam from CCTV using AlexNet+LSTM目前正在使用 AlexNet+LSTM 进行人体动作识别,以检测 CCTV 考试中的作弊类型

My Data are raw image in a each class folder with like this我的数据是每个类文件夹中的原始图像,如下所示

but i got error like this但我有这样的错误

ValueError: in user code:值错误:在用户代码中:

/usr/local/lib/python3.7/dist-packages/keras/engine/training.py:830 train_function  *
    return step_function(self, iterator)
/usr/local/lib/python3.7/dist-packages/keras/engine/training.py:813 run_step  *
    outputs = model.train_step(data)
/usr/local/lib/python3.7/dist-packages/keras/engine/training.py:770 train_step  *
    y_pred = self(x, training=True)
/usr/local/lib/python3.7/dist-packages/keras/engine/base_layer.py:989 __call__  *
    input_spec.assert_input_compatibility(self.input_spec, inputs, self.name)
/usr/local/lib/python3.7/dist-packages/keras/engine/input_spec.py:212 assert_input_compatibility  *
    raise ValueError('Input ' + str(input_index) + ' of layer ' +

ValueError: Input 0 of layer sequential_10 is incompatible with the layer: expected ndim=5, found ndim=4. Full shape received: (None, None, None, None)

The error come when i do the model.fit当我做 model.fit 时出现错误

from what i read it said that the problem at the input_shape but i am still doesnt found the solution of my problem the link of my code at colab can be found here ,从我读到的内容来看,input_shape 出现了问题,但我仍然没有找到问题的解决方案,可以在此处找到我在 colab 上的代码链接,

i still dont understand what is the problem, i check the documentation for input_shape in TimeDistributed and it's the same for (timeSteps, height, width, channels)我仍然不明白是什么问题,我检查了 TimeDistributed 中 input_shape 的文档,它与(时间步长、高度、宽度、通道)相同

is it from my ImageDataGenerator?or did i do wrong on making my model?是来自我的 ImageDataGenerator?还是我在制作模型时做错了?

i would appreciate if anybody have the experience in this matter and try to help my problem如果有人有这方面的经验并尝试解决我的问题,我将不胜感激

Thank you so much !非常感谢 !

As error message says expected dimension 5D but received 4D input.由于错误消息显示预期尺寸为 5D,但收到 4D 输入。 Time distributed layer expects input of shape 5D.时间分布层需要形状为 5D 的输入。

Working sample code:工作示例代码:

Consider a batch of 32 video samples, where each sample is a 128x128 RGB image with channels_last data format, across 10 timesteps.考虑一批 32 个视频样本,其中每个样本是 128x128 RGB 图像,具有 channels_last 数据格式,跨越 10 个时间步。 The batch input shape is (32, 10, 128, 128, 3) .批量输入形状为(32, 10, 128, 128, 3)

inputs = tf.keras.Input(shape=(10, 128, 128, 3))
conv_2d_layer = tf.keras.layers.Conv2D(64, (3, 3))
outputs = tf.keras.layers.TimeDistributed(conv_2d_layer)(inputs)

Output:输出:

TensorShape([None, 10, 126, 126, 64])

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ValueError:层 sequential_16 的输入 0 与层不兼容:预期 ndim=5,发现 ndim=4。 收到的完整形状:[无,224、224、3] - ValueError: Input 0 of layer sequential_16 is incompatible with the layer: expected ndim=5, found ndim=4. Full shape received: [None, 224, 224, 3] lstm_5层的输入0与层不兼容:预期ndim=3,发现ndim=2 - Input 0 of layer lstm_5 is incompatible with the layer: expected ndim=3, found ndim=2 ValueError:层顺序的输入 0 与层不兼容::预期 min_ndim=3,发现 ndim=2。 收到的完整形状:(10, 24) - ValueError: Input 0 of layer sequential is incompatible with the layer: : expected min_ndim=3, found ndim=2. Full shape received: (10, 24) ValueError: 层 lstm 的输入 0 与层不兼容:预期 ndim=3,发现 ndim=2。 收到的完整形状:[无,18] - ValueError : Input 0 of layer lstm is incompatible with the layer: expected ndim=3, found ndim=2. Full shape received: [None, 18] ValueError:层顺序的输入 0 与层不兼容:预期 ndim=4,发现 ndim=3。 收到的完整形状:[32, 64, 3] - ValueError: Input 0 of layer sequential is incompatible with the layer: expected ndim=4, found ndim=3. Full shape received: [32, 64, 3] Keras:ValueError:输入 0 层序列_1 与层不兼容:预期 ndim=3,发现 ndim=2 - Keras: ValueError: Input 0 of layer sequential_1 is incompatible with the layer: expected ndim=3, found ndim=2 ValueError: 层序的输入 0 与层不兼容:预期 ndim=3,发现 ndim=2。 收到的完整形状:(57, 1) - ValueError: Input 0 of layer sequential is incompatible with the layer: expected ndim=3, found ndim=2. Full shape received: (57, 1) ValueError:层顺序的输入0与层不兼容::预期的min_ndim = 4,发现ndim = 3 - ValueError: Input 0 of layer sequential is incompatible with the layer: : expected min_ndim=4, found ndim=3 Keras Conv1D ValueError:层顺序的输入 0 与层不兼容::预期 min_ndim=3,发现 ndim=2 - Keras Conv1D ValueError: Input 0 of layer sequential is incompatible with the layer: : expected min_ndim=3, found ndim=2 ValueError: 层序号_9 的输入 0 与层不兼容:预期 ndim=3,发现 ndim=2 - ValueError: Input 0 of layer sequential_9 is incompatible with the layer: expected ndim=3, found ndim=2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM