numpy.pad

Creator
Creator
Seonglae ChoSeonglae Cho
Created
Created
2020 Oct 20 3:59
Editor
Edited
Edited
2026 Jan 28 23:59
Refs
Refs

Padding

np.pad maintains the original dimensions
np.pad([1,2,3], (2,3), 'constant', constant_values=0) # [0,0,1,2,3,0,0,0]
np.pad([[1,2],[3,4]], 1, 'constant') # [[0,0,0,0], # [0,1,2,0], # [0,3,4,0], # [0,0,0,0]]
 
 
 
 
 
 
 
 

Recommendations