...

Artificial Intelligence - Keras

Back to Course

Lesson Description


Lession - #895 Keras-Deep Learning


Keras gives a total structure to make any sort of neural networks. Keras is imaginative as well as extremely simple to learn. It upholds straightforward neural networks to extremely enormous and complex neural network model. Allow us to comprehend the engineering of Keras structure and how Keras helps in deep learning in this part.

Architecture of Keras

Keras API can be separated into three primary classes −
  • Model
  • Layer
  • Core Modules

    In Keras, each ANN is addressed by Keras Models. Thusly, every Keras Model is composition of Keras Layers and addresses ANN layers like input, hidden layer, output layers, convolution layer, pooling layer, and so on, Keras model and layer access Keras modules for activation function, misfortune function, regularization function, and so on, Using Keras model, Keras Layer, and Keras modules, any ANN calculation (CNN, RNN, and so forth,>
    can be addressed in a basic and effective way.

    The accompanying chart depicts the connection between model, layer and core modules −

    Allow us to see the overview of Keras models, Keras layers and Keras modules.

    Model

    Keras Models are of two types as referenced underneath −

    Sequential Model − Sequential model is essentially a linear arrangement of Keras Layers. Consecutive model is simple, insignificant as well as can address virtually all suitable neural networks.

    A straightforward sequential model is as per the following −
    from keras.models import Sequential 
    from keras.layers import Dense, Activation 
    
    model = Sequential(>
    model.add(Dense(512, activation = 'relu', input_shape = (784,>
    >
    >
    Where,
  • Line 1 imports Sequential model from Keras models
  • Line 2 imports Dense layer and Activation module
  • Line 4 make another successive model utilizing Sequential API
  • Line 5 adds a dense layer (Dense API>
    with relu initiation (utilizing Activation module>
    work.

    Sequential model opens Model class to make redid models also. We can utilize sub-classing idea to make our own complicated model.

    Function API − Functional API is fundamentally used to make complex models.

    Layer

    Every Keras layer in the Keras model address the corresponding layer (input layer, hidden layer and result layer>
    in the genuine proposed neural network model. Keras gives a ton of pre-construct layers so any complex neural network can be effectively made. A portion of the significant Keras layers are determined beneath-
  • Core Layers
  • Convolution Layers
  • Pooling Layers
  • Recurrent Layers

    A normal python code to address a neural network model utilizing consecutive model is as per the following −
    from keras.models import Sequential 
    from keras.layers import Dense, Activation, Dropout model = Sequential(>
    model.add(Dense(512, activation = 'relu', input_shape = (784,>
    >
    >
    model.add(Dropout(0.2>
    >
    model.add(Dense(512, activation = 'relu'>
    >
    model.add(Dropout(0.2>
    >
    model.add(Dense(num_classes, activation = 'softmax'>
    >
    Where,
  • Line 1 imports Sequential model from Keras models.
  • Line 2 imports Dense layer and Activation module
  • Line 4 make another successive model utilizing Sequential API
  • Line 5 adds a dense layer (Dense API>
    with relu actuation (utilizing Activation module>
    work.
  • Line 6 adds a dropout layer (Dropout API>
    to deal with over-fitting.
  • Line 7 adds another thick layer (Dense API>
    with relu actuation (utilizing Activation module>
    work.
  • Line 8 adds another dropout layer (Dropout API>
    to deal with over-fitting.
  • Line 9 adds last dense layer (Dense API>
    with softmax initiation (utilizing Activation module>
    work.

    Keras likewise gives choices to make our own altered layers. Customized layer can be made by sub-classing the Keras.Layer class and it is like sub-classing Keras models.

    Core Modules

    Keras additionally gives a lot of built-in neural network related capacities to appropriately make the Keras model and Keras layers. A portion of the capacity are as per the following −
  • Activations module - Actuation function is a significant idea in ANN and initiation modules gives numerous enactment work like softmax, relu, and so forth.,
  • Loss module - Loss module gives misfortune capacities like mean_squared_error, mean_absolute_error, poisson, and so on.,
  • optimizer module - Optimizer module gives streamlining agent work like adam, sgd, and so forth.,
  • Regularizers - Regularizer module gives capacities like L1 regularizer, L2 regularizer, and so on.,

    clear session:Removes all keys and values from the session-state collection.
    how often keratin treat:Keratin treatments shouldn't be done more than three times a year,