Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

add padding to 2d matrix p

import numpy as np
# https://numpy.org/doc/stable/reference/generated/numpy.pad.html
image = np.ones((2,2), dtype=int)

padded_image = np.pad(image, 1, dtype=int, mode='constant')

print(padded_image)
# [[0 0 0 0]
#  [0 1 1 0]
#  [0 1 1 0]
#  [0 0 0 0]]
Comment

add padding to 2d matrix p


result = np.zeros(b.shape)
# actually you can also use result = np.zeros_like(b) 
# but that also copies the dtype not only the shape

Comment

PREVIOUS NEXT
Code Example
Python :: django text area limit characters 
Python :: yum install python3 
Python :: how to delete the last item in a list python 
Python :: where to find python3 interpreter 
Python :: browser refresh selenium python 
Python :: python requests get cookies 
Python :: pandas replace data in specific columns with specific values 
Python :: import data in pandad 
Python :: list of files in python 
Python :: pandas convert all string columns to lowercase 
Python :: write muli line conditional statements in python 
Python :: alarm when code finishes 
Python :: convert letters to numbers in python 
Python :: fatal error detected failed to execute script 
Python :: python sum attribute in list 
Python :: for each value in column pandas 
Python :: How to find majority element in a sequence of values using Boyer-Moore vote algorithm? 
Python :: how to print an input backwards in python 
Python :: convert bytes to numpy array python 
Python :: python print object 
Python :: avatar discord.py 
Python :: pyspark take random sample 
Python :: how to add a list to dataframe in python 
Python :: from sklearn.metrics import classification_report 
Python :: reload is not defined python 3 
Python :: how to insert sound in python 
Python :: python save input to text file 
Python :: read text from a pdffile python 
Python :: how to move a column in pandas dataframe 
Python :: open text file in python 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =