Building Model using Functional API
The Functional API allows more flexibility in creating complex architectures. You can create models with shared layers, multiple inputs/outputs, and skip connections.
Here’s an example:
- We define two input layers (input1 and input2).
- Create separate hidden layers for each input.
- Merge the hidden layers using the concatenate function.
- Finally, add an output layer with SoftMax activation.
from keras.layers import Input, Dense, concatenate
from keras.models import Model
input1 = Input(shape=(100,))
input2 = Input(shape=(50,))
hidden1 = Dense(64, activation='relu')(input1)
hidden2 = Dense(32, activation='relu')(input2)
merged = concatenate([hidden1, hidden2])
output = Dense(10, activation='softmax')(merged)
model = Model(inputs=[input1, input2], outputs=output)
What is Keras?
Keras is an open-source deep-learning framework that gained attention due to its user-friendly interface. Keras offers ease of use, flexibility, and the ability to run seamlessly on top of TensorFlow. In this article, we are going to provide a comprehensive overview of Keras.
Table of Content
- Understanding Keras
- History of Keras
- Key Features of Keras Library
- How to Build a Model in Keras?
- Building Model using Sequential API
- Building Model using Functional API
- Applications of Keras