Make a note from scratch so that you don't forget what you understood after reading Deep Learning 2. For example
a = np.array([1, 2, 3])
b = np.array([4, 5, 6])
If there was When a = b If a [...] = b, the result of a is the same, It is called ** "shallow copy" ** and ** "deep copy" **, and the way they are copied is different. In ** shallow copy **, when considering memory, if a = b, a points to the same position as b's memory, so that a shows the same value as b. That is, a and b point to the same position. On the other hand, in ** deep copy **, the number [1, 2, 3] at the memory position that a originally pointed to is Replace with [4, 5, 6]. I feel that this is a substitution that is generally imagined.
So what's the difference between them? When ** shallow copy **, a and b point to the same memory location, so if you change the value of either one, the value of the other will change accordingly. On the other hand, ** deep copy ** does not work together because they point to different memory locations.
Recommended Posts