セクション 2. 章 4
single
Challenge: Creating a Perceptron
メニューを表示するにはスワイプしてください
To build a multilayer perceptron (MLP), it is helpful to define a Perceptron class. It stores a list of Layer objects that make up the network:
class Perceptron:
def __init__(self, layers):
self.layers = layers
The MLP will use three values:
input_size: number of input features;hidden_size: number of neurons in each hidden layer;output_size: number of neurons in the output layer.
Thus, the model consists of:
- An input layer;
- Two hidden layers (same neuron count, ReLU);
- An output layer (sigmoid).
タスク
スワイプしてコーディングを開始
Your task is to implement the basic structure of this MLP.
1. Initialize layer parameters (__init__)
- Create a weight matrix of shape
(n_neurons, n_inputs); - Create a bias vector of shape
(n_neurons, 1); - Fill them with random values in [-1, 1) using
np.random.uniform().
2. Implement forward propagation (forward)
- Compute raw neuron outputs:
np.dot(self.weights, self.inputs) + self.biases
- Apply the assigned activation function and return the output.
3. Define the MLP layers
- Two hidden layers, each with
hidden_sizeneurons and ReLU activation; - One output layer with
output_sizeneurons and sigmoid activation.
解答
すべて明確でしたか?
フィードバックありがとうございます!
セクション 2. 章 4
single
AIに質問する
AIに質問する
何でも質問するか、提案された質問の1つを試してチャットを始めてください