# Modules of Keras

Keras is an emerging trend in the field of Deep Learning. It is a high-level neural network API that runs on the top of TensorFlow and Theano. It does not handle low-level computations. Keras uses its backend engines to perform the selective tasks that Keras is not capable of. It focuses on fast experimentations. Its main ideology is the Model. Keras is the best library available for Deep Learning. It is simple and readable. It is a user-friendly Keras library. Let us learn about Modules of Keras.

## Modules of Keras

Keras Module consists of pre-defined classes, functions, operations, and variables that are useful for Deep Learning. These Keras modules help users to complete their tasks easily. It saves their computing time. It gives user’s the opportunity to use predefined functions and classes to simplify their work.

There are various Keras Modules available:

##### 1. Keras Activators Module

These modules contain built-in activation functions. It offers you a list of activation functions.

##### 2. Keras Constraints Module

It gives you a list of constraint functions. These functions impose constraints on the weight values.

from keras.constraints import max_norm model.add(Dense(64, kernel_constraint=max_norm(2.)))

##### 3. Keras Callbacks Module

It contains a list of callback functions. You can call these functions while training the model. You can either use these functions to get the intermediate data or to stop the training of the model.

keras.callbacks.callbacks.Callback()

##### 4. Keras Backend Module

It enables you to use the functions of the backend libraries like TensorFlow and Theano. It is useful for Keras backend operations. To use Keras backend Module, prefer the code below:

from keras import backend as k

Some of the backend modules are:

**to_dense():**It is used to converts sparse into dense.

b = k.to_dense(a) print(b) Tensor("SparseToDense:0", shape = (2, 2), dtype = float32) print(k.is_sparse(b)) False

**variable():**It is used to initializes a variable.

data = k.variable([[10,20,30,40],[50,60,70,80]])

**batch_dot()****reset_uids()****random_unifrom_variable()****dot(): It is used to multiply two tensors.**

a = k.placeholder(shape = (4,2)) b = k.placeholder(shape = (2,3)) c = k.dot(a,b) c <tf.Tensor 'MatMul_3:0' shape = (4, 3) dtype = float32>

**ones():**It is used to initialize all as one value.

res = k.ones(shape = (2,2))

**placeholder():**It is useful for instantiates a placeholder tensor.

##### 5. Keras Optimizers Module

It gives you a list of optimizers’ functions. It contains built-in optimizer classes.

##### 6. Keras Utils Module

It is very useful in Deep Learning. It provides you with a list of utility functions and built-in utility classes. Some of the methods that the utils module provide are:

**to_categorical()****plot_model():**

from keras.utils import plot_model plot_model(model,to_file = 'image.png')

**HDF5Matrix():**

from keras.utils import HDF5Matrix data = HDF5Matrix('data.hdf5', 'data')

**print_summary():**

From keras.utils import print_summary print_summary(model)

##### 7. Keras Initializers Module

It is Keras initializer serialization or deserialization. It contains a list of initializer functions.

keras.initializers.Initializer()

##### 8. Keras Losses Module

It enables you to use built-in losses functions.

from keras import losses model.compile(loss=losses.mean_squared_error, optimizer='sgd')

##### 9. Keras Regularizers Module

It has a list of regularizer functions.

from keras import regularizers

##### 10. Keras Models Module

It contains model-related API entries. It has a clone code for model-cloning.

##### 11. Keras Metrics Module

It provides you a list of built-in metrics functions. It enables you to use them while dealing with metrics.

##### 12. Keras Text processing Module

It provides you functions. These functions enable you to convert text to a NumPy array. It is suitable for Machine Learning.

keras.preprocessing.text.Tokenizer()

##### 13. Keras Pre-processing Module

This module provides you with Keras data pre-processing utlis.

##### 14. Keras Layer Module

It contains a list of Keras Layers API.

##### 15. Keras Image-processing Module

It is a useful module for Machine Learning. It can be helpful in the Data Preparation Phase of ML. it contains functions that allow you to convert the image into a NumPy array.

keras.preprocessing.image.ImageDataGenerator()v

## Conclusion

Keras is a very powerful and famous Python library. It is useful while dealing with Deep Learning. It is not capable to perform low-level computations. Hence, it uses backend engines like TensorFlow, Microsoft CNTK, and Theano. Keras runs on the top of these backend engines. Keras focuses on fast implementations by providing you Keras Modules. These modules are a set of pre-defined functions and operations. These modules reduce complexity while working with Deep Learning. These are user-friendly modules. It allows users to implement modules in a simple way.