展平輸入張量,同時保留批處理軸(軸 0)。
繼承自:Flatten
、Layer
、Layer
、Module
用法
tf.compat.v1.layers.Flatten(
data_format=None, **kwargs
)
參數
-
data_format
一個字符串,是channels_last
(默認)或channels_first
之一。輸入中維度的排序。channels_last
對應於形狀為(batch, ..., channels)
的輸入,而channels_first
對應於形狀為(batch, channels, ...)
的輸入。
屬性
-
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.Flatten
。
到原生 TF2 的結構映射
支持的參數均未更改名稱。
前:
flatten = tf.compat.v1.layers.Flatten()
後:
flatten = tf.keras.layers.Flatten()
例子:
x = tf.compat.v1.placeholder(shape=(None, 4, 4), dtype='float32')
y = Flatten()(x)
# now `y` has shape `(None, 16)`
x = tf.compat.v1.placeholder(shape=(None, 3, None), dtype='float32')
y = Flatten()(x)
# now `y` has shape `(None, None)`
相關用法
- 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用法及代碼示例
- Python tf.compat.v1.layers.BatchNormalization用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.compat.v1.layers.Flatten。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。