简体   繁体   English

我正在为时间序列中的谓词值写 neural-network

[英]I am writing neural-network for predicate value in the time series

dear friends!亲爱的朋友们!

At this moment I am trying to write code of Neural-network in keras, which will predict some value in time series.目前我正在尝试在 keras 中编写 Neural-network 的代码,这将预测时间序列中的一些值。 The time series have form like "0...0 N 0...0 N 0...0", where number of zeros between N's is the same.时间序列的形式类似于“0...0 N 0...0 N 0...0”,其中 N 之间的零数相同。

For this target i am using LSTM-layers.对于这个目标,我正在使用 LSTM 层。 I've been struggling with this task for over a week, but my network is really bad now我已经为这个任务苦苦挣扎了一个多星期,但我的网络现在真的很糟糕

For this target i am using LSTM-layers.对于这个目标,我正在使用 LSTM 层。 I've been struggling with this task for over a week, but my network is really bad yet (loss are very big and they aren't reduced during fit)我已经为这项任务苦苦挣扎了一个多星期,但是我的网络还很糟糕(损失非常大,并且在适应期间并没有减少)

Mo model looks like莫 model 看起来像

model =  Sequential()

model.add(LSTM(60, activation = softplus, use_bias = True, return_sequences = True, input_shape = (1, sample)))

model.add(LSTM(60, activation = softplus, use_bias = True, return_sequences = True))

model.add(LSTM(60, activation = softplus, use_bias = True))

model.add(Dropout(0.05))

model.add(Dense(1))

model.compile(loss = 'MSE',
              optimizer = 'RMSProp',
              metrics = ['accuracy', 'mae'])
model.fit(
        x = trainX, y = trainY, 
        batch_size = batch_size, 
        epochs = 1000,
        shuffle=True,
        validation_data=(testX, testY),
        callbacks = [cp_callback])

What wrong with this code?这段代码有什么问题? And what should I do to make my network better?我应该怎么做才能使我的网络更好?

Thank you for answer!谢谢你的答案!

Ps: I am really new in Neural Networks, so I am really sorry if my question is stupid. Ps:我是神经网络的新手,如果我的问题很愚蠢,我真的很抱歉。 And sorry for my English too:)也对不起我的英语:)

You might want to try simplifying the network, also scaling the input down from 1000 to 1 might help.您可能想尝试简化网络,将输入从 1000 缩小到 1 可能会有所帮助。 I created a simplified network which has good accuracy which might help point you in the right direction.我创建了一个简化的网络,该网络具有良好的准确性,可能有助于为您指明正确的方向。 I hope this helps.我希望这有帮助。

from keras.models import Sequential
from keras.layers import LSTM, Dense
import numpy as np

data_dim = 1
timesteps = 11

# expected input data shape: (batch_size, timesteps, data_dim)
model = Sequential()
model.add(LSTM(4, input_shape=(timesteps, data_dim)))  # returns a sequence of vectors of dimension 4
model.add(Dense(2))
model.add(Dense(1))

model.compile(loss='mse',
              optimizer='rmsprop',
              metrics=['accuracy'])

# Generate dummy training data

x_train = np.array([[0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0],
                    [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0]])
x_train = np.expand_dims(x_train,axis=2)
y_train = np.array([[1], [0]])

model.summary()

print(x_train.shape)
print(y_train.shape)

model.fit(x_train, y_train, batch_size=2, epochs=200)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 python中的神经网络非线性时间序列Narx模型 - neural-network non linear time series Narx model in python 我每次在神经网络中都获得1.0的准确度 - I am getting an accuracy of 1.0 every time in neural network 无法弄清楚将浮点数或整数输入到我的神经网络中 - Cannot figure out inputting floats or integers into my neural-network 用于温度时间序列预测的 LSTM 神经网络 - LSTM Neural Network for temperature time series predictions 简单的神经网络,可以将输入变量的总和作为Python输出? - Simple Neural-Network that gives the summation of the input variables as output in Python? 完全相同的神经网络代码产生不同的结果 - Exact same neural-network code producing different results 哪种神经网络解决方案适合于延迟的时间序列回归? - What Neural Network solution(s) are appropriate for time series regression with delays? 使用深度神经网络对时间序列数据进行 Keras 回归 model - Making Keras regression model with time series data with Deep Neural Network 为什么我在这个神经网络中接收 2 个值的 2 值元组上出现值错误? - Why am I getting a value error on a 2 Valued tuple receiving 2 values in this neural network? 神经网络的传播模型(我是初学者) - propagation model using neural network (I am beginner)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM