Implemented Perlin as underlying epsilon dist
This commit is contained in:
parent
e44db33a91
commit
5f2d27efce
@ -1,6 +1,7 @@
|
||||
import numpy as np
|
||||
import torch as th
|
||||
import colorednoise as cn
|
||||
from perlin_noise import PerlinNoise
|
||||
from torch.distributions import Normal
|
||||
|
||||
|
||||
@ -78,3 +79,23 @@ class SDE_Noise():
|
||||
# (batch_size, 1, n_actions)
|
||||
noise = th.bmm(th.bmm(latent_sde, self.exploration_matrices), chol)
|
||||
return noise.squeeze(dim=1)
|
||||
|
||||
|
||||
class Perlin_Noise():
|
||||
def __init__(self, known_shape=None, scale=0.1, octaves=1):
|
||||
self.known_shape = known_shape
|
||||
self.scale = scale
|
||||
self.octaves = octaves
|
||||
self.magic = 3.14159 # Axis offset
|
||||
# We want to genrate samples, that approx ~N(0,1)
|
||||
self.normal_factor = 0.0471
|
||||
self.reset()
|
||||
|
||||
def __call__(self, shape):
|
||||
self.index += 1
|
||||
return [self.noise([self.index*self.scale, self.magic*a]) / self.normal_factor
|
||||
for a in range(self.shape[-1])]
|
||||
|
||||
def reset(self):
|
||||
self.index = 0
|
||||
self.noise = PerlinNoise(octaves=self.octaves)
|
||||
|
Loading…
Reference in New Issue
Block a user