liveBook · Manning

Mask

Masking is the selective representation, concealment, inclusion, exclusion, or restriction of parts of data or a system according to specified criteria.

How 7 Manning books explain it

Deep Learning with PyTorch, Second Edition

How it is used
Restricts image edits, selects samples for class-specific metrics, and identifies pixels in segmentation.
How deep it goes
Works through Boolean metric masks and pretrained image workflows, but does not reimplement the inpainting pipeline or Segment Anything.
Examples
Uses a horse-to-zebra edit, per-class nodule metrics, astronaut segmentation, and masks of nodules in CT slices.
What you can do after
Apply masks via StableDiffusionInpaintPipeline or Segment Anything, and construct Boolean masks for per-class metrics.

Read how Deep Learning with PyTorch, Second Edition explains mask →

Graph Neural Networks in Action

A mask is a Boolean array or tensor that selects a subset of data elements.

How it is used
Selects labeled nodes for training while keeping other node subsets distinct in semi-supervised graph learning.
How deep it goes
Defines Boolean masks and works through their construction, embedding filtering, and use in a GNN training loop.
Examples
Uses complementary NumPy masks for a 20% labeled subset and a PyTorch `train_mask` to select predictions.
What you can do after
Build it from scratch with NumPy masks, then apply a PyTorch training mask to compute loss on labeled nodes.

Read how Graph Neural Networks in Action explains mask →

Build a Large Language Model (From Scratch)

A training-time method that prevents the model from attending to certain input positions, such as padding tokens.

How it is used
Uses masking during batched instruction fine-tuning to exclude padding and optionally prompt tokens from attention or loss.
How deep it goes
Implements padding, shifted targets, -100 replacement, and loss behavior, but leaves instruction masking optional.
Examples
Demonstrates masked target tensors, GPT end-of-text padding, and an exercise comparing instruction masking with unmasked training.
What you can do after
Apply masking via a custom PyTorch collate function and verify that ignored targets leave cross-entropy unchanged.

Read how Build a Large Language Model (From Scratch) explains mask →

Build a Text-to-Image Generator (from Scratch)

A mechanism that selectively blocks information from specified sequence positions during model computation.

How it is used
Constrains decoder self-attention so sequence predictions cannot use future positions.
How deep it goes
Explains purpose and architectural placement, while deferring detailed masking mechanics.
Examples
Uses German-to-English translation and one-token-at-a-time text generation as concrete applications.
What you can do after
Understand how masking preserves valid sequential dependencies during decoder prediction.

Read how Build a Text-to-Image Generator (from Scratch) explains mask →

CSS in Depth, Second Edition

Masking is a CSS visual technique that selectively reveals or hides portions of an element using a mask image.

How it is used
Creates irregular silhouettes, fades, and selective visibility when rectangular rendering or border-radius is insufficient.
How deep it goes
Explains the opacity principle, demonstrates image and gradient masks, and catalogs related properties without descending into rendering internals.
Examples
Uses a star-shaped image mask, a fading linear gradient, a radial vignette, and repeating-gradient stripes.
What you can do after
Build masked images, tune their placement and repetition, create gradient fades, and diagnose invisible or misaligned masks.

Read how CSS in Depth, Second Edition explains mask →

Deep Learning with R, Third Edition

Masking is the exclusion of designated sequence positions from downstream neural-network computations.

How it is used
Excludes padding tokens from recurrent computations so sequence predictions use meaningful tokens.
How deep it goes
Explains implicit embedding-layer masking and its effect on LSTM output, while deferring explicit mask construction.
Examples
Uses padded movie-review sequences and an R/Keras Embedding–bidirectional LSTM classifier.
What you can do after
Apply it via Keras by reserving zero for padding and enabling mask_zero on an Embedding layer.

Read how Deep Learning with R, Third Edition explains mask →

Deep Learning with Python, Third Edition

A technique for marking padded or irrelevant sequence positions so later layers ignore them.

How it is used
Uses masks in padded text sequences so recurrent classifiers ignore padding when producing final predictions.
How deep it goes
Explains implicit zero-based masking and optional explicit masks, without detailing custom mask construction.
Examples
Demonstrates a padded movie review ending in “awful” and a Keras Embedding-to-Bidirectional-LSTM model.
What you can do after
Operate/configure Keras sequence models that ignore zero-valued padding or accept explicit masks.

Read how Deep Learning with Python, Third Edition explains mask →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.