using Flux, Flux.Data.MNIST, Statistics, Flux.Optimise
using Flux: onehotbatch, onecold, crossentropy, throttle
using Base.Iterators: repeated
using LinearAlgebra

# Training data: ATTENZIONE UNA COLONNA PER OGNI INPUT!
X = [0 0 1 1; 0 1 0 1]
Y = [0.0 1 1	0.0]

f = Chain(
  Dense(2, 3, σ),
  Dense(3, 1, sigmoid))

# Loss function: square error
L(x, y) = sum((y .- f(x)).^2) 

dataset = repeated((X, Y), 3000)
opt = Descent()

Flux.train!(L, params(f), dataset, opt)

println(L(X, Y))

println(f([0;0]))
println(f([0;1]))
println(f([1;0]))
println(f([1;1]))