tensorflow function笔记: dropout

来源:互联网 发布:新东方网络视频哪里买 编辑:程序博客网 时间:2024/04/26 00:02

Function

tf.nn.dropout(x, keep_prob, noise_shape=None, seed=None, name=None)

With probability keep_prob, outputs the input element scaled up by 1 / keep_prob, otherwise outputs 0. The scaling is so that the expected sum is unchanged.
输入元素有keep_prob 的几率按比例扩大1 / keep_prob 倍,否则输出为0. 比例为 1 / keep_prob 是为了使期望的总和不变。

By default, each element is kept or dropped independently. If noise_shape is specified, it must be broadcastable 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.

默认每个元素被保留或者扔掉是独立的。如果指定 noise_shape, 只有 noise_shape[i] == shape(x)[i] 的维度是独立的。 例如 shape(x) = [k, l, m, n] and noise_shape = [k, 1, 1, n], batch 和 channel 的元素被保留的概率是独立, row 和 column 状态相同。
x_out = tf.nn.dropout(x, 0.5, noise_shape = [k, 1, 1, n]),则对于固定的k和n和任意的l和m, x_out[k, l, m, n]相等。(一组image的tensor的四个维度分别称作 [batch, row, column, channel ] 或者 [batch, height, width, channel] )

Args

x: A tensor.

keep_prob: A scalar Tensor with the same type as x. The probability that each element is kept.

noise_shape: A 1-D Tensor of type int32, representing the shape for randomly generated keep/drop flags.

seed: A Python integer. Used to create random seeds. See tf.set_random_seed for behavior.

name: A name for this operation (optional).

Returns

A Tensor of the same shape of x.

0 0
原创粉丝点击