【问题标题】:Time Series data to fit for ConvLSTM适合 ConvLSTM 的时间序列数据
【发布时间】:2022-08-02 23:23:49
【问题描述】:

我使用了 4057 个样本的股票数据,将其分为 28 个时间步长,具有 25 个特征。

TrainX shape: (4057, 28, 25)

Target由5类整数组成

[0,1,2,3,4]

并重塑为:

trainX_reshape= trainX.reshape(4057,1, 28,25,1)
testX_reshape= testX.reshape(1334,1, 28,25,1)

试图拟合模型:

seq =Sequential([
    ConvLSTM2D(filters=40, kernel_size=(3, 3),input_shape=(1, 28, 25, 1),padding=\'same\', return_sequences=True),
    BatchNormalization(),
    ConvLSTM2D(filters=40, kernel_size=(3, 3),padding=\'same\', return_sequences=True),
    BatchNormalization(),
    ConvLSTM2D(filters=40, kernel_size=(3, 3),padding=\'same\', return_sequences=True),
    BatchNormalization(),
    ConvLSTM2D(filters=40, kernel_size=(3, 3),padding=\'same\', return_sequences=True),
    BatchNormalization(),
    Conv3D(filters=5, kernel_size=(3, 3, 3),activation=\'sigmoid\',padding=\'same\', data_format=\'channels_last\')
])

编译

seq.compile(loss=\'sparse_categorical_crossentropy\', optimizer=\'rmsprop\')

history = seq.fit(trainX_reshape, trainY, epochs=10,
               batch_size= 128, shuffle=False, verbose = 1,
               validation_data=(testX_reshape, testY),
               # validation_split=0.2)

它给出了错误:

InvalidArgumentError: Graph execution error:

如何解决?我尝试了很多方法,但没有任何线索。

代码和数据位于: https://drive.google.com/drive/folders/1WDa_CUO1Mr7wZTqE3wHsR0Tp_3NRMcZ6?usp=sharing

在 colab 上工作

    标签: python tensorflow keras


    【解决方案1】:

    如果您使用稀疏整数标签,则模型的输出没有任何意义。尝试:

    seq =Sequential([
        ConvLSTM2D(filters=40, kernel_size=(3, 3),input_shape=(1, 28, 25, 1),padding='same', return_sequences=True),
        BatchNormalization(),
        ConvLSTM2D(filters=40, kernel_size=(3, 3),padding='same', return_sequences=True),
        BatchNormalization(),
        ConvLSTM2D(filters=40, kernel_size=(3, 3),padding='same', return_sequences=True),
        BatchNormalization(),
        ConvLSTM2D(filters=40, kernel_size=(3, 3),padding='same', return_sequences=True),
        BatchNormalization(),
        Conv3D(filters=5, kernel_size=(3, 3, 3),padding='same', data_format='channels_last'),
        GlobalMaxPooling3D(),
        Dense(5, activation='softmax')
    ])
    

    【讨论】:

      猜你喜欢
      • 2018-12-24
      • 2023-01-24
      • 2016-04-08
      • 1970-01-01
      • 1970-01-01
      • 2017-03-07
      • 2015-01-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多