You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何计算神经网络的连接数?附具体网络结构参数场景

Got it, let's break down the number of trainable parameters (which includes both weight connections and bias terms) for your neural network step by step—this is a common point of confusion, so let's unpack it clearly.

Calculating Parameters in Your Fully Connected Neural Network

First, a quick clarification: when we talk about "connections" in this context, we’re referring to all trainable parameters: the weights that link neurons between layers, plus the bias terms for every neuron in non-input layers (as you specified, only the input layer skips biases).

Let’s go through each layer transition one by one:

1. Input Layer (784 units) → First Hidden Layer (400 units)

  • Weight connections: Every neuron in the first hidden layer connects to every neuron in the input layer. That’s 784 * 400 = 313,600 individual weights.
  • Bias terms: Each of the 400 hidden neurons has one bias term, so that’s 400 biases.
  • Total for this segment: 313,600 + 400 = 314,000 parameters.

2. First Hidden Layer (400 units) → Second Hidden Layer (200 units)

  • Weight connections: Every neuron in the second hidden layer links to all 400 neurons in the first hidden layer. That’s 400 * 200 = 80,000 weights.
  • Bias terms: 200 neurons mean 200 bias terms.
  • Total for this segment: 80,000 + 200 = 80,200 parameters.

3. Second Hidden Layer (200 units) → Output Layer (10 units)

  • Weight connections: Each of the 10 output neurons connects to all 200 neurons in the second hidden layer. That’s 200 * 10 = 2,000 weights.
  • Bias terms: 10 output neurons mean 10 bias terms.
  • Total for this segment: 2,000 + 10 = 2,010 parameters.

Total Trainable Parameters (Full Network)

Add up all the segments:
314,000 + 80,200 + 2,010 = 396,210 total parameters.

Quick Formula to Verify

For any fully connected layer transition from a layer with n units to a layer with m units, the total parameters are (n * m) + m (weights plus biases). Applying this to each of your transitions gives the same result as above.

This should resolve the uncertainty—breaking it down layer by layer makes it easier to avoid missing biases or miscalculating weight counts.

内容的提问来源于stack exchange,提问作者haruishi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 08:11:29