Tensorflow.js tf.complex() Function Last Updated : 20 May, 2021 Comments Improve Suggest changes 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. It helps developers to develop ML models in JavaScript, and use ML directly in the browser or in Node.js. The tf.complex() function is used to convert two real numbers to a complex number. Syntax: tf.complex(real, imag) Parameter: real: It can be any of these three tf.Tensor, TypedArray, or Array. It represents the real part of the complex number formed.imag: It can also be any of this three tf.Tensor, TypedArray, or Array. It represents the imaginary part of the complex number formed. Return Value: It returns a tf.Tensor. Note: The real parameter is the tf.Tensor represents the real part of the complex number and the imag parameter is the tf.Tensor represents the imaginary part of the complex number.For example, Let real be [r0, r1, r2]Let imag be [i0, i1, i2]The converted complex number will be [r0 + i0, r1 + i1, r2 + i2] Example 1: JavaScript // The complex function containing the // real and imag Typedarray const complex = tf.complex ([5,3],[1,3]); // Printing the tensor complex.print(); Output: Tensor [5 + 1j, 3 + 3j] Example 2: JavaScript // The complex function containing the // real and imag Typedarray const complex = tf.complex( tf.tensor1d([4.75, 5.75]), tf.tensor1d([2.25, 3.25]) ); // Printing the tensor complex.print(); Output: Tensor [4.75 + 2.25j, 5.75 + 3.25j] Reference: https://js.tensorflow.org/api/latest/#complex Comment More infoAdvertise with us Next Article Tensorflow.js tf.complex() Function C CoderSaty Follow Improve Article Tags : JavaScript Web Technologies Tensorflow.js Similar Reads Tensorflow.js tf.exp() Function Tensorflow.js is an open-source library that is being developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment. The .exp() function is used to find the exponential value i.e, (e^x) of the stated tensor input, and it is done e 2 min read Tensorflow.js tf.cos() Function Tensorflow.js is an open-source library which is being developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment. The .cos() function is used to find the cosine value of the stated tensor input and is done element wise. Syntax 2 min read Tensorflow.js tf.cosh() Function Tensorflow.js is an open-source library which is being developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment. The .cosh() function is used to find the hyperbolic cos of the stated tensor input and is done element wise. Syn 2 min read Tensorflow.js tf.expm1() Function Tensorflow.js is an open-source library that is being developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment. The .expm1() function is used to find the exponential value minus one i.e. (e^x-1) of the stated tensor input, an 2 min read Tensorflow.js tf.acosh() Function Tensorflow.js is an open-source library that is being developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment. The .acosh() function is used to find the inverse hyperbolic cos of the stated tensor element input. Syntax: Â tf 2 min read Like