python-3.x - pytorch 神经网络中的这些数字来自哪里?
问题描述
我是 Pytorch (python) 的新手,我刚刚浏览了他们的官方教程,发现了这个简单的神经网络架构。一切都很清楚,但是那些数字,最后三个全连接层,它们来自哪里?
self.fc1 = nn.Linear(16 * 6 * 6, 120) # 6*6 from image dimension and 16 from last conv layer
self.fc2 = nn.Linear(120, 84) # but here, 120? 84? why? is this just random or there is some logic behind it?
self.fc3 = nn.Linear(84, 10)
解决方案
self.fc1 = nn.Linear(16 * 6 * 6, 120)
self.fc2 = nn.Linear(120, 84) # you can use any number instead of 120 play with this number and see which gives you best result.
self.fc3 = nn.Linear(84, 10)
120 是first layer after conv layer
84 英寸second layer
和 10 英寸的单位数,last
其中可能是您的output layer
ie 的尺寸。10 种可能的分类类型。你是正确的dimension of second and third layer is not fixed
并且you can try different value of num of units
选择一个能给你最好结果的。您可以使用它,但您也可以查看一些性能最佳的模型并遵循它们使用的结构。
推荐阅读
- azure - Azure SNAT 耗尽 - 我如何知道它何时发生?
- javascript - 依赖于其范围之外的变量的函数会导致 Javascript 中的内存泄漏?
- python - 让我的乌龟在遇到另一只乌龟时变大
- c - 以下 strncpy 调用的解释
- javascript - toLocaleString - 如果不是 .00,则仅显示小数
- java - 按表示项目位置的可空字段排序
- function - Azure Functional App 2.0 Sql 不支持错误
- redis - redis排序集中基于时间间隔的桶
- java - 为什么我可以实例化抽象类和接口的对象?构造函数中的 super 是什么?
- image-processing - 是否有一种视频格式,其彩色视频的大小是其灰度版本的三倍?