The Python Oracle

How do you invert a tensor of boolean values in Pytorch?

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Industries in Orbit Looping

--

Chapters
00:00 How Do You Invert A Tensor Of Boolean Values In Pytorch?
00:33 Accepted Answer Score 34
00:44 Thank you

--

Full question
https://stackoverflow.com/questions/5914...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #python3x #machinelearning #deeplearning #pytorch

#avk47



ACCEPTED ANSWER

Score 34


Literally just use the tilde to transform all True into False and vice versa.

ts = ~ts