I’m trying to predict using my model, which I managed to bring upto 70% accuracy. I tried googling, and stackoverlow-ing but cant seem to find any relevant solution. Please, I need help in solving these last 2 cells.
The error I get on the prediction (2nd last) cell is:
ValueError: Asked to retrieve element 0, but the Sequence has length 0
And for the very last cell, I get this error:
NameError: name ‘probabilities’ is not defined
Here is the link to my Google Colab for reference:
Just found the solution myself. But for those who will face similar problems as mine in the future, I hope this solution finds them helpful. Basically I had to change the code of cell 3. Instead of this code:
and on the prediction cell, I had to use the following code:
pred=model.predict(test_data_gen, verbose=1)
predicted_class = np.argmax(model.predict(test_data_gen), axis=-1)
probabilities = predicted_class.tolist()
actual_probabilities = [np.max(vector) for vector in pred]
plotImages([test_data_gen[i][0] for i in range(50)], probabilities=probabilities)