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

用新版本中的方法定义输出层,怎么添加l2正则到loss中 #4

Open
mfxss opened this issue May 3, 2018 · 0 comments
Open

Comments

@mfxss
Copy link

mfxss commented May 3, 2018

        self.scores =tf.layers.dense(self.h_drop,num_classes,name='scores',kernel_initializer=tf.contrib.layers.xavier_initializer(),bias_initializer=tf.constant_initializer(0.1))

        # W = tf.get_variable(
        #     "W",
        #     shape=[num_filters_total, num_classes],
        #     initializer=tf.contrib.layers.xavier_initializer())
        # b = tf.Variable(tf.constant(0.1, shape=[num_classes]), name="b")
        # l2_loss += tf.nn.l2_loss(W)
        # l2_loss += tf.nn.l2_loss(b)
        # print(self.scores.shape)
        # self.scores = tf.nn.xw_plus_b(self.h_drop, W, b, name="scores")
        
        self.predictions = tf.argmax(self.scores, 1, name="predictions")


在这里面被注释的这些,我用开头的一句话tf.layers.dense代替了,这个方法有kernel_regularizer,但是不知道这里的kernel_regularizer会不会加入到loss中去。
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

1 participant