Silent Retreat

Duality me meditating on a chakra, me meditating on a mantra….who is this me? Awareness is beyond this me. It feels like only 2 days left but actually there are 3. I’m not entirely sure how I feel…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Keras Model Sequential API VS Functional API

Keras Deep Learning library helps to develop the neural network models fast and easy. There are two ways to build a model in Keras — Sequential and Functional. Let me explain.

Sequential API allows you to create models layer-by-layer by stacking them. It is limited in that it does not allow you to create models that share layers or have multiple inputs or outputs.

Example Code:

Result

And now lets plot your model using keras utils.

Keras Plot Model

As you can see, Sequential API create model and stacking them together layer by layer. Sequential API is very easy to create deep learning model in most of case.

Keras functional API provides a more flexibility as you can easily defines models where layers connect to more than just the previous and next layers, and you can connect layers to any other layers. As a result, you can create complex network such as Residual Network.

Example Code:

Result

Plot functional model using keras utils.

Keras Plot Model

As you can see, Functional API let us to make layers more flexible.

Example Code :

Model Subclassing Example

PROS :

CONS :

PROS :

CONS :

PROS:

CONS:

Add a comment

Related posts:

EMBRACING CHANGE

If my years on this planet have taught me anything, it’s that life plays by it’s own rules. To have a fixed and unbending idea of what my existence should be like is to be in constant battle with…

Purpose of human existence

So yeah..just imagine yourselves you are taking last breath of you life and the thought in your minds are what have i did in my life…what have i get??…what i found something new??…where i will go??……