参数数量估算

🔮 Neural Network Parameter Count Estimator

Estimate the parameter count of fully-connected and convolutional layers from layer widths, kernel sizes and channel counts. Useful for model sizing and memory budgeting.

📐 计算公式 / 原理
全连接参数 = in × out + out(偏置);3×3 卷积参数 = in × out × 9 + out;显存 MB = 参数 × 4 / 1024 / 1024
按层的权重矩阵规模累加估算参数量,再按每参数 4 字节(FP32)折算显存。这只是推理权重的下限,训练还要额外放梯度、优化器状态(Adam 再翻 2 倍)与激活值,实际占用通常是权重的 4–6 倍。

📐 计算公式与说明

全连接:params = in × out + out(bias)
卷积 3×3:params = in × out × 9 + out

用于快速估算模型规模。

📚 深度解析:参数数量估算

💡 常见使用场景

卷积层参数量
3×3 卷积、输入通道 64、输出通道 128:参数=(3²×64+1)×128=(576+1)×128=73728。若改为深度可分离(3×3×64+1×64×128)=576+8192=8768,仅为原先约 12%。

❓ 常见问题(FAQ)

为什么卷积层参数量远小于全连接?
卷积权值共享且局部连接,参数只与核大小、通道数有关,与特征图尺寸无关;全连接则随输入输出维度乘积增长。
偏置是否总要加?
并非必须。BN 后接的卷积常设 bias=False 以免冗余;最后一层或需学习截距时保留偏置。

Formula & Standard References

Item Formula / Note Source / Standard
Dense layer parameters = input size x output size plus biases Deep learning texts
Convolution layer parameters = kernel area x in channels x out channels plus biases Deep learning texts
Attention block self attention costs roughly twelve times the square of the model width Attention Is All You Need

如何使用参数数量估算

  1. 按页面提示逐项填写或选择所需参数。
  2. 点击「计算」或「生成」按钮运行。
  3. 在结果区查看输出,可复制结果或导出使用。

参数说明

适用场景

全连接层参数=(输入维度+1)×输出维度,+1 为偏置。

常见问题

为什么卷积层参数量远小于全连接?
卷积权值共享且局部连接,参数只与核大小、通道数有关,与特征图尺寸无关;全连接则随输入输出维度乘积增长。
偏置是否总要加?
并非必须。BN 后接的卷积常设 bias=False 以免冗余;最后一层或需学习截距时保留偏置。