What is Keras?
Keras is High-Level Deep learning Python library extensively used by Data-scientists when it comes to architect the neural networks for complex problems. Higher level API means that Keras can act as front end while you can ask Tensor-flow or Theano to work as back end.
Other Deep learning libraries
There are many development options that you can get with TensorFlow and its installation is also quick.
-
Caffe - Caffe which is really good at speed, implementing the matrix multiplication and ease of use.
-
Torch - Torch is another Deep learning library written in Lua and C programming. A most sought skill in Data science is ability to work with Torch, besides others. It is lighting fast in implementing the matrix multiplications using numpy as its base data arrays
-
Tensor-flow - Tensor-flow is the number one populous deep learning library across the industry till date and it is developed by Google. It uses tensors as the basic operations ( e.g Matrix multiplication )
Implementing Simple Neural Network Using Keras
# Import all the necessary functions to build the neural network
import keras
import keras.layers import Conv1D
from keras.optimizers import Adam
fromkeras.models import sequential
# Lets start building 3 layered convolutional network
def create_model():
model = sequential()
# First layer
model.add(Conv1D ( filters = 10, kernel_size = 10, input_shape, activation = 'relu')
# Second layer
model.add(Conv1D ( filters = 10, Kernel_size = 10, activation = 'relu' )
# third layer
model.add(Conv1D ( filters = 10, kernel_size = 10, activation = 'relu' )
# flatten
model.add(Flatten())
# compile the model
model.compile( loss = 'binary_corssentropy', optimizers = Adam(1e-4), metrics= ['accuracy'])
return model
Architecture of Keras
Keras API can be divided into three main categories −
-
Model
-
Layer
-
Core Modules
Keras Models
Keras Models divided into two categories
Sequential Model
The sequential model is basically a linear composition of Keras Layers. Sequential model is easy, minimal as well as has the ability to represent nearly all available neural networks.
A simple sequential model is as follows −
#Import Libraries
from keras.models import Sequential
from keras.layers import Dense, Activation
#Use the Model
model = Sequential()
model.add(Dense(512, activation = 'relu', input_shape = (784,)))
Core Model
Keras also provides a lot of built-in neural network related functions to properly create the Keras model and Keras layers.