Ensure returns from noise are always Tensors

This commit is contained in:
Dominik Moritz Roth 2023-05-21 20:28:52 +02:00
parent dcde2150ac
commit bf22f42cb3

View File

@ -15,10 +15,10 @@ class Colored_Noise():
self.reset(random_state=random_state) self.reset(random_state=random_state)
def __call__(self, shape, latent: th.Tensor = None) -> th.Tensor: def __call__(self, shape, latent: th.Tensor = None) -> th.Tensor:
assert shape == self.knonw_shape assert shape == self.known_shape
sample = self.samples[:, self.index] sample = self.samples[:, self.index]
self.index = (self.index+1) % self.num_samples self.index = (self.index+1) % self.num_samples
return sample return th.Tensor(sample)
def reset(self, random_state=None): def reset(self, random_state=None):
self.samples = cn.powerlaw_psd_gaussian( self.samples = cn.powerlaw_psd_gaussian(
@ -100,8 +100,9 @@ class Perlin_Noise():
def __call__(self, shape): def __call__(self, shape):
self.index += 1 self.index += 1
return [self.noise([self.index*self.scale, self.magic*(a+1)]) / self.normal_factor noise = [self.noise([self.index*self.scale, self.magic*(a+1)]) / self.normal_factor
for a in range(self.known_shape[-1])] for a in range(self.known_shape[-1])]
return th.Tensor(noise)
def reset(self): def reset(self):
self.index = 0 self.index = 0