liveBook · Manning

Fully connected neural network

As explained in Deep Learning with R, Third Edition

A dense neural network is a neural network architecture in which units in one layer are connected to all units in the adjacent layer.

A fully connected neural network, also called a densely connected network, stacks Dense layers whose units connect to every unit in the adjacent layer. It processes vector data without assuming a particular feature structure, making it a practical baseline for tabular and structured data. section 20.1.6

Table 20.1 Model architectures for different data types
Input
Output
Model
Vector data
Class probability, regression value
Densely connected network
Timeseries data
Class probability, regression value
RNN, Transformer
Images
Class probability, regression value
Convnet
Text
Class probability, regression value
Transformer
Text, images
Text
Transformer
Text, images
Images
VAE, diffusion model

Use the architecture table to match fully connected networks with vector inputs and classification or regression outputs, then compare them with modality-specific alternatives. section 20.1.6

Choose the output layer and loss according to the prediction task:

  • Binary classification: one sigmoid unit with binary crossentropy. section 20.1.6
  • Single-label categorical classification: one softmax unit per class with categorical crossentropy. section 20.1.6
  • Multilabel classification: one sigmoid unit per class with binary crossentropy. section 20.1.6
  • Regression: use an output layer without an activation and mean squared error. section 13.2.3

A simple forecasting baseline

For Jena temperature forecasting, reshape each input sequence into a vector, pass it through Dense(16, activation = "relu") and Dense(1), then compile with Adam, MSE, and MAE. Save the best validation model and evaluate it on the test set. This inexpensive model provides a baseline before trying recurrent networks. section 13.2.3

Dense connectivity can represent relationships between any pair of input features, unlike convolutional layers that emphasize local relationships. That flexibility is useful when features have no known spatial or sequential structure, but it can be a poor choice when the data demands a stronger architecture prior. section 20.1.6 section 5.3.2

How Deep Learning with R, Third Edition covers it

How deep it goes
Defines all-to-all adjacent-layer connections, contrasts local convolution, and demonstrates practical classification and regression configurations.
Examples
Uses California housing, Jena temperature forecasting, and compact Keras models for binary, categorical, multilabel, and regression tasks.
What it assumes
Introduces modality-based architecture selection while targeting vector-shaped numerical or categorical attributes as the primary input.
What you can do after
Build it from scratch in R/Keras by selecting Dense layers, output activations, losses, optimizers, metrics, and evaluation procedures.
How it connects
Connects architecture choice to convolutional networks, recurrent networks, Transformers, feature engineering, and architecture priors.

Also explained in

Compare how 2 books explain fully connected neural network →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with R, Third Edition. The section links point to the parts of the book it draws on.