Skip to content

in video 103 why we used enumerate to loop through test_dataloader but didn't use enumerate to loop through test_dataloader #584

Answered by wittyalias
D1Asif asked this question in Q&A
Discussion options

You must be logged in to vote

Enumerate (have a look at the documentation) returns an iterator that are pairs of elements and their indexes. In the first loop, the index is assigned to batch, while the values are put into X and y. It looks like this is done so that ever 400 batches, it gives an update: if batch % 400 == 0:...
There's no need to have access to the batch number because there's no updates in the second loop, so no need for enumerate.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@mrdbourke
Comment options

@D1Asif
Comment options

Answer selected by mrdbourke
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants