Skip to content
Related Articles

Related Articles

Tensorflow.js Function

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 30 Aug, 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 .io.http() function is used to generate an IOHandler subset which transmits model artifacts to the HTTP server. Moreover, an HTTP request of the multi-part or form-data mime type shall be transmitted to the path URL. Where, the form-data contains artifacts which describe the model topology and/or weights of the model. 

Syntax:, loadOptions?)


  • path: The stated URL path to the model. Moreover, it could be a complete HTTP path i.e. ‘http://localhost:8000/model-upload’ or a comparable path i.e. ‘./model-upload’. It is of type string.
  • loadOptions: The stated configuration for the purpose of loading. It is optional and is of type LoadOptions. It comprises the following fields:
    1. weightPathPrefix: The stated optional prefix of path for the weight files. In addition, the by default value of this is evaluated from the path param.
    2. fetchFunc: The stated optional custom fetch function.
    3. onProgress: The stated optional progress callback function, it is released at regular intervals prior to the completion of load.

Return Value: It returns IOHandler.

Example 1:


// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
// Calling io.http() method
const result ='');
// Printing output


  "path": "",
  "requestInit": {}

Example 2:


// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
// Creating model
const model = tf.sequential();
// Adding layer to the model
     tf.layers.dense({units: 2, inputShape: [10]}));
// Calling io.http() method within 
// save() method
const result = await
// Printing output


  "modelArtifactsInfo": {
    "dateSaved": "2021-08-26T08:43:49.648Z",
    "modelTopologyType": "JSON",
    "modelTopologyBytes": 611,
    "weightSpecsBytes": 124,
    "weightDataBytes": 88
  "responses": [


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!