Skip to content

theano max works but not min #3831

Closed
Closed
@sammosummo

Description

@sammosummo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions