Open In App

Tensorflow.js tf.signal.hannWindow() Function

Last Updated : 12 May, 2021
Improve
Improve
Like Article
Like
Save
Share
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 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.signal.hannWindow() function is used to generate a hann window.

Syntax:

tf.signal.hannWindow (windowLength)

Parameters: This function accepts single parameter which are illustrated below:

  • windowLength: It is used to generate a Hann window.

Return Value: It returns the tf.Tensor1D.

Example 1:

Javascript




// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
  
tf.signal.hannWindow(9).print();


Output:

Tensor
   [0, 0.1464466, 0.5, 0.8535534, 1, 0.8535534, 0.5, 0.1464466, 0]

Example 2:

Javascript




// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
  
tf.signal.hannWindow(3).print();


Output:

Tensor
   [0, 1, 0]

Reference: https://js.tensorflow.org/api/latest/#signal.hannWindow


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads