機能とnp.nanmean同じ機能のカスタムトーチ(一つだけ次元を行うことができます)

def torch_nanmean(x):
    num = torch.where(torch.isnan(x), torch.full_like(x, 0), torch.full_like(x, 1)).sum()
    value = torch.where(torch.isnan(x), torch.full_like(x, 0), x).sum()
    return value / num

 

公開された38元の記事 98ウォンの賞賛 ビュー360 000 +

おすすめ

転載: blog.csdn.net/xijuezhu8128/article/details/86590673