將 Dropout 應用於輸入。
繼承自:Dropout
、Layer
、Layer
、Module
用法
tf.compat.v1.layers.Dropout(
rate=0.5, noise_shape=None, seed=None, name=None, **kwargs
)
參數
-
rate
輟學率,介於 0 和 1 之間。rate=0.1
會丟棄 10% 的輸入單元。 -
noise_shape
int32
類型的一維張量,表示將與輸入相乘的二進製丟失掩碼的形狀。例如,如果您的輸入具有形狀(batch_size, timesteps, features)
,並且您希望所有時間步的 dropout 掩碼都相同,則可以使用noise_shape=[batch_size, 1, features]
。 -
seed
一個 Python 整數。用於創建隨機種子。見tf.compat.v1.set_random_seed
。為行為。 -
name
圖層的名稱(字符串)。
屬性
-
graph
-
scope_name
遷移到 TF2
警告:這個 API 是為 TensorFlow v1 設計的。繼續閱讀有關如何從該 API 遷移到本機 TensorFlow v2 等效項的詳細信息。見TensorFlow v1 到 TensorFlow v2 遷移指南有關如何遷移其餘代碼的說明。
此 API 是一個遺留 api,僅與 Eager Execution 和 tf.function
兼容,如果您將其與 tf.compat.v1.keras.utils.track_tf1_style_variables
結合使用
請參閱遷移指南的 tf.layers 模型映射部分,了解如何在 TF2 中將 TensorFlow v1 模型與 Keras 一起使用。
對應的 TensorFlow v2 層是 tf.keras.layers.Dropout
。
到原生 TF2 的結構映射
支持的參數均未更改名稱。
前:
dropout = tf.compat.v1.layers.Dropout()
後:
dropout = tf.keras.layers.Dropout()
Dropout 包括在訓練期間的每次更新時將輸入單元的分數 rate
隨機設置為 0,這有助於防止過度擬合。保留的單元按 1 / (1 - rate)
縮放,因此它們的總和在訓練時和推理時不變。
相關用法
- Python tf.compat.v1.layers.Dense用法及代碼示例
- Python tf.compat.v1.layers.conv3d用法及代碼示例
- Python tf.compat.v1.layers.Conv3D用法及代碼示例
- Python tf.compat.v1.layers.dense用法及代碼示例
- Python tf.compat.v1.layers.AveragePooling3D用法及代碼示例
- Python tf.compat.v1.layers.Conv2DTranspose用法及代碼示例
- Python tf.compat.v1.layers.max_pooling3d用法及代碼示例
- Python tf.compat.v1.layers.average_pooling1d用法及代碼示例
- Python tf.compat.v1.layers.experimental.keras_style_scope用法及代碼示例
- Python tf.compat.v1.layers.flatten用法及代碼示例
- Python tf.compat.v1.layers.conv1d用法及代碼示例
- Python tf.compat.v1.layers.experimental.set_keras_style用法及代碼示例
- Python tf.compat.v1.layers.conv2d_transpose用法及代碼示例
- Python tf.compat.v1.layers.dropout用法及代碼示例
- Python tf.compat.v1.layers.batch_normalization用法及代碼示例
- Python tf.compat.v1.layers.average_pooling2d用法及代碼示例
- Python tf.compat.v1.layers.MaxPooling1D用法及代碼示例
- Python tf.compat.v1.layers.conv2d用法及代碼示例
- Python tf.compat.v1.layers.Conv2D用法及代碼示例
- Python tf.compat.v1.layers.AveragePooling1D用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.compat.v1.layers.Dropout。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。