나는 파이썬에서 반복에 관한 질문을 받았다. 함수 generate_random_weights에서반복하는 동안 값을 변경하면 여러 수준에서 값이 변경되는 이유는 무엇입니까?
class neural_net:
def __init__(self, n_neurons, n_input):
self.n_neurons = n_neurons
self.n_input = n_input
self.input = []
self.weights = []
self.output = []
def generate_input(self):
input = [0.0,0.0,1.0]
self.input = input
def generate_random_weights(self):
weights = [[0] * self.n_input ] * (self.n_neurons)
for i in range(self.n_neurons):
for ii in range(self.n_input):
weights[i][ii] = round(random.random(), 1)
self.weights = weights
, I = 0 그리고 난 항상 같은 시간에 업데이트 = 1되어 순간에 나는 코드 다음 (의 일부)를 사용하여, 매우 간단한 신경망 구축을 위해 노력하고있다 . 'self.weights :
weights: [[0.2, 0,1, 0,8], [0,2, 0,1, 0,8]]
첫 번째와 두 번째 목록은 항상 동일합니다 결과는 항상 print'weights을 사용하여 다음과 같은 경우 인쇄이 같은이며, 이런 사람이 왜 알고 있나요 ?