I am a beginner in python . I am trying to modify a numpy array but somehow it is not getting modify. Here is my program
def test_numpy(x):
count = 0
for i in x:
i-=np.max(i)
i=(np.exp(i)/np.sum(np.exp(i)))
print "The value of i is "
print i
x[count] = i
count+=1
print "the value of x is "
print x
if __name__ == "__main__":
test_numpy(np.array([[1,2],[3,4]])).
The output it prints is :
The value of i is [0.26894142 0.73105858] the value of x is [[0 0] [3 4]] The value of i is [0.26894142 0.73105858] the value of x is [[0 0] [0 0]]
I am assuming the value of x should be overridden by the value of i . So after looping twice the value of x should become ([0.26894142 0.73105858],[0.26894142 0.73105858]) But somehow the value is not getting overridden. Can anyone please point out my mistake here