# Can't train simple net what am I doing wrong?

Here is a minimal working example:

``````function ResNetBlock(n::Int)
return Chain(
Conv((3, 3), n => n, relu; pad=1, stride=1),
BatchNorm(n, relu),
Conv((3, 3), n => n; pad=1, stride=1),
BatchNorm(n),
)
end

function simplenet(n_filter)
return Chain(
Conv((3, 3), 4 => n_filter, relu; stride=1, pad=1),
Conv((3, 3), n_filter => n_filter, relu; stride=1, pad=1),
Conv((3, 3), n_filter => n_filter, relu; stride=1, pad=1),
Conv((3, 3), n_filter => n_filter, relu; stride=1, pad=1),
Conv((3, 3), n_filter => n_filter, relu; stride=1, pad=1),
Conv((3, 3), n_filter => n_filter, relu; stride=1, pad=1),
Conv((1, 1), n_filter => 32, relu; stride=1, pad=0),
Flux.flatten,
Dense(32 * 49, 128, relu),
Dense(128, 1, tanh),
)
end

function resnet(n_filter)
return Chain(
Conv((3, 3), 4 => n_filter, relu; stride=1, pad=1),
ResNetBlock(n_filter),
ResNetBlock(n_filter),
ResNetBlock(n_filter),
ResNetBlock(n_filter),
Conv((1, 1), n_filter => 32, relu; stride=1, pad=0),
Flux.flatten,
Dense(32 * 49, 128, relu),
Dense(128, 1, tanh),
)
end

function loss(model, x, y)
return Flux.mse(model(x), y)
end

data=[(rand(Float32,7,7,4,1),0.7f0) for k in 1:10]

model1=simplenet(4)