gpt4 book ai didi

python - 用于图像预测的 ConvLSTM 模型的输入形状

转载 作者:行者123 更新时间:2023-11-30 09:04:29 25 4
gpt4 key购买 nike

我正在尝试使用 ConvLSTM 模型进行图像预测。但我无法理解应该输入神经网络的数据集。

我在网上搜索了一些例子,比如“使用ConvLSTM进行降水预测”以及其他一些使用ConvLSTM模型进行预测的模型。对于第一次试验,我选择了降水问题中提供的模型,以便了解该模型对我的数据集有何 react 。

def fn_get_model_convLSTM_tframe_5():

model = Sequential()
model.add(ConvLSTM2D(filters=64, kernel_size=(7, 7),
input_shape=(None, 101, 101, 1), padding='same', return_sequences=True,
activation='tanh', recurrent_activation='hard_sigmoid',
kernel_initializer='glorot_uniform', unit_forget_bias=True,
dropout=0.3, recurrent_dropout=0.3, go_backwards=True ))
model.add(BatchNormalization())

model.add(ConvLSTM2D(filters=32, kernel_size=(7, 7), padding='same', return_sequences=True,
activation='tanh', recurrent_activation='hard_sigmoid',
kernel_initializer='glorot_uniform', unit_forget_bias=True,
dropout=0.4, recurrent_dropout=0.3, go_backwards=True ))
model.add(BatchNormalization())

model.add(ConvLSTM2D(filters=32, kernel_size=(7, 7), padding='same', return_sequences=True,
activation='tanh', recurrent_activation='hard_sigmoid',
kernel_initializer='glorot_uniform', unit_forget_bias=True,
dropout=0.4, recurrent_dropout=0.3, go_backwards=True ))
model.add(BatchNormalization())


model.add(ConvLSTM2D(filters=32, kernel_size=(7, 7), padding='same', return_sequences=False,
activation='tanh', recurrent_activation='hard_sigmoid',
kernel_initializer='glorot_uniform', unit_forget_bias=True,
dropout=0.4, recurrent_dropout=0.3, go_backwards=True ))
model.add(BatchNormalization())

model.add(Conv2D(filters=1, kernel_size=(1, 1),
activation='sigmoid',
padding='same', data_format='channels_last'))

print(model.summary())
return model

完整代码可以在这里找到: https://github.com/TeaPearce/precipitation-prediction-convLSTM-keras/blob/master/precip_v09.py

  As I understood the image fed into the model had the shape of 101x101 with 4 color channels. The same is the case for my dataset (I am not giving all the details regarding my dataset as I am quite sure ConvLSTM model is suitable for my dataset and for running out of redundant discussion). 

I have the images of size 35x45 with four color channels. In total, I have 35 sequences and each sequence contains 140 sequential images. Additionally I have 1 more sequence on which I should do prediction as it contains 120 images (I need to fulfill it till the 140) I have tried to reshape my dataset and fit it into array of size (35, 140, 35, 45, 4). So know I have array so called trainx for training dataset. But the thing is that I am confused about the labels that I should provide (Even I am not sure whether I should provide or not as we are talking about sequential images).

Can anyone please help me on preparing this dataset for neural network and explain the datashape that I should provide clearly

最佳答案

input_shape=(无, 101, 101, 1)

输入形状为 101x101,具有 1 个 channel

如果您有 4 channel 的图像,请将输入形状设为 (None, 101, 101, 4)

关于python - 用于图像预测的 ConvLSTM 模型的输入形状,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56119439/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com