- Hands-On Deep Learning Architectures with Python
- Yuxi (Hayden) Liu Saransh Mehta
- 88字
- 2025-04-04 14:23:29
Functional API
This is just another layout for coding the model graph. You can choose the following layout if you are more comfortable with Python style code writing:
from keras.models import Model
from keras.layers import Dense, Input
#defining input placeholder with input shape
inp = Input(shape = 100)
# layers
x = Dense(units = 128, activation = 'relu')
x = Dense(units = 64, activation = 'relu')
# taking output
predict = Dense(units = 4, activation = 'softmax')(x)
# defining model
model = Model(inputs = inp, outputs = predict)