MXFusion icon indicating copy to clipboard operation
MXFusion copied to clipboard

Printing summary of optimized parameters

Open adamian opened this issue 6 years ago • 1 comments

Hi Team,

I can't figure out how to intuitively print a summary of the parameters that the optimizer sees. I can either print the uuid (not useful since I can't translate it to variable names) or the optimized values, but what I'm looking for is a way to make the connection: parameter_name: optimized_value e.g. kernel.lengthscale: 0.1.

Right now I'm using this:

m = Model()
kernel = RBF(input_dim=1)
m.y = GPRegression.define_variable(kernel=kernel,...)


infr = GradBasedInference(model=m, ...)
infr.run(...)

my_gp = m.y.factor

param_names = [
    'my_gp.kernel.rbf.lengthscale',
    'my_gp.kernel.rbf.variance'
]

param_keys = [
    my_gp._module_graph.kernel.rbf.lengthscale,
    my_gp._module_graph.kernel.rbf.variance
]

for i in range(len(param_keys)):
    print(param_names[i], infr.params[param_keys[i]].asnumpy())

But obviously I'd love some code that doesn't assume I know the structure of the model and is instead automatically parsing the model and/or infr object to generate the parameter report.

Thanks! Andreas

adamian avatar Oct 19 '18 10:10 adamian

Thanks, this definitely needs some improvement. It should be possibly to add something along the lines of

print(infr.params)
> Variable(1ab23)(name=y) - (Model/Posterior(123ge2)) - (first mxnet values/shape)
> ....

Thanks for the example code of how you're doing it!

meissnereric avatar Oct 19 '18 11:10 meissnereric