Warnings when using math equations in likelihood

Hi, I’m new to pymc, I want to know if there is a way to avoid having this warnings:
C:\Users\USUARIO\anaconda3\envs\pymc_env\Lib\site-packages\pytensor\tensor\rewriting\elemwise.py:701: UserWarning: Optimization Warning: The Op true_div does not provide a C implementation. As well as being potentially slow, this also disables loop fusion.
Happens with Op row, true_div and reciprocal.
I’m using simple numpy operations and I have all the newest versions of the libraries.
Thanks all.

1 Like


In general, it’s advisable to replace numpy functions with PyTensor functions (the APIs should match, PyTensor’s tensor functionality can be seen here). If you provide your likelihood, we may be able to make more concrete suggestions.

1 Like


def modelo(Ro, Ml, tau, c,F):
base=(1j * 2np.piF * tau)
aux = Ml * (1 - 1 / (1 + np.power(base,c)))
R = Ro / (1 + aux)
return R

with pm.Model() as ModelOne:
R_modelo = modelo(Ro, Ml, tau, c,F_val)
R_obs=pm.Normal(‘R_obs’,mu=R_modelo,sigma=epsilon, observed=Z)

I put it in a simple way, I defined the parameters in the model. But this part is what causes the warnings

cluhmann was suggesting you remove the numpy functions in order to speed up the model. So instead of


you can use:

import pytensor.tensor as pt
pt.pow(base, c)

1 Like