Python 如何为LSTM填充帧的输入序列?
我正在使用CNN+LSTM架构对人类意识水平进行分类。我一直在尝试将我的数据集填充到每5秒拍摄的帧中 共有3类0、5和10(意识范围)和180个视频,我:Python 如何为LSTM填充帧的输入序列?,python,tensorflow,keras,deep-learning,Python,Tensorflow,Keras,Deep Learning,我正在使用CNN+LSTM架构对人类意识水平进行分类。我一直在尝试将我的数据集填充到每5秒拍摄的帧中 共有3类0、5和10(意识范围)和180个视频,我: 转换为帧 旋转它们以确保所有面都是垂直的 从帧中提取面 将每个类中的所有帧组合到一个新文件夹中(例如,类10的所有帧组合在一起,每个类几乎完全平衡,只有一个类的帧比其他类少1%) 将其分为训练(95%)、验证(5%)和测试(5%) 从目录获取列车数据集: #BATCH_SIZE = 32 #SIZE = (224,224) #SEED = 4
#BATCH_SIZE = 32
#SIZE = (224,224)
#SEED = 42
train_dataset = image_dataset_from_directory(
directory=TRAIN_DIR,
labels="inferred",
label_mode="int",
class_names=["0", "10", "5"],
batch_size=BATCH_SIZE,
image_size=SIZE,
seed=SEED,
subset=None,
interpolation="bilinear",
follow_links=False,
)
因此,我需要在将帧发送到CNN+LSTM之前填充帧,以确保它们的大小一致
train_dataset = sequence.pad_sequences(train_dataset, maxlen=BATCH_SIZE, padding="post", truncating="post")
# Dataset shape
<BatchDataset shapes: ((None, None, 224, 224, 3), (None, None)), types: (tf.float32, tf.int32)>
InvalidArgumentError: assertion failed: [Unable to decode bytes as JPEG, PNG, GIF, or BMP]
[[{{node decode_image/cond_jpeg/else/_1/decode_image/cond_jpeg/cond_png/else/_20/decode_image/cond_jpeg/cond_png/cond_gif/else/_39/decode_image/cond_jpeg/cond_png/cond_gif/Assert/Assert}}]] [Op:IteratorGetNext]