Open In App

Tensorflow.js tf.conv3dTranspose() Function

Introduction: Tensorflow.js is an open-source library that is developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment.

The .conv3dTranspose() function is used to determine the transposed 3D convolution of a volume. It is also known as a deconvolution.



Syntax:

tf.conv3dTranspose(x, filter, outputShape, strides, pad)

Parameters:



Return Value: It returns tf.Tensor4D or tf.Tensor5D.

Example 1:




// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
  
// Defining input tensor
const x = tf.tensor5d([1, 2, 2, 3], [2, 2, 1, 1, 1]);
  
// Defining filter tensor
const y = tf.tensor5d([3, 3, 3, 2], [1, 2, 2, 1, 1]);
  
// Calling conv3dTranspose() method
const result = tf.conv3dTranspose(x, y, [1, 1, 2, 1, 1], 2, 'same');
  
// Printing output
result.print();

Output:

Tensor
    [[[ [[3],],

        [[3],]]]]

Example 2:




// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
  
// Calling conv3dTranspose() method
tf.conv3dTranspose(tf.tensor5d(
    [1.1, 2.1, 2.2, 3.6], [2, 2, 1, 1, 1]), 
    tf.tensor5d([3.6, 3.1, 3.2, 2.0], [1, 2, 2, 1, 1]), 
    [1, 1, 2, 1, 1], 7, 'valid').print();

Output:

Tensor
    [[[ [[0],],

        [[0],]]]]

Reference: https://js.tensorflow.org/api/latest/#conv3dTranspose


Article Tags :