1 致謝
感謝Facebook的開發者的辛苦和努力~
(給Google只有兩個字“呵呵”)
2 深度神經網絡的搭建
2.1 Module的添加
使用nn.Module.add_module()函數,
add_module()函數內部,改變的是_modules成員變量,_modules是一個OrderedDict類型的變量,
代碼如下,
[docs] def add_module(self, name, module):
r"""Adds a child module to the current module.
The module can be accessed as an attribute using the given name.
Args:
name (string): name of the child module. The child module can be
accessed from this module using the given name
module (Module): child module to be added to the module.
"""
# other code
self._modules[name] = module