# How to use VarianceScaling initializer to a Deep Learning Model in Keras

In deep learning, the initializer is a method used to set the initial values of the weights of the neural network. The initial values of the weights play a crucial role in the training process, as they determine how the network will learn from the data. There are different types of initializers available in Keras, one of which is the VarianceScaling initializer.

The VarianceScaling initializer initializes the weights of the neural network with random values based on a scaling factor. The scaling factor is calculated based on the number of input and output neurons of the layer, and the type of scaling used (fan_in, fan_out, or fan_avg).

The idea behind this initializer is that the variance of the weights should be the same for all layers, regardless of the number of neurons in the layer, so that the learning rate is the same for all layers.

To use VarianceScaling initializer in a deep learning model in Keras, you first need to import the library, then create a new model using the Sequential() function. Next, you can add layers to the model using the Dense() function, in which you can set the kernel_initializer argument to VarianceScaling.

The kernel_initializer argument takes an instance of an initializer class, such as VarianceScaling from keras.initializers. The VarianceScaling initializer class takes several arguments, including the scaling factor, mode, distribution, and seed. The scaling factor is a float value, mode can be either “fan_in”, “fan_out” or “fan_avg”, the distribution can be “normal” or “uniform” and seed is an integer value to initialize the random generator.

Once you have added the VarianceScaling initializer to your model, you can then compile and train the model as usual.

In summary, to use VarianceScaling initializer in a deep learning model in Keras, you need to import the library, create a new model using the Sequential() function, add layers to the model using the Dense() function, in which you can set the kernel_initializer argument to VarianceScaling, and then compile and train the model as usual. The kernel_initializer argument takes an instance of initializer class with several arguments, including the scaling factor, mode, distribution, and seed.

In this Applied Machine Learning & Data Science Recipe (Jupyter Notebook), the reader will find the practical use of applied machine learning and data science in Python programming: How to use VarianceScaling initializer to a Deep Learning Model in Keras.

Latest end-to-end Learn by Coding Recipes in Project-Based Learning:

**All Notebooks in One Bundle: Data Science Recipes and Examples in Python & R****. **

**End-to-End Python Machine Learning Recipes & Examples.**

**End-to-End R Machine Learning Recipes & Examples.**

**Applied Statistics with R for Beginners and Business Professionals**

**Data Science and Machine Learning Projects in Python: Tabular Data Analytics**

**Data Science and Machine Learning Projects in R: Tabular Data Analytics**

**Python Machine Learning & Data Science Recipes: Learn by Coding**

**R Machine Learning & Data Science Recipes: Learn by Coding**

**Comparing Different Machine Learning Algorithms in Python for Classification (FREE)**

**Introduction to Applied Machine Learning & Data Science for Beginners, Business Analysts, Students, Researchers and Freelancers with Python & R Codes @ Western Australian Center for Applied Machine Learning & Data Science (WACAMLDS) !!!**

**Subscribe SETScholars on YouTube.**

**Support SETScholars** for Free End-to-End Applied Machine Learning and Data Science Projects & Recipes by becoming a member of WA Center For Applied Machine Learning and Data Science (WACAMLDS). **Membership fee only $1.75 per month (on annual plan) and you will get access to 350+ end-to-end Python & R Projects.**

Western Australian Center for Applied Machine Learning & Data Science – Membership

How to add a Weight Regularization (l2) to a Deep Learning Model in Keras

How to add a dropout layer to a Deep Learning Model in Keras