PyTorch——深度神經網絡的寫作筆記

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

 

 

發佈了275 篇原創文章 · 獲贊 76 · 訪問量 30萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章