jaungiers / LSTM-Neural-Network-for-Time-Series-Prediction

LSTM built using Keras Python package to predict time series steps and sequences. Includes sin wave and stock market data
GNU Affero General Public License v3.0
4.85k stars 1.96k forks source link

Reason of the question"StopIteration" #68

Open GrayPaul opened 5 years ago

GrayPaul commented 5 years ago

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 .

lizhogn commented 5 years ago

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

lizhogn commented 5 years ago

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

shenjian5 commented 4 years ago

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 = []
lizhogn commented 4 years ago

OK, thanks very much👍

在 2020年5月3日,下午9:22,shenjian5 notifications@github.com 写道:

 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 commented 4 years ago

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

HITWH LIZHOGN

15214731817@163.com | 签名由网易邮箱大师定制

Catheriana commented 4 years ago

@shenjian5 It works for me.Thanks~!