# \#1 PyTorch Book Thread: Sunday, 29 Aug 8 AM PT

**URL:** <https://community.wandb.ai/t/1-pytorch-book-thread-sunday-29-aug-8-am-pt/211>\
**Category:** PyTorch Book Reading Group\
**Created:** [August 25, 2021, 2:45pm UTC](https://community.wandb.ai/t/1-pytorch-book-thread-sunday-29-aug-8-am-pt/211 "2021-08-25T14:45:26Z")\
**Posts on this page:** 7\
**Page:** 4

<div class="post-metadata">

**Author:** ![bhutanisanyam1](https://sea2.discourse-cdn.com/flex020/user_avatar/community.wandb.ai/bhutanisanyam1/32/18_2.png) [@bhutanisanyam1](https://community.wandb.ai/u/bhutanisanyam1)\
**Post date:** [September 4, 2021, 2:10pm UTC](https://community.wandb.ai/t/1-pytorch-book-thread-sunday-29-aug-8-am-pt/211/63 "2021-09-04T14:10:32Z")

</div>

That’s awesome! Great to see you in the group and looking forward to being part of your journey.

Feel free to introduce yourself in #start-here if you’d like 🙂

---

<div class="post-metadata">

**Author:** ![raduga256](https://avatars.discourse-cdn.com/v4/letter/r/b2d939/32.png) [@raduga256](https://community.wandb.ai/u/raduga256)\
**Post date:** [September 4, 2021, 2:26pm UTC](https://community.wandb.ai/t/1-pytorch-book-thread-sunday-29-aug-8-am-pt/211/64 "2021-09-04T14:26:34Z")

</div>

Am a Paul, a Msc Data Science and Analytics in the UK and have strong interest towards AI and ML  
LinkedIn: [Paul Ntalo - Jr Machine Learning Engineer - Omdena | LinkedIn](https://www.linkedin.com/in/paul-ntalo-273a8641/)

---

<div class="post-metadata">

**Author:** ![jabertuhin](https://sea2.discourse-cdn.com/flex020/user_avatar/community.wandb.ai/jabertuhin/32/147_2.png) [@jabertuhin](https://community.wandb.ai/u/jabertuhin)\
**Post date:** [September 4, 2021, 5:23pm UTC](https://community.wandb.ai/t/1-pytorch-book-thread-sunday-29-aug-8-am-pt/211/65 "2021-09-04T17:23:15Z")

</div>

As there is a discussion about image augmentation, last year I read this article which discussed about few interesting points.  
Specially about **Pitfall 3: When comparing humans and machines, experimental conditions should be equivalent**

[Challenges of Comparing Human and Machine Perception](https://thegradient.pub/challenges-of-comparing-human-and-machine-perception/)

---

<div class="post-metadata">

**Author:** ![yuvraj](https://avatars.discourse-cdn.com/v4/letter/y/b5a626/32.png) [@yuvraj](https://community.wandb.ai/u/yuvraj)\
**Post date:** [September 7, 2021, 9:16pm UTC](https://community.wandb.ai/t/1-pytorch-book-thread-sunday-29-aug-8-am-pt/211/66 "2021-09-07T21:16:22Z")

</div>

Hi Guys, I have a doubt. I read in Tensors chapter (Chapter 3) that if I explicitly create tensors in my GPU, pytorch will create the tensor in GPU memory and not my RAM. Now I am not sure why I am getting same id when I created a tensor in GPU and copied it to CPU and checked id of the first element in storage. Can someone help me understand this? Thanks in advance .

 ![image](https://us1.discourse-cdn.com/flex020/uploads/wandb/original/1X/973d25c1d216388daa225ae6116c24949ab49eab.png)

---

<div class="post-metadata">

**Author:** ![sahiljuneja](https://sea2.discourse-cdn.com/flex020/user_avatar/community.wandb.ai/sahiljuneja/32/294_2.png) [@sahiljuneja](https://community.wandb.ai/u/sahiljuneja)\
**Post date:** [September 8, 2021, 5:30am UTC](https://community.wandb.ai/t/1-pytorch-book-thread-sunday-29-aug-8-am-pt/211/67 "2021-09-08T05:30:24Z")

</div>

Using `id()` can be tricky for different reasons. But an object in python will return a unique number, when you use `id()`, for only the lifetime of that object.

When you use -

```auto
id(points_gpu.storage())

```

you get a number. The reference to that object is then deleted. It doesn’t exist beyond that.

When you next try to do something like -

```auto
id(points_cpu.storage())

```

then, internally, the memory management sees that there is an empty place in memory - the location that the previous number pointed to. So, it just uses that same location and returns the same number.

If it didn’t do that, you could run `id(something)` too many times just taking up memory.

However, if you did something like -

```auto
t1 = points_gpu.storage()
print(id(t1))

t2 = points_cpu.storage()
print(id(t2))
print(id(t1))

```

Now, you would likely get different numbers that would persist because your object is being stored in memory. If you have worked with Pandas, this is probably similar to when you might do something like -

```auto
a.dropna()
a.dropna(inplace=True)
a = a.dropna()

```

The first one is not going to make any change to `a`. It would show us the output, but `a` is not affected. The 2nd and 3rd ones allow for the change to persist in `a`.

For PyTorch, `data_ptr()` can be used which returns the address of the first element of the tensor.

So, if you did -

```auto
points_gpu.storage().data_ptr()
points_cpu.storage().data_ptr()

```

You would get different numbers for both. When I ran it I got something like -

```auto
30104616960
2068614157952

```

The above makes sense to me because the 2nd one is longer and corresponds to the CPU so I would expect it to have more memory locations than the GPU one. So, your tensors are being created and used as expected based on that. Using `id()` might not be the best option, in this case, to check for that because of however Python/CPython works with/defines it internally.

**Note:** Everything I shared above is likely a high overview of how it actually works (and I could have made a mistake). I tried to spent more time than I should have to understand this. But after a point, this just becomes very convoluted and some sources even said all of this is not something most people (including programmers) would have to bother with.

Interesting question, though!

---

<div class="post-metadata">

**Author:** ![yuvraj](https://avatars.discourse-cdn.com/v4/letter/y/b5a626/32.png) [@yuvraj](https://community.wandb.ai/u/yuvraj)\
**Post date:** [September 8, 2021, 6:45am UTC](https://community.wandb.ai/t/1-pytorch-book-thread-sunday-29-aug-8-am-pt/211/68 "2021-09-08T06:45:55Z")

</div>

Many thanks for taking the time out to write this. This is a great answer - very insightful.

---

<div class="post-metadata">

**Author:** ![deep\_learner\_007](https://avatars.discourse-cdn.com/v4/letter/d/e9bcb4/32.png) [@deep\_learner\_007](https://community.wandb.ai/u/deep_learner_007)\
**Post date:** [September 17, 2021, 10:43pm UTC](https://community.wandb.ai/t/1-pytorch-book-thread-sunday-29-aug-8-am-pt/211/69 "2021-09-17T22:43:23Z")

</div>

Thank you for the session. There is a lot to code and practice 🙂  
I wanted to know if you could share how to automate the process of data processing for a local datat set?

[Previous page](https://community.wandb.ai/t/1-pytorch-book-thread-sunday-29-aug-8-am-pt/211.md?page=3)
