Commit 4f919a40 authored by Constantin Pape's avatar Constantin Pape
Browse files

Add spatial noise

parent 0026647e
......@@ -128,9 +128,25 @@ def random_uniform_noise(x):
return x * np.random.uniform(0.6, 2) + np.random.uniform(-0.2, 0.2)
def gaussian_spatial_noise(x, scale=(0.1, 1.0), execution_probability=0.25):
if np.random.uniform() < execution_probability:
std = np.random.uniform(scale[0], scale[1])
x += np.random.normal(scale=std, size=x.shape)
return x
def poisson_spatial_noise(x, lambda_=(0.1, 1.0), execution_probability=0.25):
if np.random.uniform() < execution_probability:
lam = np.random.uniform(lambda_[0], lambda_[1])
x += np.random.poisson(lam, size=x.shape)
return x
def augmenter(x, y):
x, y = random_flips_and_rotations(x, y)
x = random_uniform_noise(x)
x = gaussian_spatial_noise(x)
x = poisson_spatial_noise(x)
return x, y
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment