使用LSTM神经网络预测天然气价格

时间:2018-11-15 18:03:29

标签: keras neural-network regression lstm prediction

我想用Keras建立一个模型来预测天然气的价格。 该数据集包含自1997年以来每日和每月的天然气价格,并且可以Here使用。

下图显示了几天内的价格。 X是天,Y是价格。

enter image description here

我已经尝试过在隐藏层中使用4,50,100单元的LSTM,但准确性仍然不错,并且该模型无法预测未来的价格。 我添加了另外两个具有100和128单元格的隐藏层(完全连接),但是它也无法正常工作。

这是模型和结果表格的训练过程:

num_units = 100
activation_function = 'sigmoid'
optimizer = 'adam'
loss_function = 'mean_squared_error'
batch_size = 5
num_epochs = 10
log_file_name = f"{SEQ_LEN}-SEQ-{1}-PRED-{int(time.time())}"

# Initialize the model (of a Sequential type)
model = Sequential()

# Adding the input layer and the LSTM layer
model.add(LSTM(units = num_units, activation = activation_function,input_shape=(None, 1)))

# Adding the output layer
model.add(Dense(units = 1))

# Compiling the RNN
model.compile(optimizer = optimizer, loss = loss_function, metrics=['accuracy'])

# Using the training set to train the model
history = model.fit(train_x, train_y, batch_size = batch_size, epochs =num_epochs,validation_data=(test_x, test_y))

,输出为:

  

对4362个样本进行训练,对1082个样本进行验证

     

史诗1/10   4362/4362 [==============================]-11s 3ms / step-损耗:0.0057-acc:2.2925e- 04-val_loss:0.0016-val_acc:0.0018

     

史诗2/10   4362/4362 [==============================]-9s 2ms / step-损耗:6.2463e-04-acc: 4.5851e-04-val_loss:0.0013-val_acc:0.0018

     

史诗3/10   4362/4362 [==============================]-9s 2ms / step-损耗:6.1073e-04-acc: 2.2925e-04-val_loss:0.0014-val_acc:0.0018

     

史诗4/10   4362/4362 [==============================]-8s 2ms / step-损耗:5.4403e-04-acc: 4.5851e-04-val_loss:0.0014-val_acc:0.0018

     

史诗5/10   4362/4362 [==============================]-7s 2ms / step-损耗:5.4765e-04-acc: 4.5851e-04-val_loss:0.0012-val_acc:0.0018

     

史诗6/10   4362/4362 [==============================]-8s 2ms / step-损耗:5.1991e-04-acc: 4.5851e-04-val_loss:0.0013-val_acc:0.0018

     

史诗7/10   4362/4362 [==============================]-7s 2ms / step-损耗:5.7324e-04-acc: 2.2925e-04-val_loss:0.0011-val_acc:0.0018

     

史诗8/10   4362/4362 [==============================]-7s 2ms / step-损耗:4.4248e-04-acc: 4.5851e-04-val_loss:0.0011-val_acc:0.0018

     

史诗9/10   4362/4362 [==============================]-7s 2ms / step-损耗:4.3868e-04-acc: 4.5851e-04-val_loss:0.0011-val_acc:0.0018

     

Epoch 10/10   4362/4362 [==============================]-7s 2ms / step-损耗:4.6654e-04-acc: 4.5851e-04-val_loss:0.0011-val_acc:0.0018

如何知道此类问题的层数和单元数?任何人都可以提出可以解决此问题的netwrok结构吗?

0 个答案:

没有答案
相关问题