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

StopIteration

Open heyayun18188 opened this issue 5 years ago • 2 comments

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

heyayun18188 avatar Sep 21 '19 13:09 heyayun18188

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

lizhogn avatar Oct 31 '19 07:10 lizhogn

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)

VincieD avatar Aug 05 '20 10:08 VincieD