This error is caused by using a NumPy array as a condition in an if statement, which is invalid because NumPy arrays cannot be directly used as truth values.

To fix this, you can use the 'any()' or 'all()' functions to determine the truth value of the NumPy array.

Modify your if statement like this:

if np.any(predicted.cpu().numpy() == [0, 1, 2, 3, 4, 5]) or torch.max(output) < 0.4:

This will correctly evaluate the condition based on the NumPy array.

Python ValueError: The truth value of an array with more than one element is ambiguous

原文地址: https://www.cveoy.top/t/topic/qtaj 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录