Challenge: Creating a Perceptron
Since our goal is to implement a multilayer perceptron, creating a Perceptron
class will simplify model initialization. Its only attribute, layers
is essentially a list of the Layer
objects that define the structure of the network:
class Perceptron:
def __init__(self, layers):
self.layers = layers
The variables used to initialize the layers are the following:
input_size
: the number of input features;hidden_size
: the number of neurons in each hidden layer (both hidden layers will have the same number of neurons in this case);output_size
: the number of neurons in the output layer.
The structure of the resulting perceptron should be as follows:
Swipe to start coding
Your goal is to set up the basic structure of the perceptron by implementing its layers:
- Initialize the weights (a matrix) and biases (a vector) with random values from a uniform distribution in range
[-1, 1)
using NumPy. - Compute the raw output values of the neurons in the
forward()
method of theLayer
class. - Apply the activation function to the raw outputs in the
forward()
method of theLayer
class and return the result. - Define three layers in the
Perceptron
class: two hidden layers with the same number of neurons and one output layer. Both hidden layers should use therelu
activation function, while the output layer should usesigmoid
.
Solución
¡Gracias por tus comentarios!
single
Pregunte a AI
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla
Resumir este capítulo
Explicar el código en file
Explicar por qué file no resuelve la tarea
Awesome!
Completion rate improved to 4
Challenge: Creating a Perceptron
Desliza para mostrar el menú
Since our goal is to implement a multilayer perceptron, creating a Perceptron
class will simplify model initialization. Its only attribute, layers
is essentially a list of the Layer
objects that define the structure of the network:
class Perceptron:
def __init__(self, layers):
self.layers = layers
The variables used to initialize the layers are the following:
input_size
: the number of input features;hidden_size
: the number of neurons in each hidden layer (both hidden layers will have the same number of neurons in this case);output_size
: the number of neurons in the output layer.
The structure of the resulting perceptron should be as follows:
Swipe to start coding
Your goal is to set up the basic structure of the perceptron by implementing its layers:
- Initialize the weights (a matrix) and biases (a vector) with random values from a uniform distribution in range
[-1, 1)
using NumPy. - Compute the raw output values of the neurons in the
forward()
method of theLayer
class. - Apply the activation function to the raw outputs in the
forward()
method of theLayer
class and return the result. - Define three layers in the
Perceptron
class: two hidden layers with the same number of neurons and one output layer. Both hidden layers should use therelu
activation function, while the output layer should usesigmoid
.
Solución
¡Gracias por tus comentarios!
Awesome!
Completion rate improved to 4single