In [2]:
import numpy as np
start:stop:step
In [3]:
a = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]
In [4]:
a[::2]
Out[4]:
In [5]:
a[0::2]
Out[5]:
In [6]:
a[::1]
Out[6]:
In [7]:
a
Out[7]:
Return the indices of the elements that are non-zero.
In [8]:
print(np.nonzero([1,2,3,0,4,0]))
In [9]:
arr = np.array([[1,0],[2,3]])
In [10]:
print(arr)
In [11]:
arr.nonzero()
Out[11]:
In [12]:
arr[arr.nonzero()]
Out[12]:
In [13]:
print(np.nonzero([1,2,3,0,4,0]))
In [40]:
A = np.zeros((1, 300, 3))
B = np.zeros((1, 300))
#B = np.expand_dims(B, axis=2)
B = np.expand_dims(B, axis=-1)
print(A.shape)
print(B.shape)
In [41]:
A = A[0,:,:]
B = B[0,:,:]
print(A.shape)
print(B.shape)
In [42]:
C = np.hstack((A, B))
print(C.shape)
C = np.expand_dims(C, axis=0)
print(C.shape)