The error message is always more important than the code. So value it!
1. The error position is
(1) The error message is: bool value of Tensor with more than one value is ambiguous
(2) Youdao translates as: untimeError: The tensor of bool values exceeds one value is ambiguous.
(3) The error message is: Traceback (most recent call last)
(4) Youdao translates as: backtracking (last call at the end)
2. Analysis
Look carefully at the error location, there is nothing wrong with the criterion usage. Criterion is a result tensor, then look for its original tensor, and the problem will be found at a glance. There is no bracket () in the mean square error statement, and the problem is solved after adding yellow brackets.