LSTM参数修改

我正在处理LSTM代码,试图提高模型的准确性。我尝试更改参数*、epochs数量和batch大小,但都没有效果。可能是我做错了!有什么建议吗?请分享任何有帮助的教程或指南。谢谢

*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) 

回答:

每个人在理解和使用循环神经网络时可能都会遇到困难。然而,它们实际上并不像看起来那么难。

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

你还可以查看这篇文章,它总结了RNN的概念。

Keras博客中的这个教程可能对实现RNN有帮助。

最后,要理解LSTM层,可以将其视为一个简单的Dense层,其中units是层的大小。

这些层的特别之处在于它们的工作方式,这就是其他参数的作用所在。这里我只列出我用过的参数。

units: 层的大小Activation: 应用于层输出的激活函数use_bias: 布尔值,决定是否使用偏置向量return_sequences: 布尔值,如果你有Many to One RNN,设为False;如果是Many to Many RNN,设为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() 

希望这对你有帮助。

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注