📜  Tensorflow.js tf.conv3dTranspose()函数(1)

📅  最后修改于: 2023-12-03 15:05:32.616000             🧑  作者: Mango

TensorFlow.js tf.conv3dTranspose()函数
介绍

tf.conv3dTranspose()函数是TensorFlow.js中的一个函数,用于实现3D卷积转置操作。3D卷积转置是一种将低维特征映射转换为高维特征映射的操作,常用于图像分割、图像去噪等任务。

语法
tf.conv3dTranspose(
  x,
  filter,
  outputShape,
  strides,
  pad,
  dataFormat
)
参数
  • x:输入张量,尺寸为[batch, depth, height, width, inChannels]的4维张量。
  • filter:卷积核张量,尺寸为[depth, height, width, outChannels, inChannels]的5维张量。
  • outputShape:要生成的输出张量的形状,尺寸为[batch, depth, height, width, outChannels]的5维张量。
  • strides:一个可选的数组,表示在depth、height和width维度上的步长,默认为[1, 1, 1, 1, 1]
  • pad:一个可选的填充方式,可以是'valid''same',默认为'same'
  • dataFormat:一个可选的字符串,表示输入张量的数据格式,可以是'NDHWC''NCDHW',默认为'NDHWC'
返回值

返回一个计算结果为3D卷积转置的张量。

示例
const x = tf.tensor4d(
  [
    [[[1], [2]], [[3], [4]]],
    [[[5], [6]], [[7], [8]]]
  ],
  [2, 2, 2, 1]
);
const filter = tf.tensor5d(
  [
    [[[[1]], [[-1]]], [[[2]], [[-2]]]],
    [[[[3]], [[-3]]], [[[4]], [[-4]]]]
  ],
  [2, 2, 2, 2, 1]
);

const output = tf.conv3dTranspose(x, filter, [2, 4, 4, 2, 1], [1, 2, 2, 1, 1], 'same');

output.print();

输出结果:

  [[[[[[0.03125001], [0.03125001], [0.12500003], [0.12500003]],
       ...],
      [[[-0.03125001], [-0.03125001], [-0.12500003], [-0.12500003]],
       ...]]
     ...
    [[[[[-4], [4]], [[-4], [4]]],
      ...
      [[[-4], [4]], [[-4], [4]]]]]]]