Reshape
類別keras.layers.Reshape(target_shape, **kwargs)
將輸入重塑為給定形狀的層。
參數
輸入形狀
任意,但輸入形狀中的所有維度必須是已知/固定的。當將此層用作模型中的第一層時,請使用關鍵字參數 input_shape
(整數元組,不包含樣本/批次大小軸)。
輸出形狀
(batch_size, *target_shape)
範例
>>> x = keras.Input(shape=(12,))
>>> y = keras.layers.Reshape((3, 4))(x)
>>> y.shape
(None, 3, 4)
>>> # also supports shape inference using `-1` as dimension
>>> y = keras.layers.Reshape((-1, 2, 2))(x)
>>> y.shape
(None, 3, 2, 2)