Skip to content

page 532 Batch for loop seems missing #193

Closed Answered by rasbt
kaukab asked this question in Q&A
Discussion options

You must be logged in to vote

That's a good question and point. The batch iteration is done via the seq_batch, target_batch = next(iter(seq_dl)) in

for epoch in range(num_epochs):
    hidden, cell = model.init_hidden(batch_size)
    seq_batch, target_batch = next(iter(seq_dl))

But if I were to rewrite that, I would change it to

for epoch in range(num_epochs):
    hidden, cell = model.init_hidden(batch_size)
    for batch_idx, (seq_batch, target_batch) in enumerate(seq_dl):
        ...

Replies: 1 comment

Comment options

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