Notes when initializing arrays that store weights and biases
[python] [array]
Array initialization
< Initialize an empty array>
array_a = []
<Initialize after entering a number>
array_b = [1, 2, 3, 4]
*You can also enter strings and variables
Initialize after filling the specified number with 0
For example, if you want to initialize a 1 × 10 array
array1 = [0]*10

What about 10x10? ?
array2 = [[0]*10]*10

OK, OK, array initialization succeeded.
But please wait a moment.
Change the value in the 5th row and the 4th column to 48.

!!!!!!!!!
No, this must be something wrong …
Try changing the value in row 9 and column 9 to 12.

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
All the columns have been updated …
Use ”for i in range”
If you want to update only the specified element, initialize the array as follows.
array3 = [[0 for i in range(10)]for i in range(10)]

Change the value in the 5th row and the 4th column to 48.

Try changing the value in 9th row and 9th column to 12.

Congratulations‼
Updated successfully.
Conclusion
The [[0] * 10] * 10 method defines 10 identical arrays, so changing the value of an element changes the other elements.
The [[0 for i in range (10)] for i in range (10)] method creates multiple lists. Therefore, the value of only the specified element is changed.