首页 > 解决方案 > 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) 

完整代码- https://pytorch.org/tutorials/beginner/blitz/neural_networks_tutorial.html#sphx-glr-beginner-blitz-neural-networks-tutorial-py

标签: python-3.xpytorchconv-neural-network

解决方案



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 layer84 英寸second layer和 10 英寸的单位数,last其中可能是您​​的output layerie 的尺寸。10 种可能的分类类型。你是正确的dimension of second and third layer is not fixed并且you can try different value of num of units选择一个能给你最好结果的。您可以使用它,但您也可以查看一些性能最佳的模型并遵循它们使用的结构。


推荐阅读