Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code consistency fix in linear-regression-scratch.md #2631

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions chapter_linear-regression/linear-regression-scratch.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def prepare_batch(self, batch):
%%tab pytorch
@d2l.add_to_class(d2l.Trainer) #@save
def fit_epoch(self):
self.model.train()
self.model.training = True
for batch in self.train_dataloader:
loss = self.model.training_step(self.prepare_batch(batch))
self.optim.zero_grad()
Expand All @@ -360,7 +360,7 @@ def fit_epoch(self):
self.train_batch_idx += 1
if self.val_dataloader is None:
return
self.model.eval()
self.model.training = False
for batch in self.val_dataloader:
with torch.no_grad():
self.model.validation_step(self.prepare_batch(batch))
Expand Down
Loading