error.append(function_vector(np.array(train_inputs[len(train_inputs)-1-i]))* hidden_layers_weights[len(train_outputs)-i].T.dot(error[i-1]))
时间: 2024-02-05 16:11:25 浏览: 82
这段代码中有一个错误,应该是 `train_outputs` 而不是 `train_inputs`。修改后的代码如下:
```
error.append(function_vector(np.array(train_outputs[len(train_outputs)-1-i]))* hidden_layers_weights[len(train_outputs)-i].T.dot(error[i-1]))
```
相关问题
for i in range(len(train_data) - seq_len - pre_len): train_X.append(np.array(train_data[i : i + seq_len])) train_Y.append(np.array(train_data[i + seq_len : i + seq_len + pre_len]))
对于这段代码,它是指对训练数据进行切片处理,其中train_data是数据集,seq_len是序列长度,pre_len是预测长度。代码通过循环遍历数据集,每次提取一个序列(长度为seq_len),并将其作为训练输入(train_X),同时提取下一个序列(从i+seq_len开始,长度为pre_len),将其作为训练标签(train_Y)。这样就可以将数据处理为模型所需的输入和输出。
train_x, train_y = [], [] for i in range(look_back, len(train_data)): x = [] for j in range(len(svr_models)): x.append(svr_models[j].predict(np.reshape(low_freq_imfs.iloc[i-look_back:i, j].values, (1, -1)))[0]) x.append(lstm_model.predict(np.reshape(high_freq_imfs.iloc[i-look_back:i, :].values, (1, look_back, -1)))[0]) train_x.append(x) train_y.append(train_data.iloc[i, 1]) train_x, train_y = np.array(train_x), np.array(train_y) stack_model = SVR(kernel='rbf', C=100, gamma=0.1, epsilon=.1) stack_model.fit(train_x, train_y) 将以上代码按规范排列,突出显示缩进情况
```
train_x, train_y = [], []
for i in range(look_back, len(train_data)):
x = []
for j in range(lenvr_models)):
x.append(svr_models[j].predict(np.reshape(low_freq_imfs.iloc[i-look_back:i, j].values, (1, -1)))[0])
x.append(lstm_model.predict(np.reshape(high_freq_imfs.iloc[i-look_back:i, :].values, (1, look_back, -1)))[0])
train_x.append(x)
train_y.append(train_data.iloc[i, 1])
train_x, train_y = np.array(train_x), np.array(train_y)
stack_model = SVR(kernel='rbf', C=100, gamma=0.1, epsilon=.1)
stack_model.fit(train_x, train_y)
```
阅读全文