add sync_rayleight_perlin
This commit is contained in:
parent
9f52e0a88e
commit
8b1d588b5e
@ -100,7 +100,6 @@ class SDE_Noise():
|
|||||||
noise = th.bmm(th.bmm(latent_sde, self.exploration_matrices), chol)
|
noise = th.bmm(th.bmm(latent_sde, self.exploration_matrices), chol)
|
||||||
return noise.squeeze(dim=1)
|
return noise.squeeze(dim=1)
|
||||||
|
|
||||||
|
|
||||||
class Perlin_Noise():
|
class Perlin_Noise():
|
||||||
def __init__(self, known_shape=None, scale=0.1, octave=1):
|
def __init__(self, known_shape=None, scale=0.1, octave=1):
|
||||||
self.known_shape = known_shape
|
self.known_shape = known_shape
|
||||||
@ -126,7 +125,7 @@ class Perlin_Noise():
|
|||||||
self.index = 0
|
self.index = 0
|
||||||
self.noise = PerlinNoise(octaves=self.octave)
|
self.noise = PerlinNoise(octaves=self.octave)
|
||||||
|
|
||||||
class P_Perlin_Noise():
|
class Async_Perlin_Noise():
|
||||||
def __init__(self, known_shape=None, scale=0.1, octave=1):
|
def __init__(self, known_shape=None, scale=0.1, octave=1):
|
||||||
self.known_shape = known_shape
|
self.known_shape = known_shape
|
||||||
self.scale = scale
|
self.scale = scale
|
||||||
@ -220,4 +219,30 @@ class Rayleigh_Perlin_Noise():
|
|||||||
def reset(self):
|
def reset(self):
|
||||||
self.index = 0
|
self.index = 0
|
||||||
self.scales = np.random.rayleigh(scale=self.sigma, size=np.prod(self.known_shape[:-1]))
|
self.scales = np.random.rayleigh(scale=self.sigma, size=np.prod(self.known_shape[:-1]))
|
||||||
self.noise = PerlinNoise(octaves=1)
|
self.noise = PerlinNoise(octaves=1)
|
||||||
|
|
||||||
|
class Sync_Rayleigh_Perlin_Noise():
|
||||||
|
def __init__(self, known_shape=None, sigma=0.1):
|
||||||
|
self.known_shape = known_shape
|
||||||
|
self.sigma = sigma
|
||||||
|
self.magic = PI # Axis offset, should be (kinda) irrational
|
||||||
|
# We want to genrate samples, that approx ~N(0,1)
|
||||||
|
self.normal_factor = PI/20
|
||||||
|
self.clear_cache_every = 128
|
||||||
|
self.reset()
|
||||||
|
|
||||||
|
def __call__(self, shape=None):
|
||||||
|
if shape == None:
|
||||||
|
shape = self.known_shape
|
||||||
|
self.index += 1
|
||||||
|
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 = {}
|
||||||
|
return th.Tensor(noise)
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
self.index = 0
|
||||||
|
self.scale = np.random.rayleigh(scale=self.sigma, size=(1,))[0]
|
||||||
|
self.noise = PerlinNoise(octaves=1)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user