"python: deprecationwarning: elementwise == comparison failed; this will raise an error in the future" Code Answer

2

i assume the error occurs in this expression:

np.sum(np.argmax(predictions, 1) == np.argmax(labels, 1))

can you tell us something about the 2 arrays, predictions, labels? the usual stuff - dtype, shape, some sample values. maybe go the extra step and show the np.argmax(...) for each.

in numpy you can compare arrays of the same size, but it has become pickier about comparing arrays that don't match in size:

in [522]: np.arange(10)==np.arange(5,15)
out[522]: array([false, false, false, false, false, false, false, false, false, false], dtype=bool)
in [523]: np.arange(10)==np.arange(5,14)
/usr/local/bin/ipython3:1: deprecationwarning: elementwise == comparison failed; this will raise an error in the future.
  #!/usr/bin/python3
out[523]: false
By Recursion on September 23 2022

Answers related to “python: deprecationwarning: elementwise == comparison failed; this will raise an error in the future”

Only authorized users can answer the Search term. Please sign in first, or register a free account.