@sylvaticus Sorry, script below:
xtrain = pi*rand(10000,5);
ytrain = sin.(xtrain) + 0.5 * cos.(xtrain);
xtest = pi*rand(1,5);
ytest = sin.(xtest) + 0.5 * cos.(xtest);
# dimension of input
Nod₀ = size(xtrain,2);
# dimension of output
Nodₗ = size(ytrain,2);
# number of layers
Nₗ = 4;
# layers dimensions;
lᵨ = Int64.(ceil.(Int64,(Nₗ*2)*rand(Nₗ).+1));
lᵨ[1] = Nod₀;
lᵨ[end] = Nodₗ;
all_layers = Layer[];
for j = 2:Nₗ;
# Populate layer j
l1 = BuildLayer(relu,drelu,lᵨ[j],lᵨ[j-1]);
# Push populated layers into one array.
push!(all_layers,l1);
end
# Assemble the NN structure.
myfnn = BuildNetwork(all_layers,cost,dcost);
Train!(myfnn,xtrain,ytrain,epochs=20,η=0.001,rshuffle=true);
Errors(myfnn,xtest,ytest)
y_pred = Predict(myfnn,xtest)
gr() # We will continue onward using the GR backend
p1=scatter(xtrain,
ytrain,
markershape = :hexagon,
markersize = 2,
markeralpha = 0.6,
markercolor = :green,
markerstrokewidth = 2,
markerstrokealpha = 0.2,
markerstrokecolor = :green,
markerstrokestyle = :dot,
xlabel = "x data",
ylabel = "y data",
xlims = (0,pi),
xticks = (0:pi/4:pi,["0", "\\pi/4","\\pi/2", "3\\pi/2","\\pi"]),
xflip = false,
ylims = (0,1.2),
yticks = (0:0.2:1.2,string.(collect(0:0.2:1.2))),
yflip = false,
xtickfont = font(10, "Courier"),
ytickfont = font(10, "Courier"),
label = "",
title = "My NN example")
scatter!(p1,xtest, ytest,
markershape = :hexagon,
markersize = 10,
markeralpha = 0.6,
markercolor = :red,
markerstrokewidth = 2,
markerstrokealpha = 0.2,
markerstrokecolor = :red,
markerstrokestyle = :dot,
label = "",
color=:red)
scatter!(p1,xtest, y_pred,
markershape = :hexagon,
markersize = 10,
markeralpha = 0.6,
markercolor = :blue,
markerstrokewidth = 2,
markerstrokealpha = 0.2,
markerstrokecolor = :blue,
markerstrokestyle = :dot,
label = "",
color=:blue)