一、产生X样本
x_train = np.random.random((5, 3)) 随机产生一个5行3列的样本矩阵,也就是5个维度为3的训练样本。
array([[ 0.56644011, 0.75185718, 0.98654195],
[ 0.46676905, 0.2452094 , 0.28035157],
[ 0.69687126, 0.85162556, 0.23118269],
[ 0.69127369, 0.32235362, 0.90172209],
[ 0.64421882, 0.65666665, 0.37091807]])
二、产生Y样本
y_train = np.random.randint(10, size=(20, 1)) 产生一个20行1列的Y样本,值分布为10个,也就是0~9。也就是20个多类别样本标签。
array([[8],
[8],
[0],
[4],
[9],
[9],
[7],
[3],
[0],
[9],
[0],
[2],
[1],
[0],
[3],
[4],
[6],
[8],
[9],
[7]])
三、产生2D卷积X样本
x_train = np.random.random((4,2,5, 3))产生4个卷积样本,每个样本两层,没层矩阵是5X3结构。
array([[[[ 0.81108075, 0.75130404, 0.32276459],
[ 0.84803225, 0.95347097, 0.98392204],
[ 0.82862565, 0.60562112, 0.12725719],
[ 0.66517274, 0.80061288, 0.56373024],
[ 0.33360791, 0.15615631, 0.01854572]],
[[ 0.95840439, 0.62069117, 0.98154442],
[ 0.22812983, 0.83663549, 0.79360161],
[ 0.40764592, 0.1903219 , 0.75269041],
[ 0.89337384, 0.48268712, 0.98336301],
[ 0.00515764, 0.41898271, 0.17870325]]],
[[[ 0.16303286, 0.30437622, 0.80772764],
[ 0.99838344, 0.78417382, 0.52251551],
[ 0.81561737, 0.20268081, 0.15342787],
[ 0.77666367, 0.26014027, 0.01359609],
[ 0.76491115, 0.23499911, 0.75797289]],
[[ 0.0221104 , 0.92696779, 0.16339887],
[ 0.93589062, 0.64230156, 0.54570248],
[ 0.01895301, 0.23444549, 0.03577822],
[ 0.06956943, 0.05085453, 0.58532944],
[ 0.01029333, 0.99890575, 0.22400419]]],
[[[ 0.33587317, 0.38829797, 0.76169893],
[ 0.8067067 , 0.29012318, 0.01406736],
[ 0.99158238, 0.60665312, 0.52777604],
[ 0.06333543, 0.9294594 , 0.0571626 ],
[ 0.02463482, 0.9234842 , 0.68864325]],
[[ 0.23725655, 0.8793853 , 0.49002114],
[ 0.86578146, 0.93386534, 0.48375739],
[ 0.5304713 , 0.44797753, 0.79250569],
[ 0.92835088, 0.17855765, 0.27783737],
[ 0.17801198, 0.2095321 , 0.64932004]]],
[[[ 0.35564935, 0.98168517, 0.75135149],
[ 0.79403744, 0.06994751, 0.95484361],
[ 0.14493514, 0.11813182, 0.61482502],
[ 0.5031048 , 0.91276372, 0.2315978 ],
[ 0.57193754, 0.20402079, 0.75060145]],
[[ 0.0099759 , 0.37148569, 0.89472595],
[ 0.91443219, 0.17405477, 0.78021433],
[ 0.84789989, 0.34975548, 0.85220165],
[ 0.85179668, 0.04264071, 0.36531178],
[ 0.72911524, 0.85494955, 0.60118721]]]])
四、产生2D卷积Y样本
y_train = np.random.randint(10, size=(20, 1)) y样本不变,同上