@@ -98,8 +98,8 @@ print(len(glob.glob(f"{shard_dir}/*.parquet")), "shards written")
9898It reads one shard at a time and gets ` n_rows ` from the Parquet metadata without
9999scanning the data, so ` total_size="auto" ` resolves ` N ` for free. The ` DataLoader `
100100batches and shuffles it into fixed-size minibatches. The model reads a
101- ` pm.Data("batch", ...) ` placeholder, the only data resident at any point , and the
102- ` Trainer ` writes each minibatch into it with ` set_data ` . There are no callbacks:
101+ ` pm.Data("batch", ...) ` placeholder holding a single batch , and the ` Trainer `
102+ writes each minibatch into it with ` set_data ` . There are no callbacks:
103103` total_size=len(loader) ` triggers the ` N / batch_size ` rescaling and ` Trainer.fit `
104104runs the loop.
105105
@@ -117,7 +117,7 @@ loader = DataLoader(
117117
118118with pm.Model() as model:
119119 b = pm.Normal("b", 0.0, 3.0, shape=4)
120- batch = pm.Data("batch", np.zeros((batch_size, 4))) # placeholder, the only data in RAM
120+ batch = pm.Data("batch", np.zeros((batch_size, 4))) # placeholder for one minibatch
121121 logit = b[0] + b[1] * batch[:, 0] + b[2] * batch[:, 1] + b[3] * batch[:, 2]
122122 pm.Bernoulli("y", logit_p=logit, observed=batch[:, 3], total_size=len(loader))
123123
@@ -179,7 +179,7 @@ fig.tight_layout();
179179
180180Both paths feed the same ` batch_size ` to ADVI, but ` pm.Minibatch ` keeps all ` N `
181181rows resident, so its array grows linearly in ` N ` , while the streaming ` DataLoader `
182- only holds one ` batch_size ` buffer. The dense ` float64 ` design matrix dominates the
182+ holds one batch plus its bounded shuffle buffer. The dense ` float64 ` design matrix dominates the
183183cost. The line below is its lower bound (` N * ncols * 8 ` bytes), not a measurement:
184184
185185``` {code-cell} ipython3
0 commit comments