|
|
|||
File indexing completed on 2025-12-16 09:18:06
0001 import torch 0002 import torch.nn.functional as F 0003 0004 def monotonic_loss(y_pred): 0005 """ 0006 计算 y_pred 单调递减违反程度 0007 如果 y_{i+1} > y_i,算 penalty 0008 """ 0009 dy = y_pred[1:] - y_pred[:-1]c 0010 penalty = F.relu(dy).sum() # relu(dy) > 0 部分是违反单调递减的 0011 return penalty
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|