liveBook · Manning

Sequence

As explained in Deep Learning with PyTorch, Second Edition

A dataset whose observations are ordered successive timepoints.

A time-series dataset contains observations at successive timepoints. Unlike an ordinary table whose rows can be treated independently, row order matters: an earlier observation may help predict a later one. In hourly bike-sharing data, for example, earlier rain could help predict later rental counts. section 4.4 section 4.4.1

The bike-sharing data starts as one row per hour, with columns for weather, temperature, rental counts, and other variables. To give a neural network fixed-size chunks, group the hours into days. The resulting tensor can have shape N × C × L: days × variables × hours. Keeping variables on the middle axis makes each variable’s 24-hour sequence accessible as a whole. Days × hours × variables is also a valid arrangement. section 4.4.1 section 4.4.2

Turn hourly rows into daily sequences

For 17,520 hourly rows with 17 columns, `bikes.view(-1, 24, bikes.shape[1])` gives a 730 × 24 × 17 tensor. Then `daily_bikes.transpose(1, 2)` gives 730 × 17 × 24: one day, 17 variables, and 24 hourly values along the respective axes. This grouping requires complete, correctly ordered hours; the example file fills hours missing from the original data. section 4.4.2

A day is a useful chunk because daily rhythms may help prediction, but it is not the only choice: complete data could instead be grouped into 168-hour weeks. Before training, categorical weather conditions can be one-hot encoded, and quantitative variables such as temperature can be rescaled or standardized. This prepares the sequences for a model; it does not train one. section 4.4.2 section 4.4.3

How Deep Learning with PyTorch, Second Edition covers it

How deep it goes
Works through tensor reshaping and feature preparation, stopping before model training.
Examples
Uses hourly bike-sharing records from 2011–2012, including weather and rental counts, reshaped into 730 daily sequences.
What it assumes
Builds on flat tables and basic tensor axes while demonstrating how to add a time dimension.
What you can do after
Apply it via PyTorch to reshape ordered hourly rows into daily tensors and prepare variables for training.
How it connects
Connects tensor dimensions and tabular data to prediction across time, one-hot encoding, and feature scaling.

Also explained in

Compare how 22 books explain sequence →

Related concepts

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