LSTM-Neural-Network-for-Time-Series-Prediction
LSTM-Neural-Network-for-Time-Series-Prediction copied to clipboard
Reason of the question"StopIteration"
In the founction "generate_train_batch" belong to dara_processor.py. i = 0 while i < (self.len_train - seq_len): x_batch = [] y_batch = [] for b in range(batch_size): if i >= (self.len_train - seq_len): # stop-condition for a smaller final batch if data doesn't divide evenly yield np.array(x_batch), np.array(y_batch) i = 0 x, y = self._next_window(i, seq_len, normalise) x_batch.append(x) y_batch.append(y) i += 1 yield np.array(x_batch), np.array(y_batch)
sometimes, i==self.len_train-seq_len. So it cannot satisfy the while loop .
Is this the intent of the author or a bug in the program
If I want to iterate more times to better train the model, how can I improve the problem
Maybe this is a small mistake. Perhaps you can refer to the following modification code:
def generate_train_batch(self, seq_len, batch_size, normalise):
'''Yield a generator of training data from filename on given list of cols split for train/test'''
i = 0
x_batch = []
y_batch = []
# while i < (self.len_train - seq_len):
while True:
for b in range(batch_size):
x, y = self._next_window(i, seq_len, normalise)
x_batch.append(x)
y_batch.append(y)
i += 1
if i == (self.len_train - seq_len):
# stop-condition for a smaller final batch if data doesn't divide evenly
i = 0
yield np.array(x_batch), np.array(y_batch)
x_batch = []
y_batch = []
OK, thanks very much👍
在 2020年5月3日,下午9:22,shenjian5 [email protected] 写道:
Maybe this is a small mistake. Perhaps you can refer to the following modification code:
def generate_train_batch(self, seq_len, batch_size, normalise): '''Yield a generator of training data from filename on given list of cols split for train/test''' i = 0 x_batch = [] y_batch = [] # while i < (self.len_train - seq_len): while True: for b in range(batch_size): x, y = self._next_window(i, seq_len, normalise) x_batch.append(x) y_batch.append(y) i += 1 if i == (self.len_train - seq_len): # stop-condition for a smaller final batch if data doesn't divide evenly i = 0 yield np.array(x_batch), np.array(y_batch) x_batch = [] y_batch = [] — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
尊敬的人资负责人: 您好! 我想咨询一下关于暑期实习的问题,我是一名本科应届毕业生,目前已保送至中科大读研,希望通过实习来开拓视野,长长见识。请问这种情况有没有在今年暑期获取华为实习的机会呢,主要考虑技术研发岗位。
| | HITWH LIZHOGN | | [email protected] | 签名由网易邮箱大师定制
@shenjian5 It works for me.Thanks~!