Tensorflow.js tf.data.array() Method
Last Updated :
04 Jun, 2021
Tensorflow.js is an open-source library that is developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment.
The .data.array() method is used to form a dataset based on an array made from elements.
Syntax :
tf.data.array(items)
Parameters:
- items: It is the stated array made from elements that is to be parsed in a dataset like items, and it can be of type tf.void, number, string, TypedArray, tf.Tensor, tf.Tensor[], or {[key: string]:tf.Tensor, number, or string}[].
Return Value: It returns tf.data.Dataset.
Example 1:
Javascript
import * as tf from "@tensorflow/tfjs"
const res = tf.data.array([
{ 'element' : 5},
{ 'element' : 6},
{ 'element' : 7}
]);
await res.forEachAsync(op => console.log(op));
|
Output:
{
"element": 5
}
{
"element": 6
}
{
"element": 7
}
Example 2:
Javascript
import * as tf from "@tensorflow/tfjs"
const res = tf.data.array([4.6, 7.9, 9.6, 2.6, 8.9]);
await res.forEachAsync(op => console.log(op));
|
Output:
4.6
7.9
9.6
2.6
8.9
Reference: https://js.tensorflow.org/api/latest/#data.array
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...