Help find a bug in the code

IndexError: list index out of range
I can’t understand why this error is being called.

import numpy as np
import random

wn1 = 2
epochs = 10
st_s1 = np.random.rand(10,9)
st_t1 = np.random.rand(10,1)
len_st = len(st_s1)
b = len_st-wn1

for epoch in range(epochs):
    shuffle_list = list(range(1, b))
    for wn_start in range(b):
        wn_all2 = []
        los_l = []
        shuffle_temp = shuffle_list[wn_start]

Hi @slavavs,

Here you declare a list of length 7:

    shuffle_list = list(range(1, b))

So in the inner loop you should iterate of range(b-1) and not range(b).

1 Like