Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

theano max works but not min #3831

Closed
sammosummo opened this issue Mar 15, 2020 · 7 comments
Closed

theano max works but not min #3831

sammosummo opened this issue Mar 15, 2020 · 7 comments

Comments

@sammosummo
Copy link

sammosummo commented Mar 15, 2020

Its seems that my version of PyMC3/Theano won't compile models containing tt.min() but will compile models with tt.max(). I've tried replacing tt.min([a, b], axis=0) with the workaround -tt.max([-a, -b], axis=0) and while this works for the toy example below, in real models, it sometimes yields the same compilation error as using min. This must be related but I haven't figured out the critical issue.

import pymc3 as pm
import theano.tensor as tt


def main():
    with pm.Model() as m1:

        a = pm.Normal(name="a", shape=5)
        b = pm.Normal(name="b", shape=5)
        c = tt.max([a, b], axis=0)

    pm.sample(model=m1)  # works fine

    with pm.Model() as m2:

        a = pm.Normal(name="a", shape=5)
        b = pm.Normal(name="b", shape=5)
        c = tt.min([a, b], axis=0)

    pm.sample(model=m2)  # raises this exception:
    # ... error: non-constant-expression cannot be narrowed from type 'npy_intp' (aka
    # 'long') to 'int' in initializer list [-Wc++11-narrowing]


if __name__ == '__main__':
    main()
  • PyMC3 Version: 3.8
  • Theano Version: 1.0.4
  • Python Version: 3.8.1
  • Operating system: MacOS
  • How did you install PyMC3: conda
@aloctavodia
Copy link
Member

I am not able to reproduce this error.

  • PyMC3 Version: master
  • Theano Version: 1.0.4
  • Python Version: 3.7.6
  • Operating system: Linux

@Ahanmr
Copy link
Contributor

Ahanmr commented Apr 1, 2020

I tried with the exact same specs, I too was not able to reproduce the error, it ran successfully. Not sure, what's causing the error.

Auto-assigning NUTS sampler... Initializing NUTS using jitter+adapt_diag... Sequential sampling (2 chains in 1 job) NUTS: [b, a] Sampling chain 0, 0 divergences: 100%|██████████| 1000/1000 [00:01<00:00, 774.57it/s] Sampling chain 1, 0 divergences: 100%|██████████| 1000/1000 [00:00<00:00, 1363.44it/s] Auto-assigning NUTS sampler... Initializing NUTS using jitter+adapt_diag... Sequential sampling (2 chains in 1 job) NUTS: [b, a] Sampling chain 0, 0 divergences: 100%|██████████| 1000/1000 [00:00<00:00, 1280.23it/s] Sampling chain 1, 0 divergences: 100%|██████████| 1000/1000 [00:00<00:00, 1363.76it/s]

  • PyMC3 Version: 3.8

  • Theano Version: 1.0.4

  • Python Version: 3.6.9 and 3.8.1

  • Operating system: Linux

@Ahanmr
Copy link
Contributor

Ahanmr commented Apr 1, 2020

I'm not too sure if this is a work-around, please feel free to correct me,
import theano
theano.config.gcc.cxxflags = "-Wno-c++11-narrowing"

@fonnesbeck
Copy link
Member

This flag is set automatically for macOS to solve a different issue, but is not set for Linux. If this solves the problem, we could add it for that platform as well.

@ricardoV94
Copy link
Member

@sammosummo Did you keep encountering this issue in newer releases?

@sammosummo
Copy link
Author

Works fine with this setup:

  • PyMC3 Version: 3.9.3
  • Theano Version: 1.0.5
  • Python Version: 3.8.5
  • Operating system: macOS

@ricardoV94
Copy link
Member

Thanks for the feedback. Will close this issue as it seems we did not hear more reports like this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants