You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cc @hmc-cs-mdrissi who originally contributed the tensorflow stubs.
hoel-bagard
changed the title
tensorfllow: Tensor.__bool__'s signature is incorrect for one element tensorstensorflow: Tensor.__bool__'s signature is incorrect for one element tensors
Feb 28, 2025
It only works for scalars and fails with other shapes.
It only works in some execution modes. It'll be fine in eager, but can crash for graph mode even with scalars. Most code I work with needs to be graph mode compatible.
I'm fine with the change. My experience leans that those two issues cover large percent of usages, but it's fair that policy is prefer false negatives and I don't have actual numbers for it.
Currently
Tensor.__bool__
's signature is as follows:It suggests that the method should never be called, however the following is valid code:
Since this depends on the shape of the tensor, I don't know if this can be fixed, but it would be nice to have.
The text was updated successfully, but these errors were encountered: