-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