In Variational Classifier Code, let’s say

```
Y.shape = (200,)
index = np.random.permutation(range(len(Y)))
num_train = 150
# Y value (i.e., -1, 1) corresponding to array of # index of size 150. Also since, index contains # randomly permutated values from 0 to 200, # so selecting first 150 numbers possibly #have more than 150 in magnitude (i.e., 186, # 157, etc.)
Y_train = Y[index[:num_train]]
# Now, let's define one more parameter,
batch_index = np.random.randint(0, num_train, (batch_size,))
# It takes 5 random values from 0 to 150 ,
# In optimization loop, here is the problem,
Y_train_batch = Y_train[batch_index]
```

batch_ index is chosen randomly 5 values but in Y_train is also randomly permutated values. In many cases if batch_index contain value (example :128 as a value) but it didn’t have Y_train. So many times it gives me this error :KeyError: ‘[117] not in index’.

Its not give me error if i choose ,

```
Y_train = Y[:150]
# rather than randomly generated between 0 to 200 and select 150.
```

Please, I tried my best explaining the difficulty i am facing. If someone understand the problem show me how can i fix it and where did i go wrong?