Like the single neuron, this model can be implemented in Python. Actually, we do not even have to make too many edits compared to our Neuron class:
import numpy as np
class FullyConnectedLayer(object):
"""A simple fully-connected NN layer.
Args:
num_inputs (int): The input vector size/number of input values.
layer_size (int): The output vector size/number of neurons.
activation_fn (callable): The activation function for this layer.
Attributes:
W (ndarray): The weight values for each input.
b (ndarray): The bias value, added to the weighted sum.
size (int): The layer size/number of neurons.
activation_fn (callable): The neurons' activation function.
"""
def __init__(self, num_inputs, layer_size, activation_fn):
super().__init__()
# Randomly initializing the parameters (using a normal distribution this time):
self.W = np.random.standard_normal((num_inputs...