def construct(self, input_ids): """evaluation net""" input_mask = F.cast(F.not_equal(input_ids, 0), mstype.float32) logits = self.backbone(input_ids, input_mask) outputs = None if self.generate: outputs = nn.LogSoftmax()(logits) outputs = F.tensor_pow(np.e, outputs) else: outputs = self.argmax(logits) return outputs
def construct(self, x): _, max_value = self.max(x) exp_x = F.tensor_pow(np.e, x - max_value) sum_x = self.sum(exp_x, self.axis) output = exp_x / sum_x return output