map2map/map2map/models/instance_noise.py
Yin Li 29ab550032 Change instance noise
Simpler linear annealing as in the blog post;
different noise to output and target
2020-07-11 01:56:46 -04:00

15 lines
398 B
Python

import torch
class InstanceNoise:
"""Instance noise, with a linear decaying schedule
"""
def __init__(self, init_std, batches):
assert init_std >= 0, 'Noise std cannot be negative'
self.init_std = init_std
self._std = init_std
self.batches = batches
def std(self):
self._std -= self.init_std / self.batches
return max(self._std, 0)