Answers for "np.random shape"

2

random matrix python

np.random.rand(3,2)
Posted by: Guest on March-21-2020
0

convert np shape (a,) to (a,1)

# numpy array/vector (n,) dimension -> (n,1) dimension conversion
a  = np.arange(3)         # a.shape  = (3,)
b  = a.reshape((3,1))     # b.shape  = (3,1)
c  = b.reshape((3,))      # c.shape  = (3,)

c2 = b.reshape((-1,1))    # c2.shape = (3,)
Posted by: Guest on January-04-2021
1

NumPy Array Shape

import numpy as np

arr = np.array([1, 2, 3, 4], ndmin=5)

print(arr)
print('shape of array :', arr.shape)
Posted by: Guest on February-01-2021

Python Answers by Framework

Browse Popular Code Answers by Language