In [1]:
    
import numpy as np
    
In [2]:
    
np.tanh(1)
    
    Out[2]:
In [3]:
    
a = np.arange(50).reshape(2,5,5)
    
In [4]:
    
a
    
    Out[4]:
In [7]:
    
print a.shape
    
    
In [9]:
    
#change the order as we need 5,2,5 say for example
b = a.transpose(1,0,2)
    
In [10]:
    
print b
    
    
In [11]:
    
print b.shape
    
    
In [12]:
    
c = b #copying here is just reference copy
    
In [14]:
    
c[1,1,1] = 18
    
In [15]:
    
b[1,1,1]
    
    Out[15]:
In [16]:
    
b
    
    Out[16]:
In [19]:
    
d = b.copy() #this is literal copy as we know it
    
In [20]:
    
d
    
    Out[20]:
In [21]:
    
d[1,1,1] = 20
    
In [22]:
    
c[1,1,1]
    
    Out[22]:
In [25]:
    
d[-1]
    
    Out[25]:
In [26]:
    
range(10,0,-1)
    
    Out[26]:
In [46]:
    
#from 2 d to 3d
N = 30
T = 20
p = np.zeros((N,T))
    
In [47]:
    
np.random.random_sample(30)
    
    Out[47]:
In [48]:
    
import random
    
In [49]:
    
p[np.arange(N)] = [random.sample(range(T),T) for _ in range(N)]
    
In [51]:
    
#p
    
In [52]:
    
D = 10
W = np.zeros((T,D))
    
In [53]:
    
W[np.arange(T)] = [random.sample(range(D),D) for _ in range(T)]
    
In [54]:
    
W
    
    Out[54]:
In [56]:
    
W[p,:]
    
    
In [58]:
    
type(W)
    
    Out[58]:
In [59]:
    
type(p)
    
    Out[59]:
In [60]:
    
W.shape
    
    Out[60]:
In [62]:
    
p.shape
    
    Out[62]:
In [69]:
    
W[p,:] #not sure why it is giving error
    
    
In [77]:
    
np.add.at(p,[[0,1],[2,3]],[2,3])
    
In [79]:
    
np.add.at(p,[[0,1],[2,3]],np.arange(50).reshape(2,5,5))
    
    
In [ ]: