Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about L2 regularization(weight decay) #108

Closed
agave233 opened this issue Apr 23, 2019 · 1 comment
Closed

Question about L2 regularization(weight decay) #108

agave233 opened this issue Apr 23, 2019 · 1 comment

Comments

@agave233
Copy link

Hi ,
when I read your code, for var in self.layers[0].vars.values() shows that the L2 regularization only contains vars of the first layer, why not all layers? I am confused about this.

def _loss(self):
    # Weight decay loss
    for var in self.layers[0].vars.values():
        self.loss += FLAGS.weight_decay * tf.nn.l2_loss(var)

    # Cross entropy error
    self.loss += masked_softmax_cross_entropy(self.outputs, self.placeholders['labels'],
                                              self.placeholders['labels_mask'])

Thanks!

@tkipf
Copy link
Owner

tkipf commented Apr 24, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants