def score(guess, e, v, per_pixel=False): """calculates cost function of given surface guess - surface to measure e - image of original surface v - light vector used to iluminate original surface per_pixel - if True, cost value is divided by number comparision points """ e_guess = surface2im(guess, v) cost = (e_guess - e)**2 if per_pixel: cost = torch.average(cost) return torch.sum(cost)
def average(*args, **kwargs): return torch.average(*args, **kwargs)