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)
.squeeze function in numpy
The squeeze() function is used to remove single-dimensional entries from the
shape of an array.
Python NumPy squeeze function Syntax
numpy.squeeze(arr, axis=None )
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)
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)
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)
.squeeze function in numpy
The squeeze() function is used to remove single-dimensional entries from the
shape of an array.
Python NumPy squeeze function Syntax
numpy.squeeze(arr, axis=None )
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)
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)