(self)
| 51 | self.tokens_count += 1 |
| 52 | |
| 53 | def eval(self): |
| 54 | if not self.is_last_stage: |
| 55 | return 0 |
| 56 | if self.tokens_count == 0: |
| 57 | print("Warning: tokens_count is 0") |
| 58 | return 0 |
| 59 | val_loss = sum(self.PPL) / (self.tokens_count * self.data_length) |
| 60 | ppl = math.exp(min(20, val_loss)) |
| 61 | # print("====" * 20 + " ppl end") |
| 62 | # print("====" * 20 + " ppl: {}".format(ppl)) |
| 63 | # return ppl |
| 64 | return val_loss |
| 65 | |
| 66 | |
| 67 | class ValidationLoss(Metric): |
no outgoing calls