From c68fd1635da262e6ef35058e991a8b2bda32c447 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Sun, 10 Sep 2023 14:46:38 +0200 Subject: [PATCH] Made normalization prettier --- priorConditionedAnnealing/noise.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/priorConditionedAnnealing/noise.py b/priorConditionedAnnealing/noise.py index ad88d72..9f7978f 100644 --- a/priorConditionedAnnealing/noise.py +++ b/priorConditionedAnnealing/noise.py @@ -4,6 +4,7 @@ import colorednoise as cn from perlin_noise import PerlinNoise from torch.distributions import Normal +PI = 3.1415926535897932384626433 class Colored_Noise(): def __init__(self, known_shape=None, beta=1, num_samples=2**14, random_state=None): @@ -102,9 +103,9 @@ class Perlin_Noise(): self.known_shape = known_shape self.scale = scale self.octave = octave - self.magic = 3.141592653589 # Axis offset, should be (kinda) irrational + self.magic = PI # Axis offset, should be (kinda) irrational # We want to genrate samples, that approx ~N(0,1) - self.normal_factor = 14/99 + self.normal_factor = PI/20 self.clear_cache_every = 128 self.reset() @@ -112,7 +113,7 @@ class Perlin_Noise(): if shape == None: shape = self.known_shape self.index += 1 - noise = [self.noise([self.index*self.scale, self.magic*(1+a)]) / self.normal_factor + noise = [self.noise([self.index*self.scale, self.magic+(2*a)]) / self.normal_factor for a in range(shape[-1])] if self.index % self.clear_cache_every == 0: self.noise.cache = {}