Open In App

Tensorflow.js tf.signal.frame() 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.frame() function is used to expand input into frames of frameLength.

Syntax:

tf.signal.frame (signal, frameLength, frameStep, 
                      padEnd?, padValue?)

Parameters:

  • signal: The input tensor to be expanded.
  • frameLength: The length of frame
  • frameStep: The frame hop size in samples
  • padEnd: Whether to pad the end of signal with padValue.
  • padValue: An number to use where the input signal does not exist when padEnd is True.

Return Value: It returns tf.Tensor.

Example 1:

Javascript




// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
  
  
tf.signal.frame([1, 2, 3, 4, 5, 6], 2, 3).print();


Output:

Tensor
     [undefined,]

Example 2:

Javascript




// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
  
tf.signal.frame([2,, 4, 6], 1, 3).print();


Output:

Tensor
     [undefined,]

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


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

Similar Reads