Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
tensorflow2.0 lstm,当一个时间序列用于恢复另一个时间序列时,现在无法减少验证数据集的丢失_Tensorflow - Fatal编程技术网

tensorflow2.0 lstm,当一个时间序列用于恢复另一个时间序列时,现在无法减少验证数据集的丢失

tensorflow2.0 lstm,当一个时间序列用于恢复另一个时间序列时,现在无法减少验证数据集的丢失,tensorflow,Tensorflow,CSV有两列时间序列,这两列之间存在数学关系。当lstm使用一个时间序列恢复另一个时间序列时,无法减少验证数据集的丢失。我该怎么办 import pandas as pd dataframe = pd.read_csv('qqq.csv') dataset = dataframe.values x = dataset[:986,0] y = dataset[:986,1] print(x.shape) time_points = np.linspace(0, 1, 986) seq_l

CSV有两列时间序列,这两列之间存在数学关系。当lstm使用一个时间序列恢复另一个时间序列时,无法减少验证数据集的丢失。我该怎么办

import pandas as pd

dataframe = pd.read_csv('qqq.csv')
dataset = dataframe.values

x = dataset[:986,0]
y = dataset[:986,1]
print(x.shape)
time_points = np.linspace(0, 1, 986)   
seq_length = 50
dataX = []
dataY = []
for i in range(0, len(time_points) - seq_length, 1):
    seq_in = x[i:i + seq_length]
    seq_out = y[i+ seq_length]
    dataX.append([seq_in])
    dataY.append(seq_out)

X = np.reshape(dataX, (len(dataX), seq_length, 1)) 
Y = np.reshape(dataY, (len(dataY), 1))
print('xshape',X.shape)
print('yshape',Y.shape)

x_test = dataset[986:1286,0]
y_test = dataset[986:1286,1]
time_points_test = np.linspace(0, 1,300)
dataX_test = []
dataY_test = []
for j in range(0, len(time_points_test) - seq_length, 1):
    seq_in_test = x_test[j:j + seq_length]
    seq_out_test = y_test[j + seq_length]
    dataX_test.append([seq_in_test])
    dataY_test.append(seq_out_test)

X_test = np.reshape(dataX_test, (len(dataX_test), seq_length, 1)) #numpy as np
Y_test = np.reshape(dataY_test, (len(dataY_test), 1))

model = Sequential()
model.add(LSTM(10, input_shape=(X.shape[1], X.shape[2])))
model.add(Dropout(0.2))
model.add(Dense(1, activation='tanh'))

model.compile(loss='mse', optimizer=tf.keras.optimizers.Adam(0.005))
model.fit(X[:936], y[:936], epochs=100, batch_size=100, verbose=1, validation_split=0.3)

您好,您能否澄清一下“当一个时间序列被lstm用于恢复另一个时间序列时”的含义。谢谢我随机生成1000个数字作为X的序列,然后通过Y=X**2生成序列Y。我有两组序列。现在Y作为输入,X作为标签。我想从一个新的Y序列中恢复X的值。嗨,你能澄清一下你所说的“当一个时间序列被lstm用来恢复另一个时间序列时”是什么意思吗。谢谢我随机生成1000个数字作为X的序列,然后通过Y=X**2生成序列Y。我有两组序列。现在Y作为输入,X作为标签。我想从新的Y序列中恢复X的值。