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

recompute_test_point fails after pickling #5090

Closed
ferrine opened this issue Oct 20, 2021 · 1 comment · Fixed by #5130
Closed

recompute_test_point fails after pickling #5090

ferrine opened this issue Oct 20, 2021 · 1 comment · Fixed by #5130
Assignees
Labels

Comments

@ferrine
Copy link
Member

ferrine commented Oct 20, 2021

Recompute_test_point fails after pickling

Please provide a minimal, self-contained, and reproducible example.

def test_pickling():
    import cloudpickle
    with pm.Model() as model:
        pm.Normal("one")
    model = cloudpickle.loads(cloudpickle.dumps(model))
    model.recompute_initial_point()

Please provide the full traceback.

Complete error traceback
>       model.recompute_initial_point()

pymc/tests/test_initial_point.py:74:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pymc/model.py:945: in recompute_initial_point
    fn = make_initial_point_fn(model=self, return_transformed=True)
pymc/initial_point.py:185: in make_initial_point_fn
    graph.replace_all(zip(rng_nodes, new_rng_nodes), import_missing=True)
../../.pyenv/versions/3.8.7/envs/pymc3/lib/python3.8/site-packages/aesara/graph/fg.py:554: in replace_all
    self.replace(var, new_var, **kwargs)
../../.pyenv/versions/3.8.7/envs/pymc3/lib/python3.8/site-packages/aesara/graph/fg.py:515: in replace
    new_var = var.type.filter_variable(new_var, allow_convert=True)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = RandomStateType, other = RandomStateSharedVariable(<RandomState(PCG64) at 0x7FEE7A091240>), allow_convert = True

    def filter_variable(
        self, other: Union[Variable, D], allow_convert: bool = True
    ) -> Variable:
        r"""Convert a symbolic variable into this `Type`, if compatible.

        For the moment, the only `Type`\s compatible with one another are
        `TensorType` and `GpuArrayType`, provided they have the same number of
        dimensions, same broadcasting pattern, and same dtype.

        If `Type`\s are not compatible, a ``TypeError`` should be raised.

        """
        if not isinstance(other, Variable):
            # The value is not a Variable: we cast it into
            # a Constant of the appropriate Type.
            other = self.Constant(type=self, data=other)

        if other.type != self and allow_convert:
            other2 = self.convert_variable(other)
            if other2 is not None:
                return other2

        if other.type != self:
>           raise TypeError(
                "Cannot convert Type %(othertype)s "
                "(of Variable %(other)s) into Type %(self)s. "
                "You can try to manually convert %(other)s into a %(self)s."
                % dict(othertype=other.type, other=other, self=self)
            )
E           TypeError: Cannot convert Type RandomStateType (of Variable RandomStateSharedVariable(<RandomState(PCG64) at 0x7FEE7A091240>)) into Type RandomStateType. You can try to manually co
nvert RandomStateSharedVariable(<RandomState(PCG64) at 0x7FEE7A091240>) into a RandomStateType.

Related to #4582

Versions and main components

  • PyMC/PyMC3 Version: master
  • Aesara/Theano Version: master
  • Python Version: 3.9
  • Operating system: Linux
  • How did you install PyMC/PyMC3: development
@ferrine
Copy link
Member Author

ferrine commented Oct 22, 2021

should be related to #4983

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

Successfully merging a pull request may close this issue.

2 participants