tf.nn.dropout使用参考

一、 embedding + dropout.

embedded = tf.nn.embedding_lookup(self.var, x)
if self.keep_prob < 1.:
	shape = embedded.get_shape().as_list()
	# Use same dropout masks at each timestep with specifying noise_shape.
    # This slightly improves performance.
    # Please see https://arxiv.org/abs/1512.05287 for the theoretical
    # explanation.
	embedded = tf.nn.dropout(embedded, 'self.keep_prob, noise_shape=(shape[0], 1, shape[2]))
    return embedded       

该代码, 在lookup后的embedded进行了drop_out ,并且使用了noise_shape, 据说是有提升的。

  • noise_shape
By default, each element is kept or dropped independently.  If `noise_shape`
is specified, it must be [broadcastable](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html)
to the shape of `x`, and only dimensions with `noise_shape[i] == shape(x)[i]`
will make independent decisions.  For example, if `shape(x) = [k, l, m, n]`
and `noise_shape = [k, 1, 1, n]`, each batch and channel component will be
kept independently and each row and column will be kept or not kept together.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值