Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • TypeScript
  • Vue.js
  • D3.js
  • Collect.js
  • Underscore.js
  • Moment.js
  • Ember.js
  • Tensorflow.js
  • Fabric.js
  • JS Formatter
  • JavaScript
  • Web Technology
Open In App
Next Article:
Tensorflow.js tf.layers.activation() Function
Next article icon

Tensorflow.js tf.layers.batchNormalization() Function

Last Updated : 25 Apr, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

Tensorflow.js is a Google-developed open-source toolkit for executing machine learning models and deep learning neural networks in the browser or on the node platform. It also enables developers to create machine learning models in JavaScript and utilize them directly in the browser or with Node.js.

The tf.layers.batchNormalization() function is used to apply the batch normalization operation on data. Batch normalisation is a method for training very deep neural networks that standardises each mini-inputs batch's to a layer. This stabilises the learning process and significantly reduces the number of training epochs needed to create deep networks.

Syntax:

tf.layers.batchNormalization(args?)

Input Shape: Arbitrary. When utilizing this layer as the initial layer in a model, use the inputShape configuration.

Output Shape: The output has the same shape as the input.

Parameters: It accepts the args object which can have the following properties:

  • axis (number): The integer axis that should be normalized (typically the features axis). -1 is the default value.
  • momentum (number): The moving average's momentum. The default value is 0.99.
  • epsilon (number): The small float is added to the variance to avoid division by zero. Defaults to 1e-3.
  • center (boolean): If this is true, add the offset of beta to the normalized tensor. If false, beta isn't taken into account. The value is set to true by default.
  • scale (boolean): If this is true, multiplied by gamma. Gamma is not utilized if false. True is the default value.
  • betaInitializer: This is the beta weight's initializer. 'zeroes' is the default value.
  • gammaInitializer: This is the gamma weight's initializer. 'ones' is the default value.
  • movingMeanInitializer: This is the moving mean's initializer. 'zeroes' is the default value.
  • movingVarianceInitializer: This is the moving variance's initializer. 'ones' is the default value.
  • betaConstraint: The constraint for the beta weight.
  • gammaConstraint: The constraint for the gamma weight.
  • betaRegularizer: The regularizer for the beta weight.
  • gammaRegularizer: The regularizer for the beta weight.

Return Value: It returns an object (BatchNormalization).

Example 1:

JavaScript
import * as tf from "@tensorflow/tfjs";  const batchNormalizationLayer = tf.layers.batchNormalization();      const x = tf.tensor([1.12, -0.8, 1.9, 0.12, 0.25, -3.4], [2, 3]);  batchNormalizationLayer.apply(x).print(); 

Output:

Tensor     [[1.1194404, -0.7996003, 1.8990507 ],      [0.11994  , 0.2498751 , -3.3983014]]

Example 2:

JavaScript
import * as tf from "@tensorflow/tfjs";  const batchNormalizationLayer = tf.layers.batchNormalization();      const x = tf.tensor([12, 3.2, 4.8, 9, 10, 2.5,      8, 11, 9.4, 25, 24.9, 98.7], [2, 3, 2]);  batchNormalizationLayer.apply(x).print(); 

Output:

Tensor     [[[11.9940042, 3.1984012 ],       [4.7976022 , 8.9955034 ],       [9.9950037 , 2.4987509 ]],      [[7.9960032 , 10.994504 ],       [9.3953028 , 24.9875088],       [24.8875599, 98.6506805]]]

Reference: https://js.tensorflow.org/api/latest/#layers.batchNormalization


Next Article
Tensorflow.js tf.layers.activation() Function

A

aayushmohansinha
Improve
Article Tags :
  • JavaScript
  • Web Technologies
  • Tensorflow.js
  • TensorFlow.js-layers

Similar Reads

  • Tensorflow.js tf.layers.activation() Function
    Introduction: 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. Tensorflow.js tf.layers.activation() function is used to applied to function to all the element of our input layer . we
    3 min read
  • Tensorflow.js tf.batchNorm() Function
    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 .batchNorm() function is useful in batch normalization. Moreover, the mean, variance, scale, including offset can b
    2 min read
  • Tensorflow.js tf.layers.flatten() Function
    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.flatten() function is used to flatten the input, without affecting the batch size. A Flatten layer flattens each batch i
    2 min read
  • Tensorflow.js tf.layers.dot() Function
    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. Tensorflow.js tf.layers.dot() function is used to apply the dot product between the two tensors provided. Syntax:  tf.layers.dot(args)
    3 min read
  • Tensorflow.js tf.layers.conv2d() Function
    Tensorflow.js is a Google-developed open-source toolkit for executing machine learning models and deep learning neural networks in the browser or on the node platform. It also enables developers to create machine learning models in JavaScript and utilize them directly in the browser or with Node.js.
    3 min read
  • Tensorflow.js tf.layers.conv3d() Function
    Tensorflow.js is a Google-developed open-source toolkit for executing machine learning models and deep learning neural networks in the browser or on the node platform. It also enables developers to create machine learning models in JavaScript and utilize them directly in the browser or with Node.js.
    3 min read
  • Tensorflow.js tf.layers.bidirectional() Function
    Tensorflow.js is an open-source library that is being developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment. The tf.layers.bidirectional function is a bidirectional wrapper for RNNs layer. Syntax: tf.layers.bidirectional(
    2 min read
  • Tensorflow.js tf.layers.conv1d() Function
    Tensorflow.js is a javascript library developed by Google to run and train machine learning models in the browser or in Node.js. Tensorflow.js tf.layers.conv1d() function is used to create convolution layer. It is used to applied 1d convolution to the input data. The convolutional layer is used to m
    4 min read
  • Tensorflow.js tf.layers.concatenate() Function
    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.concatenate() function is used to concatenate an array of inputs. Syntax: tf.layers.concatenate() Parameters: args(Objec
    2 min read
  • Tensorflow.js tf.layers.convLstm2d() Function
    Tensorflow.js is an open-source library that is being developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment. The tf.layers.convLstm2d() function is used for creating a ConvRNN2D layer which consists of one ConvLSTM2DCell a
    5 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences