-1
import numpy as np
weights = np.random.standard_normal((2,2,3))
b = weights
c = weights
c[0,1,:] = c[0,1,:] + [1,1,1]
print b[0,1]
print ('##################')
print c[0,1]
print ('##################')
print (np.sum(b-c))
[ 1.76759245 0.87506255 2.83713469]
##################
[ 1.76759245 0.87506255 2.83713469]
##################
0.0
Process finished with exit code 0
你可以看到,元素並沒有改變。 爲什麼?
在此先感謝
因爲'b'和'c'都是數組'weights'中相同位置的視圖。 – Divakar
元素已更改。 'b'和'c'是同一個數組。 – user2357112