Model architecture is the choice of layers, their settings, and how they connect. It matters before training starts: the resulting graph defines the functions that gradient descent can search by adjusting the model’s weights. An unsuitable architecture can limit results even with more training data; a well-chosen one can make learning easier. section 9.0
A graph instead of a stack
Consider a support-ticket model that reads a title, a message body, and user-added tags. Their inputs can be combined into shared features, then split into two outputs: priority and department. That connectivity is part of the architecture. A Sequential stack cannot express this multi-input, multi-output graph; Keras’s Functional API can. section 7.2.2
Practical architecture decisions:
- Choose a Sequential model for one input, one output, and a simple layer-by-layer stack. section 3.6.3
- Use the Keras Functional API when layers branch or inputs and outputs multiply. Prefer it to model subclassing when the model can be expressed as a directed acyclic graph of layers. section 7.2.2 section 7.2.5
- For complex ConvNets, look for modules arranged in a hierarchy and reused as blocks. Common patterns include residual connections, batch normalization, and depthwise separable convolutions. section 9.1 section 9.7
Listing 7.8 A simple Functional model with two Dense layers
inputs = keras.Input(shape=(3,), name="my_input") features = layers.Dense(64, activation="relu")(inputs) outputs = layers.Dense(10, activation="softmax")(features) model = keras.Model(inputs=inputs, outputs=outputs, name="my_functional_model")
This small Functional model shows how calling layers on an input defines connectivity before the input and output are assembled into a Keras Model. section 7.2.2
Architecture also encodes assumptions about the problem. A single Dense layer without an activation assumes that two classes can be separated linearly; convolution layers encode an expectation that useful image patterns can occur at different locations. There is no guaranteed recipe for choosing well, so use established patterns and test whether they help the task at hand. section 3.6.3 section 9.0












