Created
January 23, 2021 15:48
-
-
Save sdejean28/c05c4d9abfd47dae1331d4dcec78ca48 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Plots | |
using Flux | |
using NNlib | |
using Flux: @epochs | |
m = Dense(1,1) | |
loss(x, y) = sum((m(x).-y).^2) | |
dataset = [([0.8], [1.0]), | |
([2.0], [3.0]), | |
([2.4], [2.0]), | |
([0], [0.5]), | |
([1.5], [2]), | |
([3], [2.5]), | |
([4.0], [1.5])] | |
@epochs 100 Flux.train!(loss, Flux.params(m), dataset, ADAM()) | |
x = 0:5 | |
y =zeros(6) | |
for i in x | |
y[i+1] = m([i])[1] | |
end; | |
plot(dataset, seriestype = :scatter, legend = false); plot!(x,y) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment