Exemplo n.º 1
0
    def parameters(self):
        params, grads = [], []

        if hasattr(self, 'weight'):
            assert hasattr(self, 'grad_weight'), "The layer {} has a `weight` variable but no `grad_weight`, you probably forget to implement it.".format(df.classname(self))
            params += [self.weight]
            grads += [self.grad_weight]

        if hasattr(self, 'bias'):
            assert hasattr(self, 'grad_bias'), "The layer {} has a `bias` variable but no `grad_bias`, you probably forget to implement it.".format(df.classname(self))
            params += [self.bias]
            grads += [self.grad_bias]

        return params, grads