Monday, June 8, 2026
HomeLanguagesJavascriptTensorflow.js tf.linalg.gramSchmidt() Function

Tensorflow.js tf.linalg.gramSchmidt() 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.linalg.gramSchmidt() function is used to orthogonalize the vectors using the Gram-Schimdt process.

Syntax:

tf.linalg.gramSchmidt( xs ) 

Parameters:

  • xs ( a tf.Tensor1D array or tf.Tensor2D): These are the vectors that are to be orthogonalized.

Return Value: It returns a tf.Tensor1D array or tf.Tensor2D.

Example 1:

Javascript




const tf = require("@tensorflow/tfjs")
  
// Creating a 2-D tensor
const input = tf.tensor2d([
    [3, 7], 
    [4, 6]
]);
  
// Getting the orthogonalized vector
let result = tf.linalg.gramSchmidt(input);
  
result.print();


Output:

Tensor
    [[0.3939193, 0.919145  ],
     [0.919145 , -0.3939194]]

Example 2:

Javascript




const tf = require("@tensorflow/tfjs")
  
// Creating a 2-D tensor
const input = tf.tensor2d([
    [5, 7, 2], 
    [7, 6, 9],
    [1, 2, 3]
]);
  
// Getting the orthogonalized vector
let result = tf.linalg.gramSchmidt(input);
  
result.print();


Output:

Tensor
    [[0.5661386, 0.792594  , 0.2264554],
     [0.1283516, -0.3561312, 0.925579 ],
     [-0.814256, 0.4949402 , 0.3033505]]

Reference: https://js.tensorflow.org/api/latest/#linalg.gramSchmidt

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32515 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6895 POSTS0 COMMENTS
Nicole Veronica
12012 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7018 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6963 POSTS0 COMMENTS