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

 

发布了277 篇原创文章 · 获赞 76 · 访问量 30万+

猜你喜欢

转载自blog.csdn.net/songyuc/article/details/104377480