liveBook · Manning

Automatic shape inference

As explained in Deep Learning with R, Third Edition

Automatic shape inference is the process of determining a layer's input and output shapes from the shapes of tensors supplied to it.

Automatic shape inference lets layers determine their input shape from the first tensor they receive, so connected layers can create compatible weights without explicit input-size arguments. section 3.6.2

A dense layer infers its input size

Create a 32-unit dense layer, pass it a tensor shaped (2, 784), and receive an output shaped (2, 32). The layer uses the inferred input dimension, 784, to create its weight matrix. section 3.6.2

How Deep Learning with R, Third Edition covers it

How deep it goes
Explains layer compatibility, build-time weight creation, and deferred state initialization without detailing complex shape rules.
Examples
Demonstrates SimpleDense with a (2, 784) tensor producing a (2, 32) tensor.
What it assumes
Assumes tensors and dense-layer computation, while demonstrating deferred weight creation from an incoming tensor.
What you can do after
Builds dense layers and sequential models without manually passing each preceding layer’s input size.
How it connects
Connects layers with tensors, weights, build methods, and model composition.

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.