Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Challenge: Creating a Perceptron | Neural Network from Scratch
Introduction to Neural Networks with Python
セクション 2.  4
single

single

bookChallenge: 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:

  1. An input layer;
  2. Two hidden layers (same neuron count, ReLU);
  3. 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_size neurons and ReLU activation;
  • One output layer with output_size neurons and sigmoid activation.

解答

Switch to desktop実践的な練習のためにデスクトップに切り替える下記のオプションのいずれかを利用して、現在の場所から続行する
すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 2.  4
single

single

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

some-alt