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

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 :: Broadcasting with NumPy Arrays Single dimension array Example 
Python :: Python NumPy atleast_3d Function Example 2 
Python :: Python NumPy atleast_1d Function Example 
Python :: Python NumPy moveaxis function syntax 
Python :: intervalle de temps python 
Python :: Django merge duplicate rows 
Python :: python read file with class 
Python :: how to import scypy in python 
Python :: Python NumPy asanyarray Function Example Scalar to an array 
Python :: Python NumPy require Function Example without requirements attribute 
Python :: Python NumPy split Function Example when index attribute given wrong 
Python :: search recurse sub-folders using glob.glob module python 
Python :: structure conditionnelle python 
Python :: python __sub__ 
Python :: django ejemplo de un formulario crud 
Python :: program adxl335 python 
Python :: NumPy bitwise_or Syntax 
Python :: django view - mixins and GenericAPIView (list or create - GET, POST) 
Python :: # convert dictionary keys to a list 
Python :: lpython list unino 
Python :: get token eth balance python 
Python :: from android.runnable in python 
Python :: print(i) 
Python :: python re return index of match 
Python :: Python batch file rename 
Python :: How deploy Flask application on Webfaction 
Python :: EDA describe missing and zero values 
Python :: ring For in Loop 
Python :: ring The For Loops uses the local scope 
Python :: convert all date columns using pd.datetime 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =