Skip to content

Commit e4c306b

Browse files
committed
no more cbrt, no more abs2
1 parent 0892dbb commit e4c306b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ Flux is an elegant approach to machine learning. It's a 100% pure-Julia stack, a
2121
Works best with [Julia 1.8](https://julialang.org/downloads/) or later. Here's a very short example to try it out:
2222
```julia
2323
using Flux, Plots
24-
data = [([x], x-cbrt(x)) for x in range(-2, 2, 100)]
24+
data = [([x], 2x-x^3) for x in -2:0.1f0:2]
2525

26-
model = Chain(Dense(1 => 10, tanh), Dense(10 => 1), only)
26+
model = Chain(Dense(1 => 23, tanh), Dense(23 => 1, bias=false), only)
2727

28-
loss(x,y) = abs2(model(x) - y)
28+
loss(x,y) = (model(x) - y)^2
2929
optim = Flux.Adam()
3030
for epoch in 1:1000
3131
Flux.train!(loss, Flux.params(model), data, optim)
3232
end
3333

34-
plot(x -> x-cbrt(x), -2, 2, legend=false)
34+
plot(x -> 2x-x^3, -2, 2, legend=false)
3535
scatter!(-2:0.1:2, [model([x]) for x in -2:0.1:2])
3636
```
3737

0 commit comments

Comments
 (0)