Sorry I just realized that this error comes from the tensorflow_probability package I took from the tensorflow/probability github repository (unless it is the same as TFP).
But I still don’t understand why I get the error when importing this package (after I already imported it one time) without doing anything else. I get the error
ValueError: Name tfp.util.DeferredTensorSpec has already been registered for class tensorflow_probability.python.util.deferred_tensor._DeferredTensorSpec.
or more specifically from this part of type_spec.py in the package :
def register(name):
“”"Decorator used to register a globally unique name for a TypeSpec subclass.
Args:
name: The name of the type spec.  Must be globally unique.  Must have
the form "{project_name}.{type_name}".  E.g. "my_project.MyTypeSpec".
Returns:
A class decorator that registers the decorated class with the given name.
“”"
if not isinstance(name, str):
raise TypeError(“Expected name to be a string; got %r” % (name,))
if not _REGISTERED_NAME_RE.match(name):
raise ValueError(
"Registered name must have the form ‘{project_name}.{type_name}’ "
“(e.g. ‘my_project.MyTypeSpec’); got %r.” % name)
def decorator_fn(cls):
if not (isinstance(cls, type) and issubclass(cls, TypeSpec)):
raise TypeError(“Expected cls to be a TypeSpec; got %r” % (cls,))
if cls in _TYPE_SPEC_TO_NAME:
raise ValueError(“Class %s.%s has already been registered with name %s.”
% (cls.module, cls.name,
_TYPE_SPEC_TO_NAME[cls]))
if name in _NAME_TO_TYPE_SPEC:
raise ValueError(“Name %s has already been registered for class %s.%s.”
% (name, _NAME_TO_TYPE_SPEC[name].module,
_NAME_TO_TYPE_SPEC[name].name))
_TYPE_SPEC_TO_NAME[cls] = name
_NAME_TO_TYPE_SPEC[name] = cls
return cls
return decorator_fn
Any idea why would importing this package twice leads to this error?
Sorry again for the confusion!