机器学习杂文

多通道cnn+lstm+dense复杂网络测试(附单通道效果对比

2019-10-22  本文已影响0人  yangy_fly

网络结构

# 定义多通道特征组合模型
def build_multi_cr_lstm_model(ts, fea_dim):

    # 定义输入
    inputs = Input(shape = (ts, fea_dim))

    # ########################################
    # cnn层&lstm层1
    cnn_left_out1 = Conv1D(filters=50, kernel_size=6, strides=3, kernel_initializer=he_normal(seed=3))(inputs)
    act_left_out1 = LeakyReLU()(cnn_left_out1)

    lstm_left_out1 = LSTM(64, activation='sigmoid', dropout=0.1, return_sequences=False, 
                         kernel_initializer=he_normal(seed=10))(act_left_out1)

    # #########################################
    # cnn层&lstm层2
    cnn_right_out1 = Conv1D(filters=50, kernel_size=12, strides=3, kernel_initializer=he_normal(seed=3))(inputs)
    act_right_out1 = LeakyReLU()(cnn_right_out1)

    lstm_right_out1 = LSTM(64, activation='sigmoid', dropout=0.1, return_sequences=False, 
                         kernel_initializer=he_normal(seed=10))(act_right_out1)
    
    # #########################################
    # cnn层&lstm层3
    cnn_mid_out1 = Conv1D(filters=50, kernel_size=6, strides=2, kernel_initializer=he_normal(seed=3))(inputs)
    act_mid_out1 = LeakyReLU()(cnn_mid_out1)

    lstm_mid_out1 = LSTM(64, activation='sigmoid', dropout=0.1, return_sequences=False, 
                         kernel_initializer=he_normal(seed=10))(act_mid_out1)

    # ############################################
    # 上层叠加新的dense层
    concat_output = Concatenate(axis=1)([lstm_left_out1, lstm_mid_out1, lstm_right_out1])
    outputs = Dense(1)(concat_output)
    model_func = Model(inputs=inputs, outputs=outputs)
    model_func.compile(loss='mse', optimizer=Adam(lr=0.002, decay=0.01), metrics=['mse'])
    
    return model_func

image.png

预测结果与上面文章中结果的对比

可见复杂网络的效果提升极为明显,mse降低了足足50%,但是多通道相对单通道的提升相对较少。若追求时间性能,可能多数情况下cnn+lsmt+dense的单通道已经能够满足需求

效果提升的原因猜想

拟合曲线对比

image.png image.png

思考

针对不同的数据,如何应用相同的复杂网络,这是下一步需要思考的问题。以及attention的引入

上一篇下一篇

猜你喜欢

热点阅读