Skip to content

Commit 7167e30

Browse files
fix back class 01
1 parent 0887916 commit 7167e30

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

class01/background_materials/math_basics.jl

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ end
107107
begin
108108
if ismissing(∂f╱∂ωₙ)
109109
still_missing()
110-
elseif ∂f╱∂ωₙ == a[n] && grad_f == ∇f
110+
elseif ∂f╱∂ωₙ == _ans && grad_f == ∇f
111111
correct()
112112
else
113113
keep_working()
@@ -121,14 +121,17 @@ Compute the gradient of the function:
121121
122122
```math
123123
124-
f(w_1, w_2, w_3) = w_1 w_2 + w_2 w_3 + w_3 w_1
124+
f_2(w_1, w_2, w_3) = w_1 w_2 + w_2 w_3 + w_3 w_1
125125
126126
```
127127
128128
"
129129

130130
# ╔═╡ 611c28fa-9542-11ea-1751-fbdedcfb7690
131-
ans2=missing
131+
begin
132+
f2(w) = w[1] * w[2] + w[2] * w[3] + w[3] * w[1]
133+
∇f2 = (w) -> missing # replace missing with the function that computes the gradient of `f2`
134+
end
132135

133136
# ╔═╡ da942073-32d5-4de5-82c0-271a0cb0e903
134137
md" **Lets check our answer (with Automatic Differentiation - AD):**
@@ -137,13 +140,16 @@ Symbolic Differentiation may not always be possible, making it beneficial to hav
137140
"
138141

139142
# ╔═╡ 9972495f-79f4-4612-99db-d97c3e9d57b4
140-
zygote_ans = f'(rand(N))
143+
begin
144+
w2 = rand(3) # Random vector of size 3
145+
zygote_ans = f2'(w2)
146+
end
141147

142148
# ╔═╡ e6948424-ce04-4bed-b9d1-ab6c5a513ffa
143149
begin
144-
if ismissing(ans2)
150+
if ismissing(∇f2(w2))
145151
still_missing()
146-
elseif zygote_ans == ans2
152+
elseif zygote_ans == ∇f2(w2)
147153
correct()
148154
else
149155
keep_working()

0 commit comments

Comments
 (0)