Toy Cells vs Captured Cells
Compare the handful of cells drawn in a notebook preview against the full rectangular grid captured inside a tensor.
The problem
A textbook diagram displays a table of four rows and two columns so your eye can scan every entry at once. Real feature matrices keep the same two-dimensional layout, yet neither dimension stays at single digits. Suppose we compare three table shapes : a toy table [4, 2], a small clinic study [50, 12], and a modest sensor log [250, 40].
If a notebook preview window displays at most cells, how many feature cells exist in the captured tensor, and how many remain unseen outside that preview box? Answering requires counting all rectangular grid entries and clamping unseen counts at whenever the preview window is larger than a tiny table.
Work through the numbers
Multiply row count by column count for each shape. Shape [4, 2] holds cells. Shape [50, 12] holds cells. Shape [250, 40] holds cells. Growing rows from to () while growing columns from to () multiplies cell count by , turning numbers into .
Now compare each tensor against a default preview window of cells. For [4, 2], unshown cells: paper shows the entire dataset. For [50, 12], unshown cells. For [250, 40], unshown cells, meaning of the matrix sits outside the printed box.
Check the boundary when the preview window exceeds a tiny table. At preview_rows , the window holds up to cells. Since is not a valid count of hidden entries, reports [8, 0] for [4, 2], alongside [600, 580] and [10000, 9980].
The live model
Each horizontal bar pair shows total captured cells in blue and unshown cells in amber on a shared scale across the three table shapes. At preview_rows , the [250, 40] bar pair reaches [10000, 9992] while the [4, 2] toy table sits near zero at [8, 0]. Drag preview_rows down to to leave unshown cells in [4, 2], or up to to see [600, 580] and [10000, 9980].
![Paired bars for shapes [4, 2], [50, 12], and [250, 40] showing captured vs unshown cells [8, 0], [600, 592], and [10000, 9992] at preview_rows 4.](../assets/ml/toy-cells-vs-captured-cells--demo.png)
let preview_rows = scene.parameter("preview_rows", 4.0, 2.0, 10.0, 2.0);
let rows = input.select(1, 0);
let cols = input.select(1, 1);
let total = rows * cols;
let shown = preview_rows * 2.0;
let hidden = (total - shown).clamp(0.0, 1000000000.0);
let cols_out = torch.list().add(total.unsqueeze(1)).add(hidden.unsqueeze(1));
let answer = torch.cat(cols_out, 1);
out.set("captured_and_unshown", answer);
{
"captured_and_unshown": [
[
8,
0
],
[
600,
592
],
[
10000,
9992
]
]
}Watch the parameter change
Your turn
For each [rows, columns] row in input, answer must return the two-column pair [captured_cells, unshown_cells] against a two-column preview window of height preview_rows. On the visible fixture at preview_rows , the expected result is [[8, 0], [600, 592], [10000, 9992]]. Check varies both table dimensions and preview_rows across unseen inputs, including cases where the preview window holds more cells than the first table.
![Starter bars using row-plus-column sums [6, 0], [62, 54], and [290, 282] instead of rectangular cell products.](../assets/ml/toy-cells-vs-captured-cells--exercise.png)
let preview_rows = scene.parameter("preview_rows", 4.0, 2.0, 10.0, 2.0);
let rows = input.select(1, 0);
let cols = input.select(1, 1);
let total = rows + cols;
let shown = preview_rows * 2.0;
let hidden = (total - shown).clamp(0.0, 1000000000.0);
let cols_out = torch.list().add(total.unsqueeze(1)).add(hidden.unsqueeze(1));
let answer = torch.cat(cols_out, 1);
out.set("captured_and_unshown", answer);
{
"captured_and_unshown": [
[
6,
0
],
[
62,
54
],
[
290,
282
]
]
}Compute total rectangular grid cells and clamped unshown cells for each [rows, columns] shape instead of adding rows and columns. Check tests larger preview windows and unseen table shapes.
Read the result carefully
Spot-checking the first four rows and two columns confirms column units and catches gross parsing blunders, yet it inspects almost none of a 10,000-cell table. A corrupted sensor value in row 180 or a constant feature in column 31 will never appear in a fixed top-left preview.
That gap explains why tensor reductions such as column mins, column maxes, missing-value sums, and shape assertions replace visual scanning as soon as dimensions leave single digits. Summary statistics inspect every captured cell systematically without printing ten thousand numbers.
Recap
- An feature matrix captures scalar cells, so scaling both axes multiplies storage rather than adding to it.
- Unshown cell count equals , flooring at when the preview window exceeds the table.
- Top-left table previews verify layout on a handful of cells but cannot substitute for full-tensor reductions over unseen rows and columns.