Basics steps to build an ANN?

So… just by trial and error, I found that collect() changed a tracked array to an ordinary array. Don’t know if that works for arbitrary x_d, though. With a slight change of the function (shifting it along x_d so that a bias is necessary…):

# Packages
using Flux
using Plots; pyplot()
using Statistics
# Data
x_d = reshape(collect(range(0,pi,length=100)),1,100)
y_d = sin.(x_d.-pi/2)
data = [(x_d,y_d)]
# Set up Flux problem
mod = Dense(1,1,tanh)
# Initial fit
plot(x_d',y_d',label="data")
y_0 = Float64.(collect(mod(x_d)))
plot!(x_d',y_0',label="initial guess")
par = params(mod)
loss(x, y) = mean((mod(x).-y).^2)
opt = ADAM(0.002, (0.99, 0.999))
@Flux.epochs 3000 Flux.train!(loss,par,data,opt);
y_1k = Float64.(collect(mod(x_d)))
plot!(x_d',y_1k',label="fit @ 3000 epochs")

gives the plot:

Checking parameters and loss at 3000 epochs:

julia> par
Params([Float32[1.05148] (tracked), Float32[-1.64145] (tracked)])

julia> loss(x_d,y_d)
0.00265027057055282 (tracked)

A little bit more of playing around, but I guess I'll check out the JuliaAcademy soon.

Anyway, this is fun! And… just an initial test.