I’d like to fit a normalizing flow to some data using Bijectors.jl. I’m a bit lost because I couldn’t find any complete examples. This is what I managed to do so far:
using Bijectors using KernelDensity using StatsPlots using ReverseDiff function test_nf() # some data + plotting data = reduce(vcat, [(x, sin(10*x) + exp(-y)) for x in 0.0:0.001:1.0, y in 0.0:0.1:1.0]) dens = kde(([data[i] for i in 1:length(data)], [data[i] for i in 1:length(data)])) plot(dens) # normalizing flow base_dist = MvNormal(zeros(2), ones(2)) layers = reduce(∘, [ PlanarLayer(2, ReverseDiff.track) for i in 1:5 ]) flow = transformed(base_dist, layers) # how to fit parameters? end
Readme of Bijectors.jl explains how to do a forward pass or obtain a gradient but not how to update the weights. Could I maybe use Flux for optimization?