Rewrite instance noise annealing scheduler
This commit is contained in:
parent
7a0f0bd979
commit
ccb323e6ee
@ -6,13 +6,12 @@ class InstanceNoise:
|
|||||||
"""
|
"""
|
||||||
def __init__(self, init_std):
|
def __init__(self, init_std):
|
||||||
self.init_std = init_std
|
self.init_std = init_std
|
||||||
self.adv_loss_cum = 0
|
self.anneal = 1
|
||||||
self.ln2 = log(2)
|
self.ln2 = log(2)
|
||||||
self.batches = 1e5
|
self.batches = 1e5
|
||||||
|
|
||||||
def std(self, adv_loss):
|
def std(self, adv_loss):
|
||||||
self.adv_loss_cum += adv_loss
|
self.anneal -= adv_loss / self.ln2 / self.batches
|
||||||
anneal = 1 - self.adv_loss_cum / self.ln2 / self.batches
|
std = self.anneal * self.init_std
|
||||||
anneal = anneal if anneal > 0 else 0
|
std = std if std > 0 else 0
|
||||||
std = anneal * self.init_std
|
|
||||||
return std
|
return std
|
||||||
|
Loading…
Reference in New Issue
Block a user