ノートPyTorch--深ニューラルネットワークを書きます

謝辞

Facebookの開発者のハードワークと努力のおかげで -

(Googleの「あ」の2つだけの単語)

ビルド深さ2ニューラルネットワーク

2.1モジュールの追加

使用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

 

 

公開された277元の記事 ウォン称賛76 ビュー30万+

おすすめ

転載: blog.csdn.net/songyuc/article/details/104377480