Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer Challenge: Implement Custom Optimizer Step | Optimization Algorithms in Practice
Practice
Projects
Quizzes & Challenges
Quizzen
Challenges
/
Optimization and Regularization in Neural Networks with Python
Sectie 2. Hoofdstuk 4
single

single

bookChallenge: Implement Custom Optimizer Step

Veeg om het menu te tonen

Taak

Swipe to start coding

You will implement a custom optimizer step (manual SGD update) using PyTorch autograd.

You are given a learnable weight w and a small dataset. The code already computes predictions and loss. Your goal is to manually perform one gradient descent step without using torch.optim.

Complete the missing parts:

  1. Compute gradients of loss with respect to w.
  2. Update w using SGD: wwlrwlossw \leftarrow w - lr \cdot \nabla_w loss
  3. Reset the gradient stored in w.grad to avoid accumulation.

After the update, the code prints the updated weight and the loss value.

Oplossing

Switch to desktopSchakel over naar desktop voor praktijkervaringGa verder vanaf waar je bent met een van de onderstaande opties
Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 2. Hoofdstuk 4
single

single

Vraag AI

expand

Vraag AI

ChatGPT

Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.

some-alt