Keras 3 API 文档 / 层 API / 重塑层 / UpSampling3D 层

UpSampling3D 层

[源代码]

UpSampling3D

keras.layers.UpSampling3D(size=(2, 2, 2), data_format=None, **kwargs)

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

分别将数据的第 1、第 2 和第 3 维重复 size[0]size[1]size[2] 次。

示例

>>> input_shape = (2, 1, 2, 1, 3)
>>> x = np.ones(input_shape)
>>> y = keras.layers.UpSampling3D(size=(2, 2, 2))(x)
>>> y.shape
(2, 2, 4, 2, 3)

参数

  • size: 整数或包含 3 个整数的元组。dim1、dim2 和 dim3 的上采样因子。
  • data_format: 字符串,可以是 "channels_last"(默认)或 "channels_first"。输入中维度顺序。"channels_last" 对应于形状为 (batch_size, spatial_dim1, spatial_dim2, spatial_dim3, channels) 的输入,而 "channels_first" 对应于形状为 (batch_size, channels, spatial_dim1, spatial_dim2, spatial_dim3) 的输入。如果未指定,则使用 Keras 配置文件 ~/.keras/keras.json(如果存在)中找到的 image_data_format 值,否则使用 "channels_last"。默认为 "channels_last"

输入形状

5D 张量,形状为:- 如果 data_format"channels_last"(batch_size, dim1, dim2, dim3, channels) - 如果 data_format"channels_first"(batch_size, channels, dim1, dim2, dim3)

输出形状

5D 张量,形状为:- 如果 data_format"channels_last"(batch_size, upsampled_dim1, upsampled_dim2, upsampled_dim3, channels) - 如果 data_format"channels_first"(batch_size, channels, upsampled_dim1, upsampled_dim2, upsampled_dim3)