#!/usr/local/bin/python3
try:
import numpy as np
except ImportError:
print("numpy is not installed")
sizes = [37, 5, 6];
#biases = np.array([ 1.0, 3.0, 5.0, 6.0, 7.0]);
#weights = np.array([ 11.0, 33.0, 45.0, 26.0, 17.0, 88.0]);
biases = [np.random.randn(y, 1) for y in sizes[1:]];
weights = [np.random.randn(y, x) for x, y in zip(sizes[:-1], sizes[1:])]
nabla_b = [np.zeros(b.shape) for b in biases]
nabla_w = [np.zeros(w.shape) for w in weights]
print("sizes = ", sizes);
print("biases = ", biases);
print("weights = ", weights);
print("nabla_b = ", nabla_b);
print("nabla_w = ", nabla_w);
Notes: shape is one property of array of Numpy
Result:
sizes = [37, 5, 6]
biases = [array([[ 0.09714949],
[ 0.47620944],
[ 0.34928777],
[-1.10658204],
[-0.57715089]]), array([[-0.12100556],
[ 0.30560598],
[-1.78399525],
[ 0.27128077],
[ 1.0465515 ],
[-0.28311362]])]
weights = [array([[ 1.12822952, 0.33155703, -0.46288445, 0.92675546, 0.54701611,
-0.93509988, -0.70719355, 0.12302588, 2.14841954, -0.36100478,
0.65198077, 0.06947597, -0.58518835, -0.28141837, -0.753684 ,
0.24600003, 1.29092558, 1.07839281, -1.9282652 , 0.95000812,
0.4322544 , -0.17890703, 0.85988656, -0.48510108, -2.80733894,
0.26172456, 1.43374532, -0.51824353, -0.01262389, -1.93553739,
-1.30519477, -0.46520771, -0.97351474, 1.86550752, 0.85019947,
1.34546826, -1.1560633 ],
[ 0.64565081, 1.49986708, 0.75776246, 1.57481943, -0.9780609 ,
-0.2968981 , -1.17538016, 1.90705997, 1.1066672 , -0.13255052,
1.11002742, -1.59493182, 1.68483557, 0.39450082, -0.22871299,
-0.17862088, -0.5510486 , -1.51851881, -0.79322958, -0.31228867,
-0.89773743, 0.05387167, -2.50643893, 0.65536273, -0.22493518,
-0.02080998, -0.82108174, 0.93690475, 1.71457333, 2.31045295,
0.64184868, -0.11813463, -0.10631656, -0.86058624, -0.52644961,
-1.41857935, -0.37974942],
[-0.42409432, -0.27554181, 1.43614341, -1.1781703 , -0.32322266,
0.58355853, -0.31433167, 1.14738536, -0.12726777, -0.20390705,
0.17021241, -0.79802039, -0.02456132, -0.38001236, -0.38796353,
0.87351707, 1.93662153, -0.93767934, 1.35776271, 1.34811941,
0.07537077, -0.97452296, -0.15106705, 1.56302877, 0.25463266,
2.24722704, 0.2288987 , -1.24260812, -0.27735166, -0.52408036,
0.46209944, -0.612775 , -1.48650429, -1.13291731, -2.50855025,
-0.04495658, 0.40288902],
[-0.52452656, 1.17464405, 1.28915663, -0.70730175, -1.39016269,
1.68963576, -2.47483537, -0.62337663, -0.34400279, 0.41673257,
0.19468299, -1.34090444, -0.29102868, 1.91751429, -0.93428858,
0.12811932, 1.38872104, -0.43923168, -0.24974017, 0.03936021,
1.23211332, -0.78245534, -0.34747242, -1.25531902, 1.97262763,
0.8549816 , 0.75021482, -0.41798084, -0.31969348, 1.74115019,
-0.09906906, -0.58303702, -2.14022197, 0.11302391, 0.81415664,
0.25070911, 1.43592718],
[-0.54508121, 1.02542003, -0.42188603, -0.96910273, -0.64093118,
0.729856 , -0.99300862, 0.16322807, -3.00025972, 0.07483891,
-0.09031022, -0.24260929, -0.20694853, 1.45461925, 1.03036029,
-0.56423162, -1.81530528, 0.73621626, 0.45923198, -0.86762077,
-1.27036976, 0.73427931, 0.55326818, -0.46989278, 0.32468113,
1.69925189, -0.58533852, 0.90316271, -0.09363836, -0.55200695,
1.00102944, 0.93338578, 0.69989805, 1.59906312, -0.7526137 ,
0.28697489, 1.32338624]]), array([[-1.52940998, -0.22617425, 0.05160399, -0.75481722, -0.95507352],
[ 0.71569978, -0.53738774, 0.29188021, -0.89338887, 0.32436847],
[-0.13128955, -0.99779635, 0.05091223, 1.8215761 , 0.5402419 ],
[-1.8957081 , -0.89643672, 0.61422733, -0.68740477, 0.24506073],
[-0.58010539, -0.46452788, 1.22280345, -2.25719689, 0.85342986],
[ 1.0387704 , 0.63984682, 0.87889194, 0.68513674, 0.52289289]])]
nabla_b = [array([[ 0.],
[ 0.],
[ 0.],
[ 0.],
[ 0.]]), array([[ 0.],
[ 0.],
[ 0.],
[ 0.],
[ 0.],
[ 0.]])]
nabla_w = [array([[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), array([[ 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0.]])]