The Python Oracle

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

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Track title: CC P Beethoven - Piano Sonata No 2 in A

--

Chapters
00:00 Question
00:46 Accepted answer (Score 25)
01:01 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