Data - one_batch / next(iter(dl)) question

I’m using data from imagenette example.
When i take batch by data.one_batch(), i get stats for batch as expected - mean: 0.445 std: 0.246 min: 0.000 max: 1.000.
But when i use - next(iter(data.train_dl)), i get mean: 0.006 std: 1.064 min: -2.118 max: 2.640.
Checked code - one_batch return same next(iter(dl)) but result is different.
What I’m missing?

By default data.one_batch() denormalizes the batch (if denorm=True), whereas next(iter(data.train_dl)) does not.


Not completely related but I want to see all batches in my validation set. The following code returns the same tensor every time.


How can I achieve that?


It should be model (if model is a Learner) next(iter(

1 Like