Skip to content

[BUG] - Current item calculation in Optimization tutorial prints wrong number when data set length doesn't split evenly to batches #2742

Closed
@anttikup

Description

@anttikup

Add Link

https://pytorch.org/tutorials/beginner/basics/optimization_tutorial.html#full-implementation

Describe the bug

On line 17 in Full Implementation code of Optimization tutorial the current item is calcuated like this

loss, current = loss.item(), (batch + 1) * len(X)

which gives the wrong number on the last item if data set size doesn't split evenly to batches.

Describe your environment

web site

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions