Published in


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.

Updated successfully.


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.




The member of LSC Corp.

Recommended from Medium

The who, what, and why of Bear

Upgrade Activity: Harddrive SSD → SSD

Flutter Barcode Plugin — Writing C++ Code for Windows Desktop

【Application(8)】Martingale Strategy

Five Integration Challenges Organizations will face in 2022

How to Build ZXing C++ to Wasm using WASI SDK in Linux

run wasi zxing barcode wasm file with wapm

How Grammarly bashed our test site

Week of 1 Nov — 7 Nov Blog

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


Microbiology technician,Machine learning engineer(beginner)

More from Medium

How does Coding really work?

“We believe deep learning and JavaScript belong together”, me too!😍🤗


Why’d You Refactor the Code that Way? That’s crazy! (Hint: the Database)