Tensorflow Probability: module 'collections' has no attribute 'Sequence'

  File "/Users/judau/miniconda/lib/python3.10/site-packages/tensorflow_probability/python/layers/distribution_layer.py", line 171, in _fn

    value_is_seq = isinstance(d.dtype, collections.Sequence)

AttributeError: Exception encountered when calling layer "multivariate_normal_tri_l" (type MultivariateNormalTriL).

module 'collections' has no attribute 'Sequence' 

################################################

The issue seems related to the `collections.abc` package which has been available since Python 3.3, and `collections.Mapping` and `collections.Sequence` are gone as of Python 3.10. So if you are using Python 3.10+, it might cause this type of error as discussed in the following thread.

https://github.com/tensorflow/probability/commit/76ff71ba27a5a035fa6220e6132744ac89a56fdf#

Move uses of collections.Mapping and collections.Sequence to `col…
…lections.abc`.

The `collections.abc` package has been available since Python 3.3, and `collections.Mapping` and `collections.Sequence` are gone as of Python 3.10.

No comments:

Post a Comment