我正在使用张量流预测不同时间段的财务时间序列。为了划分输入数据,我制作了子样本并用于循环。但是,我遇到了这样的ValueError;
ValueError:变量rnn / basic_lstm_cell / weights已经存在,不允许使用。您是要在VarScope中设置“ reuse = True”吗?最初定义为:
没有子样本,此代码可以很好地工作。下面是我的代码。
import tensorflow as tf
import numpy as np
import matplotlib
import os
import matplotlib.pyplot as plt
class lstm:
def __init__(self, x, y):
# train Parameters
self.seq_length = 50
self.data_dim = x.shape[1]
self.hidden_dim = self.data_dim*2
self.output_dim = 1
self.learning_rate = 0.0001
self.iterations = 5 # originally 500
def model(self,x,y):
# build a dataset
dataX = []
dataY = []
for i in range(0, len(y) - self.seq_length):
_x = x[i:i + self.seq_length] …Run Code Online (Sandbox Code Playgroud)