(also posted in Julia discourse https://discourse.julialang.org/t/what-is-a-model-in-julia-flux-0-13-and-higher/100653)
I want to use Julia Flux for machine learning with custom models (not neural networks, so I won't be using/combining models provided by Flux). I want to do it with Flux because I want access to various advanced gradient decent algorithms.
To do so I intend to use the training API (https://fluxml.ai/Flux.jl/stable/training/reference/#Training-API-Reference)
The problem is that the documentation is not very detailed. For example there are functions like
Flux.setup(rule, model)
and
Flux.train!(loss, model, data, opt_state)
however nowhere in the API there is a description of what the model is and what form should it take.
As a test problem, consider matrix factorization. That is, given matrix A
using Random
dim = 2
A = rand(dim, dim)
find such x and y that
x * y' ≈ A
I would guess that the model should be defined as model(x, y) = x * y', but then Flux.setup(AdaGrad(), model) produces a warning
Warning: setup found no trainable parameters in this model
The page you link to has an example of what a
modelis in the documentation ofFlux.Train.setup:It might be easier to look at the "Fitting a straight line" part of the docs:
https://fluxml.ai/Flux.jl/stable/models/overview/