joint_model.py 文件源码

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

项目:age 作者: ly015 项目源码 文件源码
def _compute_age(self, feat_relu):
        '''
        input:
            feat: output of feat_embed layer (after relu)
        output:
            age_out
            age_fc_out
        '''
        age_fc_out = self.age_cls(feat_relu)

        if self.opts.cls_type == 'dex':
            # deep expectation
            age_scale = np.arange(self.opts.min_age, self.opts.max_age + 1, 1.0)
            age_scale = Variable(age_fc_out.data.new(age_scale)).unsqueeze(1)

            age_out = torch.matmul(F.softmax(age_fc_out), age_scale).view(-1)

        elif self.opts.cls_type == 'oh':
            # ordinal hyperplane
            age_fc_out = F.sigmoid(age_fc_out)
            age_out = age_fc_out.sum(dim = 1) + self.opts.min_age

        elif self.opts.cls_type == 'reg':
            # regression
            age_out = self.age_fc_out.view(-1) + self.opts.min_age

        return age_out, age_fc_out
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号