Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Python NumPy squeeze function Example

# welcome to softhunt.net
# Python program explaining
# numpy.squeeze function

import numpy as np

in_arr = np.array([[[1, 2, 3], [4, 5, 6]]])

print ("Input array : 
", in_arr)
print("Shape of input array : ", in_arr.shape)

out_arr = np.squeeze(in_arr)

print ("output squeezed array : 
", out_arr)
print("Shape of output array : ", out_arr.shape)
Comment

.squeeze function in numpy

The squeeze() function is used to remove single-dimensional entries from the
shape of an array.
Comment

Python NumPy squeeze function Syntax

numpy.squeeze(arr, axis=None )
Comment

Python NumPy squeeze function Example with axis

# welcome to softhunt.net
# Python program explaining
# numpy.squeeze function
import numpy as geek
in_arr = geek.arange(9).reshape(1, 3, 3)

print ("Input array : 
", in_arr)
out_arr = geek.squeeze(in_arr, axis = 0)

print ("output array : 
", out_arr)
print("The shapes of Input and Output array : ",in_arr.shape, out_arr.shape)
Comment

Python NumPy squeeze function Example with axis=1

# welcome to softhunt.net
# Python program explaining
# numpy.squeeze function
import numpy as geek
in_arr = geek.arange(9).reshape(1, 3, 3)

print ("Input array : 
", in_arr)
out_arr = geek.squeeze(in_arr, axis = 1)

print ("output array : 
", out_arr)
print("The shapes of Input and Output array : ",in_arr.shape, out_arr.shape)
Comment

PREVIOUS NEXT
Code Example
Python :: symbolic variables python 
Python :: how to change the main diagonal in pandas 
Python :: comment transformer un chaine de caractere en liste python 
Python :: blender python get current filename 
Python :: every substring python 
Python :: python os path safe string 
Python :: # logging 
Python :: how to make a histogram with plotly for a single variable 
Python :: list of list to numpy array 
Python :: get value of bit in integer python 
Python :: Print and remove previous line 
Python :: list dictionary to json file python with tab 
Python :: cv2 remove black borders on images 
Python :: alphabeticallly 
Python :: dict to list python 
Python :: how to use mtproto proxy for telethon 
Python :: python elementTree tostring write() argument must be str, not bytes 
Python :: how to split a dataframe into train and test 
Python :: The function to be built, amino_acids, must return a list of a tuple and an integer when given a string of mRNA code. 
Python :: stores number in set using input in python 
Python :: python find cells with na 
Python :: django insert data into database foreign key view.py 
Python :: python timedelta get days with fraction 
Python :: string to list 
Python :: tkinter standard dialogs message 
Python :: Python RegEx Compile – re.compile() 
Python :: 151 - Power Crisis 
Python :: bytestring python 
Python :: turn off yticklabels 
Python :: re sub python 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =