Example #1
0
 def __init__(self,
              max_val=1.0,
              filter_size=11,
              filter_sigma=1.5,
              k1=0.01,
              k2=0.03):
     super(SSIM, self).__init__()
     validator.check_type('max_val', max_val, [int, float])
     validator.check('max_val', max_val, '', 0.0, Rel.GT)
     self.max_val = max_val
     self.filter_size = validator.check_integer('filter_size', filter_size,
                                                1, Rel.GE)
     self.filter_sigma = validator.check_float_positive(
         'filter_sigma', filter_sigma)
     validator.check_type('k1', k1, [float])
     self.k1 = validator.check_number_range('k1', k1, 0.0, 1.0,
                                            Rel.INC_NEITHER)
     validator.check_type('k2', k2, [float])
     self.k2 = validator.check_number_range('k2', k2, 0.0, 1.0,
                                            Rel.INC_NEITHER)
     self.mean = P.DepthwiseConv2dNative(channel_multiplier=1,
                                         kernel_size=filter_size)
Example #2
0
def _check_param(initial_accum,
                 learning_rate,
                 lr_power,
                 l1,
                 l2,
                 use_locking,
                 loss_scale=1.0,
                 weight_decay=0.0):
    validator.check_type("initial_accum", initial_accum, [float])
    validator.check("initial_accum", initial_accum, "", 0.0, Rel.GE)

    validator.check_type("learning_rate", learning_rate, [float])
    validator.check("learning_rate", learning_rate, "", 0.0, Rel.GT)

    validator.check_type("lr_power", lr_power, [float])
    validator.check("lr_power", lr_power, "", 0.0, Rel.LE)

    validator.check_type("l1", l1, [float])
    validator.check("l1", l1, "", 0.0, Rel.GE)

    validator.check_type("l2", l2, [float])
    validator.check("l2", l2, "", 0.0, Rel.GE)

    validator.check_type("use_locking", use_locking, [bool])

    validator.check_type("loss_scale", loss_scale, [float])
    validator.check("loss_scale", loss_scale, "", 1.0, Rel.GE)

    validator.check_type("weight_decay", weight_decay, [float])
    validator.check("weight_decay", weight_decay, "", 0.0, Rel.GE)
Example #3
0
 def __init__(self, max_val=1.0):
     super(PSNR, self).__init__()
     validator.check_type('max_val', max_val, [int, float])
     validator.check('max_val', max_val, '', 0.0, Rel.GT)
     self.max_val = max_val