Replies: 1 comment 2 replies
-
The "+=" operates in place, so it will change the original numpy array. You can try these codes and observe how each variable memory address changes.
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I was going through numpy to tensor and tensor to numpy conversion, where it was mentioned that memory is not shared between the original and the new tensor/array.
But while performing
+=
for increment, they behaved like they are sharing the same memory. Although the moment I use statements liketensor = tensor + 1
that sharing stops e.g.tensor += 1
Can someone tell me the right topic to read so it doesn't feel like a quirky behaviour?
I am using Google Colab and I'm on CPU.
Code:
Beta Was this translation helpful? Give feedback.
All reactions