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
评论列表
文章目录