PIXELBANKv8.2.1
Menu

SGD Parameter Update

Problem Statement

Perform a single Stochastic Gradient Descent update step.

Background

In SGD, parameters are updated using gradients and a learning rate α\alpha (alpha):

W=WαdWW = W - \alpha \cdot dW

This simple rule moves parameters in the direction that reduces the loss.

Your Task

Write a function sgd_update(weights, gradients, learning_rate) that performs a single SGD update on a list of weights.

Output Format

Return a list of updated weights. Round each value to 4 decimal places.

Example:

Input:
weights=[1.0], gradients=[0.5], learning_rate=0.1
Output:
[0.95]
Reasoning:

1.0 - (0.1×01 \times 0.5) = 1.0 - 0.05 = 0.95

Constraints:

  • -1000 <= weights[i], gradients[i] <= 1000
  • 0 < learning_rate <= 1
  • List length: 1 to 100 elements
Editor

Test Results

0/0
Run code to see test results.