W = rand(1, N); b = rand(1);
model = Dense(param(W), param(b), nonlinearity);
This is also roughly what happens when you call model = Dense(N,1,nonlinearity);, as you can see by looking at the source with
@edit model = Dense(N,1,nonlinearity);
One option to keep norm(W) = 1 would be to define a custom wrapper, e.g.
struct NormedDense{D}
l::D
end
function (a::NormedDense)(x::AbstractArray)
W, b, σ = a.l.W ./ norm(a.l.W), a.l.b, a.l.σ
σ.(W*x .+ b)
end
model = NormedDense(Dense(param(W), param(b), nonlinearity));