age_model.py 文件源码

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

项目:age 作者: ly015 项目源码 文件源码
def _forward_age_cls(self, feat):
        '''
        Input:
            feat: CNN feature (ReLUed)
        Output:
            age_out: output age prediction (for evaluation)
            age_fc: final fc layer output (for compute loss)

        '''
        #fc_out = self.age_cls(feat)
        fc_out = self.age_cls(F.relu(feat))

        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(fc_out.data.new(age_scale)).unsqueeze(1)

            age_out = torch.matmul(F.softmax(fc_out), age_scalei).view(-1)


        elif self.opts.cls_type == 'oh':
            # Ordinal Hyperplane
            fc_out = F.sigmoid(fc_out)
            age_out = fc_out.sum(dim = 1) + self.opts.min_age

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

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


问题


面经


文章

微信
公众号

扫码关注公众号