model.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:self-driving-cars 作者: musyoku 项目源码 文件源码
def forward_one_step(self, x, test):
        f = activations[self.activation_function]
        chain = [x]

        # Hidden layers
        for i in range(self.n_hidden_layers):
            u = getattr(self, "layer_%i" % i)(chain[-1])
            if self.apply_batchnorm:
                if i == 0 and self.apply_batchnorm_to_input is False:
                    pass
                else:
                    u = getattr(self, "batchnorm_%i" % i)(u, test=test)
            output = f(u)
            if self.apply_dropout:
                output = F.dropout(output, train=not test)
            chain.append(output)

        # Output
        u = getattr(self, "layer_%i" % self.n_hidden_layers)(chain[-1])
        if self.apply_batchnorm:
            u = getattr(self, "batchnorm_%i" % self.n_hidden_layers)(u, test=test)
        chain.append(f(u))

        return chain[-1]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号