已知有如下几种子类,如何写父类
class MSE(NumpyMetric):
"""Calculates MSE and aggregates by summing across distr processes."""
def __init__(self, name="MSE", *args, **kwargs):
super().__init__(name=name, *args, **kwargs)
def forward(self, gt, pred):
return mse(gt, pred)
class NMSE(NumpyMetric):
"""Calculates NMSE and aggregates by summing across distr processes."""
def __init__(self, name="NMSE", *args, **kwargs):
super().__init__(name=name, *args, **kwargs)
def forward(self, gt, pred):
return nmse(gt, pred)
class PSNR(NumpyMetric):
"""Calculates PSNR and aggregates by summing across distr processes."""
def __init__(self, name="PSNR", *args, **kwargs):
super().__init__(name=name, *args, **kwargs)
def forward(self, gt, pred):
return psnr(gt, pred)
class SSIM(NumpyMetric):
"""Calculates SSIM and aggregates by summing across distr processes."""
def __init__(self, name="SSIM", *args, **kwargs):
super().__init__(name=name, *args, **kwargs)
def forward(self, gt, pred, maxval=None):
return ssim(gt, pred, maxval=maxval)