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 :: Algorithm of Broadcasting with NumPy Arrays 
Python :: Python NumPy atleast_3d Function Example 
Python :: Python NumPy atleast_1d Function Syntax 
Python :: Python NumPy rollaxis Function Example 02 
Python :: Python NumPy copyto function example copy elements from a source array to a destination array. 
Python :: how to murj record in django 
Python :: conmbination in python 
Python :: make python standalone 
Python :: Python NumPy asanyarray Function Example Tuple to an array 
Python :: Python NumPy require Function Syntax 
Python :: Python NumPy row_stack Function Example with 2d array 
Python :: verbose field names 
Python :: get method from plot 
Python :: codeforces problem 580A 
Python :: create different size matplotlib 
Python :: Open S3 object as string in Python 3 
Python :: saving specific column with pd 
Python :: django view - APIView (urls.py config) 
Python :: python override inherited method data model constructor 
Python :: python list and numpy array 
Python :: celery 5.2.3 decorators 
Python :: how to remove a strech in pyqt5 
Python :: if is 
Python :: python flask many to many relation db 
Python :: python list len 
Python :: Python beginner question - trying to understand return statement 
Python :: KeyError: 0 python 
Python :: ring for loop 
Python :: ring Using the Natural Library 
Python :: python get message Exception 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =