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]之內.