What is truncated normal initializer in tf

This recipe explains what is truncated normal initializer in tf

Recipe Objective

What is truncated_normal_initializer() in tf?

This is achieved by using the function "tf.keras.initializers.TruncatedNormal" available in tensorflow. The function will generate a truncated normal distribution. The values generated are the similar values from a "tf.keras.initializers.RandomNormal" initializer which except the values which are more than the two standard deviations from the mean value which are discarded and re-drawn.

Step 1 - Import library

import tensorflow as tf

Step 2 - Standalone usage

My_initializer = tf.keras.initializers.TruncatedNormal(mean=0., stddev=1.) data = My_initializer(shape=(3,3)) print("This is the standalone usage for Truncated normal initializer:",data)

This is the standalone usage for Truncated normal initializer: tf.Tensor(
[[-1.1120183   1.3974382  -0.40179777]
 [-0.14957851 -0.3789588  -1.8179718 ]
 [ 1.6118207  -0.05026797 -1.019972  ]], shape=(3, 3), dtype=float32)

Step 3 - Usage in the keras layers

My_initializer_2 = tf.keras.initializers.TruncatedNormal(mean=0., stddev=1.) data_2 = tf.keras.layers.Dense(3, kernel_initializer=My_initializer) print("This is the Usage in the keras layers of Truncated normal initializer:",data_2)

This is the Usage in the keras layers of Truncated normal initializer: 

{"mode":"full","isActive":false}

What Users are saying..

profile image

Anand Kumpatla

Sr Data Scientist @ Doubleslash Software Solutions Pvt Ltd
linkedin profile url

ProjectPro is a unique platform and helps many people in the industry to solve real-life problems with a step-by-step walkthrough of projects. A platform with some fantastic resources to gain... Read More

Relevant Projects

Customer Market Basket Analysis using Apriori and Fpgrowth algorithms
In this data science project, you will learn how to perform market basket analysis with the application of Apriori and FP growth algorithms based on the concept of association rule learning.

Recommender System Machine Learning Project for Beginners-1
Recommender System Machine Learning Project for Beginners - Learn how to design, implement and train a rule-based recommender system in Python

Llama2 Project for MetaData Generation using FAISS and RAGs
In this LLM Llama2 Project, you will automate metadata generation using Llama2, RAGs, and AWS to reduce manual efforts.

Deep Learning Project for Beginners with Source Code Part 1
Learn to implement deep neural networks in Python .

Deep Learning Project for Time Series Forecasting in Python
Deep Learning for Time Series Forecasting in Python -A Hands-On Approach to Build Deep Learning Models (MLP, CNN, LSTM, and a Hybrid Model CNN-LSTM) on Time Series Data.

PyTorch Project to Build a LSTM Text Classification Model
In this PyTorch Project you will learn how to build an LSTM Text Classification model for Classifying the Reviews of an App .

Build Regression (Linear,Ridge,Lasso) Models in NumPy Python
In this machine learning regression project, you will learn to build NumPy Regression Models (Linear Regression, Ridge Regression, Lasso Regression) from Scratch.

House Price Prediction Project using Machine Learning in Python
Use the Zillow Zestimate Dataset to build a machine learning model for house price prediction.

Time Series Forecasting with LSTM Neural Network Python
Deep Learning Project- Learn to apply deep learning paradigm to forecast univariate time series data.

Build a Speech-Text Transcriptor with Nvidia Quartznet Model
In this Deep Learning Project, you will leverage transfer learning from Nvidia QuartzNet pre-trained models to develop a speech-to-text transcriptor.