Tensorflow.js tf.matMul() Function Last Updated : 18 May, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report Tensorflow.js is an open-source library developed by Google for running machine learning models and deep learning neural networks in the browser or node environment. The tf.matMul() function is used to compute the dot product of two matrices, A * B. Syntax: tf.matMul (a, b, transposeA?, transposeB?) Parameters: This function accepts a parameter which is illustrated below: a: This is the first matrix in dot product operation.b: This is the second matrix in dot product operation.transposeA: This is optional and if it is set to true, then a is transposed before multiplication.transposeB: This is optional and if it is set to true, then b is transposed before multiplication. Return Value: It returns the dot product of two matrices. Below are the examples that illustrates the use of tf.matMul() function. Example 1: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Initializing a tensor of some elements let geek1 = tf.tensor2d([2, 1], [1, 2]); let geek2 = tf.tensor2d([11, 12, 13, 14], [2, 2]); // Calling the .avgPool3d() function over // the above tensor as its parameter and // printing the result. geek1.matMul(geek2).print(); Output: Tensor [[35, 38],] Example 2: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Initializing a tensor of some elements let geek1 = tf.tensor2d([2, 1], [1, 2]); let geek2 = tf.tensor2d([61, 62, 63, 64], [2, 2]); // Calling the .avgPool3d() function over // the above tensor as its parameter and // printing the result. tf.matMul(geek1, geek2).print(); Output: Tensor [[185, 188],] Reference:https://js.tensorflow.org/api/latest/#matMul Comment More infoAdvertise with us Next Article Tensorflow.js tf.max() Function T thacker_shahid Follow Improve Article Tags : JavaScript Web Technologies Tensorflow.js Similar Reads Tensorflow.js tf.max() Function Tensorflow.js is an open-source library developed by Google for running machine learning models and deep learning neural networks in the browser or node environment. The tf.max() function is used to calculate the maximum value from the specified Tensor across its dimension. It reduces the given inpu 2 min read Tensorflow tf.mul() Function The tf.mul() function returns the multiplication of two tf.Tensor objects element wise. The tf.Tensor object represents the multidimensional array of numbers. Syntax: tf.mul( a, b ) Parameters: a: It contains the first tf.Tensor object that multiplied by second tf.Tensor object element-wise. The val 2 min read Tensorflow.js tf.mean() Function Tensorflow.js is an open-source library developed by Google for running machine learning models and deep learning neural networks in the browser or node environment. The tf.mean() function is used to calculate the mean value of the specified Tensor across its dimension. It reduces the given input el 2 min read Tensorflow.js tf.pad() Function Tensorflow.js is an open-source library developed by Google for running machine learning models and deep learning neural networks in the browser or node environment. It also helps the developers to develop ML models in JavaScript language and can use ML directly in the browser or in Node.js. The tf. 2 min read Tensorflow.js tf.sum() Function Tensorflow.js is an open-source library developed by Google for running machine learning models and deep learning neural networks in the browser or node environment. The tf.sum() function is used to calculate sum of the elements of a specified Tensor across its dimension. It reduces the given input 2 min read Tensorflow.js tf.min() Function Tensorflow.js is an open-source library developed by Google for running machine learning models and deep learning neural networks in the browser or node environment. The tf.min() function is used to calculate the minimum value from the specified Tensor across its dimension. It reduces the given inpu 2 min read Like