def project_params(self, lp, lp_bound): """ Projects the params to be within lp_bound (according to an lp) of the identity map. First thing we do is clip the params to be valid, too ARGS: lp : int or 'inf' - which LP norm we use. Must be an int or the string 'inf' lp_bound : float - how far we're allowed to go in LP land RETURNS: None, but modifies self.xform_params """ assert isinstance(lp, int) or lp == 'inf' diff = self.xform_params.data new_diff = utils.batchwise_lp_project(diff, lp, lp_bound) self.xform_params.data.add_(new_diff - diff)
def constrain_params(self): new_delta = utils.batchwise_lp_project(self.delta.data, self.lp_style, self.lp_bound) delta_diff = new_delta - self.delta.data self.delta.data.add_(delta_diff)
def project_params(self, lp, lp_bound): assert isinstance(lp, int) or lp == 'inf' diff = self.xform_params.data - self.identity_params(self.img_shape) new_diff = utils.batchwise_lp_project(diff, lp, lp_bound) self.xform_params.data.add_(new_diff - diff)