📘
SGD Parameter Update
EasyDeep Learning
Problem Statement
Perform a single Stochastic Gradient Descent update step.
Background
In SGD, parameters are updated using gradients and a learning rate α (alpha):
W=W−α⋅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×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
Python 3.13.1
Test Results
0/0Run code to see test results.