Can’t seem to make this work, any idea anyone @apaszke @smth ? I got the following error:
ValueError: optimizer got an empty parameter list

I tried the following but the clipper doesn’t seem to work, still get negative weights despite softmax clip. Seems like it’s not assigning the new values to replace the original weight matrix.

class MaxOneClipper(object):

    def __init__(self, frequency=1):
        self.frequency = frequency

    def __call__(self, module):
        # filter the variables to get the ones you want
        if hasattr(module, 'weight'):
            w = module.weight
            sm = nn.Softmax()
            w = sm(w)

clipper = MaxOneClipper

for i in range(10):
    net.apply(clipper)