【问题标题】:LSTM Arguments modificationsLSTM 参数修改
【发布时间】:2020-08-20 19:01:17
【问题描述】:

我正在研究 LSTM 代码并试图使我的模型准确无误。我一直在尝试更改参数*以及 epoch 数和批量大小,但都是徒劳的。可能,我做错了! 有什么帮助吗?请与我分享任何可能有用的教程或指南。谢谢你

*LSTM 参数

tf.keras.layers.LSTM(
    units, activation='tanh', recurrent_activation='sigmoid', use_bias=True,
    kernel_initializer='glorot_uniform', recurrent_initializer='orthogonal',
    bias_initializer='zeros', unit_forget_bias=True, kernel_regularizer=None,
    recurrent_regularizer=None, bias_regularizer=None, activity_regularizer=None,
    kernel_constraint=None, recurrent_constraint=None, bias_constraint=None,
    dropout=0.0, recurrent_dropout=0.0, implementation=2, return_sequences=False,
    return_state=False, go_backwards=False, stateful=False, time_major=False,
    unroll=False, **kwargs
) 

【问题讨论】:

    标签: tensorflow machine-learning deep-learning lstm hyperparameters


    【解决方案1】:

    每个人都可能很难理解和使用循环神经网络。然而,它们并没有看起来那么困难。

    为了从头开始理解循环神经网络和 LSTM,我认为最好的博客是 Colah 博客。

    您还可以查看此article,它总结了 RNN 的概念。

    keras 博客中的 tutorial 可能对实现 RNN 很有用。

    最后,要理解 LSTM 层,请将它们视为一个简单的 Dense 层,units 作为层的大小。

    这些层的特别之处在于它们是如何工作的,这就是其他争论的来源。这里只放我用过的。

    units: Size of the layer
    Activation: Activation function to apply on the output of the layer
    use_bias: Boolean, decides if to use a vector for bias or not
    return_sequences: Boolean, if you have Many to One RNN set it to False, If Many to Many RNN set it to True
    

    编辑:这是我为图像分类构建的宪法循环神经网络的代码。我希望这是您正在搜索的内容。

     model = Sequential()
            model.add(Input(shape=(IMG_HEIGHT, IMG_WIDTH, 3)))
            model.add(Reshape(target_shape=(IMG_HEIGHT, IMG_WIDTH * 3)))
            model.add(Conv1D(filters=64, kernel_size=3, padding="same", activation='relu',
                             input_shape=(IMG_HEIGHT, IMG_WIDTH * 3), data_format='channels_last'))
            
            model.add(Conv1D(filters=64, kernel_size=3, padding="same", activation='relu'))
            model.add(MaxPooling1D(pool_size=3))
    
            model.add(Conv1D(filters=128, kernel_size=3, padding="same", activation='relu'))
            model.add(Conv1D(filters=128, kernel_size=3, padding="same", activation='relu'))
            model.add(LSTM(64, activation='relu'))
            model.add(BatchNormalization())
            model.add(Flatten())
            model.add(Dense(4, activation='softmax'))
            model.build(input_shape=(batch_size, IMG_HEIGHT, IMG_WIDTH, 3))
            model.summary() 
    

    我希望这会有所帮助。

    【讨论】:

    • 谢谢@Reda。我都读过了。你有任何 LSTM 实现的例子吗?
    • 您好@Giselle,抱歉回复晚了。我添加了一个为图像分类构建的 LSTM 实现示例。
    猜你喜欢
    • 1970-01-01
    • 2017-12-20
    • 2018-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-21
    相关资源
    最近更新 更多