brendanhasz / probflow

A Python package for building Bayesian models with TensorFlow or PyTorch
http://probflow.readthedocs.io
MIT License
170 stars 17 forks source link

Requires tensorflow installed even if you not using it as the backend. #28

Closed ricpruss closed 3 years ago

ricpruss commented 3 years ago

doing a:

import probflow as pf

raises:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-7-aa87442b1141> in <module>
      1 import torch
----> 2 import probflow as pf

~/github/probflow/src/probflow/__init__.py in <module>
----> 1 from probflow.applications import *
      2 from probflow.callbacks import *
      3 from probflow.data import *
      4 from probflow.distributions import *
      5 from probflow.models import *

~/github/probflow/src/probflow/applications/__init__.py in <module>
     22 
     23 
---> 24 from .dense_classifier import DenseClassifier
     25 from .dense_regression import DenseRegression
     26 from .linear_regression import LinearRegression

~/github/probflow/src/probflow/applications/dense_classifier.py in <module>
      3 import probflow.utils.ops as O
      4 from probflow.distributions import Categorical
----> 5 from probflow.models import CategoricalModel
      6 from probflow.modules import DenseNetwork
      7 from probflow.utils.casting import to_tensor

~/github/probflow/src/probflow/models/__init__.py in <module>
     23 
     24 
---> 25 from .categorical_model import CategoricalModel
     26 from .continuous_model import ContinuousModel
     27 from .discrete_model import DiscreteModel

~/github/probflow/src/probflow/models/categorical_model.py in <module>
      4 from probflow.utils.plotting import plot_categorical_dist
      5 
----> 6 from .model import Model
      7 
      8 

~/github/probflow/src/probflow/models/model.py in <module>
      7 import probflow.utils.ops as O
      8 from probflow.data import make_generator
----> 9 from probflow.modules import Module
     10 from probflow.utils.base import BaseCallback
     11 from probflow.utils.casting import to_numpy

~/github/probflow/src/probflow/modules/__init__.py in <module>
     28 
     29 
---> 30 from .batch_normalization import BatchNormalization
     31 from .dense import Dense
     32 from .dense_network import DenseNetwork

~/github/probflow/src/probflow/modules/batch_normalization.py in <module>
      3 import probflow.utils.ops as O
      4 from probflow.distributions import Deterministic, Normal
----> 5 from probflow.parameters import Parameter
      6 from probflow.utils.base import BaseDistribution
      7 from probflow.utils.initializers import xavier

~/github/probflow/src/probflow/parameters/__init__.py in <module>
     51 
     52 
---> 53 from .bounded_parameter import BoundedParameter
     54 from .categorical_parameter import CategoricalParameter
     55 from .deterministic_parameter import DeterministicParameter

~/github/probflow/src/probflow/parameters/bounded_parameter.py in <module>
      4 from probflow.utils.initializers import scale_xavier, xavier
      5 
----> 6 from .parameter import Parameter
      7 
      8 

~/github/probflow/src/probflow/parameters/parameter.py in <module>
     13 
     14 
---> 15 class Parameter(BaseParameter):
     16     r"""Probabilistic parameter(s).
     17 

~/github/probflow/src/probflow/parameters/parameter.py in Parameter()
     87         shape: Union[int, List[int]] = 1,
     88         posterior: Type[BaseDistribution] = Normal,
---> 89         prior: BaseDistribution = Normal(0, 1),
     90         transform: Callable = None,
     91         initializer: Dict[str, Callable] = {

~/github/probflow/src/probflow/distributions/normal.py in __init__(self, loc, scale)
     48 
     49         # Check input
---> 50         ensure_tensor_like(loc, "loc")
     51         ensure_tensor_like(scale, "scale")
     52 

~/github/probflow/src/probflow/utils/validation.py in ensure_tensor_like(obj, name)
     23         tensor_types = (torch.Tensor, BaseParameter)
     24     else:
---> 25         import tensorflow as tf
     26 
     27         tensor_types = (tf.Tensor, tf.Variable, BaseParameter)

ModuleNotFoundError: No module named 'tensorflow'

both from the pip version and a clone of this repo.

brendanhasz commented 3 years ago

Whoops, yep that's my bad for only testing in an env w/ Tensorflow. I'll get that fixed in a bit here. Thanks for pointing out the problem!

brendanhasz commented 3 years ago

Ok, this should work now! For both the latest pypi release, and the latest version of this repo. Feel free to reopen the issue or let me know if it doesn't.

ricpruss commented 3 years ago

Thanks Brendan and nice project, Ric

On Mon, 14 Dec 2020 at 10:57 am, Brendan Hasz notifications@github.com wrote:

Ok, this should work now! For both the latest pypi release, and the latest version of this repo. Feel free to reopen the issue or let me know if it doesn't.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/brendanhasz/probflow/issues/28#issuecomment-744105187, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAUZUQDEBWH7RVC4QKL5A3SUVPGJANCNFSM4TWPFY4Q .