Skip to content

Commit

Permalink
PyTorch: Fix SGD ValueError
Browse files Browse the repository at this point in the history
  • Loading branch information
AnirudhDagar committed Aug 9, 2023
1 parent 042c11c commit e709c64
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflow_scripts/build_pytorch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ d2lbook build outputcheck tabcheck
# Move aws copy commands for cache restore outside
if [ "$DISABLE_CACHE" = "false" ]; then
echo "Retrieving pytorch build cache from "$CACHE_DIR""
measure_command_time "aws s3 sync s3://preview.d2l.ai/"$CACHE_DIR"/"$REPO_NAME"-"$TARGET_BRANCH"/_build/eval_pytorch _build/eval_pytorch --delete --quiet --exclude 'data/*'"
measure_command_time "aws s3 sync s3://preview.d2l.ai/"$CACHE_DIR"/"$REPO_NAME"-"$TARGET_BRANCH"/_build/eval_pytorch/ _build/eval_pytorch/ --delete --quiet --exclude 'data/*'"
echo "Retrieving pytorch slides cache from "$CACHE_DIR""
aws s3 sync s3://preview.d2l.ai/"$CACHE_DIR"/"$REPO_NAME"-"$TARGET_BRANCH"/_build/slides _build/slides --delete --quiet --exclude 'data/*'
fi
Expand Down
4 changes: 2 additions & 2 deletions chapter_optimization/sgd.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ def f_grad(x1, x2): # 目标函数的梯度
def sgd(x1, x2, s1, s2, f_grad):
g1, g2 = f_grad(x1, x2)
# 模拟有噪声的梯度
g1 += d2l.normal(0.0, 1, (1,))
g2 += d2l.normal(0.0, 1, (1,))
g1 += d2l.normal(0.0, 1, (1,)).item()
g2 += d2l.normal(0.0, 1, (1,)).item()
eta_t = eta * lr()
return (x1 - eta_t * g1, x2 - eta_t * g2, 0, 0)
```
Expand Down

0 comments on commit e709c64

Please sign in to comment.