How to caculate numWeightElements in network?

조회 수: 4 (최근 30일)
Le Xuan Thang
Le Xuan Thang 2019년 8월 10일
댓글: Le Xuan Thang 2024년 12월 20일
I have a problem that when I code:
net=configure(net,inputs,targets)
When targets is 1 output I Think function to caculation numWeightElements(NWE) is:
NWE=m*n+n+n+o;(1)
Where:
- m: number of input layers
- n: number of hidden layers
- o: number of output layers
But when it is 2 output
Example: for 2 output
inputs: 25x550
outputs: 2x550
m = 25;
n =5 ;
o = 2;
Equation(1)is = 137 and It is not truth when I checked net.numWeightElements is 142
Can anyone help me explain this?
Thanks
LXT

채택된 답변

Ayush Aniket
Ayush Aniket 2024년 12월 20일
The discrepancy in the calculation of the number of weight elements net.numWeightElements arises from the structure of the neural network and the connections between layers. Let's break down the calculation for a neural network with one hidden layer and two outputs:
1. Inputs to Hidden Layer:
  • Number of inputs (m) = 25
  • Number of neurons in the hidden layer (n) = 5
  • Weights from inputs to hidden layer: m * n = 25 * 5 = 125
  • Biases for hidden layer neurons: n = 5
2. Hidden Layer to Output Layer:
  • Number of outputs (o) = 2
  • Weights from hidden layer to output layer: n * o = 5 * 2 = 10
  • Biases for output layer neurons: o = 2
The total number of weight elements is the sum of all weights and biases:
Total Weights = (m * n) + n + (n * o) + o = (25 * 5) + 5 + (5 * 2) + 2 = 125 + 5 + 10 + 2 = 142
This matches the value you observed (net.numWeightElements = 142). The original equation you used didn't account for all biases and connections between layers.
  댓글 수: 1
Le Xuan Thang
Le Xuan Thang 2024년 12월 20일
It've been 4 since 2019 :D. Btw, thank you so much. Its correct.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by