Here is a Python representation of a Neural Network Neuron that I'm trying to understand
class Network(object):
def __init__(self, sizes):
self.num_layers = len(sizes)
self.sizes = sizes
self.biases = [np.random.randn(y, 1) for y in sizes[1:]]
self.weights = [np.random.randn(y, x)
for x, y in zip(sizes[:-1], sizes[1:])]
Here is my current understanding :
self.num_layers = len(sizes)
: Return the number of items in sizesself.sizes = sizes
: assign self instance sizes to function parameter sizesself.biases = sizes
: generate an array of elements from the standard normal distribution (indicated bynp.random.randn(y, 1)
)
What is the following line computing?
self.weights = [np.random.randn(y, x)
for x, y in zip(sizes[:-1], sizes[1:])]
I'm new to Python. Can this code be used within a Python shell so I can gain a better understanding by invoking each line separately ?