LSTM-Neural-Network-for-Time-Series-Prediction icon indicating copy to clipboard operation
LSTM-Neural-Network-for-Time-Series-Prediction copied to clipboard

Reason of the question"StopIteration"

Open GrayPaul opened this issue 5 years ago • 6 comments

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 .

GrayPaul avatar Nov 21 '19 15:11 GrayPaul

Is this the intent of the author or a bug in the program

lizhogn avatar Dec 02 '19 00:12 lizhogn

If I want to iterate more times to better train the model, how can I improve the problem

lizhogn avatar Dec 02 '19 00:12 lizhogn

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 = []

shenjian5 avatar May 03 '20 13:05 shenjian5

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.

lizhogn avatar May 03 '20 13:05 lizhogn

尊敬的人资负责人: 您好! 我想咨询一下关于暑期实习的问题,我是一名本科应届毕业生,目前已保送至中科大读研,希望通过实习来开拓视野,长长见识。请问这种情况有没有在今年暑期获取华为实习的机会呢,主要考虑技术研发岗位。

| | HITWH LIZHOGN | | [email protected] | 签名由网易邮箱大师定制

lizhogn avatar Jun 01 '20 11:06 lizhogn

@shenjian5 It works for me.Thanks~!

Catheriana avatar Nov 16 '20 03:11 Catheriana