tf.nn.dropout(x, keep_prob, noise_shape=None, seed=None, name=None)###
Computes dropout.
计算dropout率。
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。缩放以便期望总和不变。
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,则x的形状必须为可广播的。
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 set_random_seed for behavior.
name: A name for this operation (optional).
参数:
x: 一个张量.
keep_prob: 一个跟x有相同类型的标量张量. 决定每个元素被保留的几率。
noise_shape: 一个int32类型的一维张量, 表示随机生成保留 / 丢弃 状态的形状。
seed: 一个Python整数,用来创建随机种子。可参见set_random_seed的行为.
name: 操作的名字 (可选参数).
Returns:
A Tensor of the same shape of x.
返回值:
一个形状跟x一样的张量.
Raises:
ValueError: If keep_prob is not in (0, 1].
可引起的错误:
值错误: 如果keep_prob不在(0, 1]之内.