Open In App

Tensorflow.js tf.layers getConfig() Method

Last Updated : 22 Apr, 2022
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.

The tf.layers getConfig() function is used to get the configuration of a layer.

Syntax:

getConfig()

Parameters: This function does not accept any parameters.

Return Value: This function returns the configuration of the layer.

Example 1: We will get the configuration of the minimum layer in this example.

Javascript




const tf = require("@tensorflow/tfjs")
  
// Creating a minLayer
const minLayer = tf.layers.minimum();
  
// Getting the configuration of the layer
const config = minLayer.getConfig();
console.log(config)


Output: 

{ name: 'minimum_Minimum1', trainable: true }

Example 2: We will get the configuration of the dense layer in this example. 

Javascript




const tf = require("@tensorflow/tfjs")
  
// Creating a minLayer
const denseLayer = tf.layers.dense({units: 1});
  
// Getting the configuration of the layer
const config = denseLayer.getConfig();
console.log(config)


Output: 

{ units: 1,
  activation: 'linear',
  useBias: true,
  kernelInitializer:
   { className: 'VarianceScaling',
     config:
      { scale: 1, mode: 'fanAvg', 
      distribution: 'normal', seed: null } },
  biasInitializer: { className: 'Zeros', config: {} },
  kernelRegularizer: null,
  biasRegularizer: null,
  activityRegularizer: null,
  kernelConstraint: null,
  biasConstraint: null,
  name: 'dense_Dense1',
  trainable: true }

Example 3: We will get the configuration of the application layer in this example. 

Javascript




const tf = require("@tensorflow/tfjs")
  
// Creating a minLayer
const activationLayer = 
    tf.layers.activation({activation: 'relu6'});
  
// Getting the configuration of the layer
const config = activationLayer.getConfig();
console.log(config)


Output: 

{ activation: 'relu6',
  name: 'activation_Activation1',
  trainable: true }

Reference: https://js.tensorflow.org/api/latest/#tf.layers.Layer.getConfig

 



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

Similar Reads