In [2]:
import numpy as np
In [3]:
s = np.array(5)
In [4]:
print s
In [5]:
s.shape
Out[5]:
In [6]:
x = s + 3
In [7]:
print x
In [8]:
v = np.array([1,2,3])
print v
In [9]:
x = v[1]
print x
In [11]:
v[1:]
Out[11]:
In [12]:
m = np.array([[1,2,3], [4,5,6], [7,8,9]])
print m
In [13]:
m.shape
Out[13]:
In [14]:
print m[1][2]
In [16]:
t = np.array([[[[1],[2]],[[3],[4]],[[5],[6]]],[[[7],[8]],\
[[9],[10]],[[11],[12]]],[[[13],[14]],[[15],[16]],[[17],[17]]]])
print t
In [17]:
v = np.array([1,2,3,4])
print v
In [18]:
x = v.reshape(1,4)
print x
In [19]:
x = v.reshape(4,1)
print x
In [20]:
x = v.reshape(2,2)
print x
In [21]:
x = v[None, :]
print x
In [22]:
x = v[:, None]
print x
In [23]:
a = np.arange(6) # 1d array
print(a)
In [24]:
b = np.arange(12).reshape(4,3) # 2d array
print(b)
In [25]:
c = np.arange(24).reshape(2,3,4) # 3d array
print(c)
In [27]:
d = np.arange(24*5).reshape(2,3,4,5) # 4d array
print(d)
In [ ]: