1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| import numpy as np
y1 = np.random.choice(2,size=[10,10]) print(y1) print(type(y1[0][0])) ''' [[1 0 0 1 0 0 1 0 0 1] [0 0 0 1 1 0 1 1 1 0] [1 1 0 0 1 1 1 0 0 0] [0 0 1 0 1 1 1 0 1 1] [1 0 0 0 1 1 0 1 1 1] [0 1 1 1 1 1 1 0 0 1] [0 1 0 0 0 0 1 0 1 1] [1 1 0 0 0 0 0 0 0 1] [1 0 1 1 0 1 0 0 0 1] [1 1 0 0 1 0 0 1 1 1]] <class 'numpy.int64'> '''
y2 = np.random.choice(10,size=[10], replace=False) print(y2)
y3 = np.random.choice(2, size=[10], p=[0.0001,0.9999]) print(y3)
|