🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
Back to Deep Learning Notes
Topic #56

Neural Network Architecture

"Architecture" describes the overall structure of a neural network — how many layers it has, how wide each one is, and how they connect. This note establishes the vocabulary for talking about network structure precisely, before the next notes zoom into each layer type individually.

The Three Layer Types

LayerRoleCount
Input layerReceives the raw feature vector — performs no computation itselfExactly 1
Hidden layer(s)Learn intermediate representations between input and output0 or more (0 = a single-layer Perceptron)
Output layerProduces the network's final prediction, shaped to the taskExactly 1

Depth and Width

TermMeaningEffect of Increasing It
DepthNumber of layers (usually counting hidden + output)More capacity for hierarchical, compositional representations; harder to train (vanishing gradients) without careful design
WidthNumber of neurons in a given layerMore capacity to represent complex functions within one layer; more parameters, more overfitting risk with limited data

A network with many layers is called "deep" — this is literally where "deep learning" gets its name.

Common Architecture Patterns

  • Fully connected (dense): every neuron in one layer connects to every neuron in the next — the MLP pattern from the previous note. Flexible, but doesn't exploit any structure in the input (like an image's spatial layout).
  • Convolutional: neurons connect only to a local neighborhood of the previous layer, with shared weights across positions — exploits spatial structure in images (covered fully in the CNN Fundamentals category).
  • Recurrent: connections loop back on themselves across time steps — suited to sequential data (covered in the RNN category).

Notation for Describing an Architecture

A common shorthand: "784-128-64-10" describes an MLP with 784 input features, two hidden layers of 128 and 64 neurons, and 10 output classes. This single line fully specifies the shape of every weight matrix in the network — a habit worth building, since it's exactly what you'll need to debug shape errors in real code.

Code — Reading Architecture from a PyTorch Model

import torch.nn as nn

model = nn.Sequential(
    nn.Linear(784, 128), nn.ReLU(),
    nn.Linear(128, 64),  nn.ReLU(),
    nn.Linear(64, 10)
)
print(model)
# Sequential(
#   (0): Linear(in_features=784, out_features=128, bias=True)
#   (1): ReLU()
#   (2): Linear(in_features=128, out_features=64, bias=True)
#   (3): ReLU()
#   (4): Linear(in_features=64, out_features=10, bias=True)
# )

total_params = sum(p.numel() for p in model.parameters())
print(total_params)   # counts every weight and bias across all layers

Common Mistakes

  • Assuming architecture design is arbitrary or purely a matter of trial and error — matching architecture to data structure (convolutional for images, recurrent/attention-based for sequences) is a core engineering decision with strong theoretical and empirical justification, covered in depth in later categories.
  • Conflating "deep" with "good" — depth without appropriate techniques (residual connections, normalization, careful initialization) can make training harder, not better, due to vanishing/exploding gradients.

Interview Relevance

Q: "What's the difference between making a network 'deeper' vs 'wider,' and what are the tradeoffs?" Deeper means more layers, enabling more hierarchical/compositional representations but increasing training difficulty (vanishing gradients) without mitigations like residual connections. Wider means more neurons per layer, increasing per-layer capacity and parameter count, with a more direct overfitting risk on limited data but generally easier optimization than comparable added depth.

Practice Question

Describe the architecture "3072-512-256-100" in words: what could the input and output layer sizes plausibly represent for an image classification task?

Want to go beyond the notes?

Join CodingNow 2.0's Deep Learning course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Neural Network Architecture – FAQs

Quick answers about learning Neural Network Architecture in Deep Learning.

This free note from CodingNow 2.0 explains Neural Network Architecture in Deep Learning — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every Deep Learning topic on CodingNow 2.0, including Neural Network Architecture, is 100% free with no signup required.
With focused practice, most students grasp Neural Network Architecture in 1–3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now