Hi all,
I have a symbolic neural network, parameterised by theta=theta_vals which I wish to evaluate at some point x. I construct the neural network as:
using Lux, ModelingToolkit, ModelingToolkitNeuralNets
nn_arch = Lux.Chain(
Lux.Dense(1 => 3, Lux.softplus, use_bias = true),
Lux.Dense(3 => 1, Lux.softplus, use_bias = true)
)
nn, theta = SymbolicNeuralNetwork(;
nn_p_name = :theta,
chain = nn_arch,
n_input = 1,
n_output = 1
)
theta_vals = ModelingToolkit.getdefault(theta)
I tried to convert nn to a function I could evaluate numerically by running
@variables x[1]
nn_num = ModelingToolkit.build_function(nn.f, theta, x; expression = Val{false})
nn_num(theta_vals, [1.0])
But this threw
ERROR: UndefVarError: `NN` not defined in `Symbolics`
I’m not sure where I’m going wrong here - how can I construct the parameterised neural network function that I can evaluate numerically?
Thanks!