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.83k stars 1.96k forks source link

StopIteration #65

Open heyayun18188 opened 5 years ago

heyayun18188 commented 5 years ago

When the process runs into the 17th epoch. StopIteration error comes out.

lizhogn commented 5 years ago

I also meet this problem, do you solve it now?

VincieD commented 4 years ago

Hi, this small change do the trick...

def generate_train_batch(self, seq_len, batch_size, normalise):
        i = 0
        while True:
            x_batch = []
            y_batch = []
            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 = []
            yield np.array(x_batch), np.array(y_batch)