Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Creating a Neural Network Layer | Neural Networks Foundations
Introduction to TensorFlow
セクション 3.  1
single

single

bookCreating a Neural Network Layer

メニューを表示するにはスワイプしてください

Single Neural Network Layer

In a basic feed-forward neural network, the output of a neuron in a layer is calculated using the weighted sum of its inputs, passed through an activation function. This can be represented as:

y=σ(Wx+b)y=\sigma(W \cdot x + b)

Where:

  • yy: output of the neuron;
  • WW: a matrix representing the weights associated with connections to the neuron;
  • xx: a column matrix (or vector) representing the input values to the neuron;
  • bb: a scalar value;
  • σ\sigma: an activation function, such as the sigmoid, ReLU or softmax function.

To achieve the best performance, all calculations are performed using matrices. We will cope with this task in the same way.

タスク

スワイプしてコーディングを開始

Given weights, inputs, and bias for a single neuron layer, compute its output using matrix multiplication and the sigmoid activation function. Consider a layer with 3 inputs and 2 neurons, taking a single batch containing just one sample.

  1. Determining Shapes:

    • The shape of the input matrix I should have its first dimension representing the number of samples in the batch. Given one sample with 3 inputs, its size will be 1x3;
    • The weight matrix W should have its columns representing input weights for each neuron. So for 2 neurons with 3 inputs, the expected shape is 3x2. This isn't the case, so you need to transpose the weight matrix to achieve the required shape.
  2. Matrix Multiplication:

    • With the matrices in the correct shape, perform the matrix multiplication;
    • Recall that in matrix multiplication, the output is derived from the dot product of each row of the first matrix with each column of the second matrix. Ensure you multiply in the right order.
  3. Bias Addition:

    • Simply perform an element-wise addition of the result from the matrix multiplication with the bias.
  4. Applying Activation:

    • Use the sigmoid activation function on the outcome from the bias addition to get the output of the neuron;
    • TensorFlow provides the sigmoid function as tf.sigmoid().

Note

In the end of the course we'll delve into implementing a complete feed-forward network using TensorFlow. This exercise is setting the foundation for that.

解答

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

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

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

セクション 3.  1
single

single

AIに質問する

expand

AIに質問する

ChatGPT

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

some-alt