wesselb / stheno

Gaussian process modelling in Python
MIT License
217 stars 18 forks source link

problem with running examples #7

Closed fatemeRsh1995 closed 3 years ago

fatemeRsh1995 commented 3 years ago

Hi Wessel!

when I run the "readme_example8_gp-rnn.py" I get this error:

TypeError: Can not convert a NoneType into a Tensor or Operation.

what should I do for this problem?

Any help will be grateful.

wesselb commented 3 years ago

Hi @fatemeRsh1995!

Thanks for opening an issue. :) Just letting you know that I can reproduce the error and that I'm looking into it.

wesselb commented 3 years ago

Hey @fatemeRsh1995, I've looked into the problem and the issue was the use of tf.function. The calls to the optimiser should be slightly different:

# Pretrain the RNN.
vs = Vars(tf.float32)
minimise_adam(objective_rnn, vs, rate=1e-2, iters=1000, trace=True, jit=True)

# Jointly train the RNN and GPs.
minimise_adam(objective_gp_rnn, vs, rate=1e-3, iters=1000, trace=True, jit=True)

With this change, the example runs fine for me! Let me know if the updated example also works for you.

Note that the particular GP-RNN model is a bit fiddly and can require a couple restarts to fit well.

fatemeRsh1995 commented 3 years ago

Yes! that's it. thanks a lot Wessel! It fix'd :)

wesselb commented 3 years ago

Glad to hear that! :)