Keras 2 API 文档 / 层 API / 重塑层 / UpSampling1D 层

UpSampling1D 层

[源代码]

UpSampling1D

tf_keras.layers.UpSampling1D(size=2, **kwargs)

用于 1D 输入的上采样层。

沿着时间轴将每个时间步重复 size 次。

示例

>>> input_shape = (2, 2, 3)
>>> x = np.arange(np.prod(input_shape)).reshape(input_shape)
>>> print(x)
[[[ 0  1  2]
  [ 3  4  5]]
 [[ 6  7  8]
  [ 9 10 11]]]
>>> y = tf.keras.layers.UpSampling1D(size=2)(x)
>>> print(y)
tf.Tensor(
  [[[ 0  1  2]
    [ 0  1  2]
    [ 3  4  5]
    [ 3  4  5]]
   [[ 6  7  8]
    [ 6  7  8]
    [ 9 10 11]
    [ 9 10 11]]], shape=(2, 4, 3), dtype=int64)

参数

  • size: 整数。上采样因子。

输入形状

3D 张量,形状为:(batch_size, steps, features)

输出形状

3D 张量,形状为:(batch_size, upsampled_steps, features)