InferPy: Deep Probabilistic Modeling with Tensorflow Made Easy

Overview
https://travis-ci.org/PGM-Lab/InferPy.svg?branch=master

docs/_static/img/logo.png

InferPy: Deep Probabilistic Modeling Made Easy

InferPy is a high-level API for probabilistic modeling written in Python and capable of running on top of Edward and Tensorflow. InferPy's API is strongly inspired by Keras and it has a focus on enabling flexible data processing, easy-to-code probablistic modeling, scalable inference and robust model validation.

Use InferPy is you need a probabilistic programming language that:

  • Allows easy and fast prototyping of hierarchical probabilistic models with a simple and user friendly API inspired by Keras.
  • Defines probabilistic models with complex probabilistic constructs containing deep neural networks.
  • Automatically creates computational efficient batched models without the need to deal with complex tensor operations.
  • Run seamlessly on CPU and GPU by relying on Tensorflow.

InferPy is to Edward what Keras is to Tensorflow

InferPy's aim is to be to Edward what Keras is to Tensorflow. Edward is a general purpose probabilistic programing language, like Tensorflow is a general computational engine. But this generality comes a at price. Edward's API is verbose and is based on distributions over Tensor objects, which are n-dimensional arrays with complex semantics operations. Probability distributions over Tensors are powerful abstractions but it is not easy to operate with them. InferPy's API is no so general like Edward's API but still covers a wide range of powerful and widely used probabilistic models, which can contain complex probability constructs containing deep neural networks.

Getting Started:

Installation

Install InferPy from PyPI:

$ python -m pip install inferpy

30 seconds to InferPy

The core data structures of InferPy is a probabilistic model, defined as a set of random variables with a conditional dependency structure. A random varible is an object parameterized by a set of tensors.

Let's look at a simple non-linear probabilistic component analysis model (NLPCA). Graphically the model can be defined as follows,

Non-linear PCA

Non-linear PCA

We start by importing the required packages and defining the constant parameters in the model.

import inferpy as inf
import tensorflow as tf

# number of components
k = 1
# size of the hidden layer in the NN
d0 = 100
# dimensionality of the data
dx = 2
# number of observations (dataset size)
N = 1000

A model can be defined by decorating any function with @inf.probmodel. The model is fully specified by the variables defined inside this function:

@inf.probmodel
def nlpca(k, d0, dx, decoder):

    with inf.datamodel():
        z = inf.Normal(tf.ones([k])*0.5, 1, name="z")    # shape = [N,k]
        output = decoder(z,d0,dx)
        x_loc = output[:,:dx]
        x_scale = tf.nn.softmax(output[:,dx:])
        x = inf.Normal(x_loc, x_scale, name="x")   # shape = [N,d]

The construct with inf.datamodel(), which resembles to the plateau notation, will replicate N times the variables enclosed, where N is the size of our data.

In the previous model, the input argument decoder must be a function implementing a neural network. This might be defined outside the model as follows.

def decoder(z,d0,dx):
    h0 = tf.layers.dense(z, d0, tf.nn.relu)
    return tf.layers.dense(h0, 2 * dx)

Now, we can instantiate our model and obtain samples (from the prior distributions).

# create an instance of the model
m = nlpca(k,d0,dx, decoder)

# Sample from priors
samples = m.prior().sample()

In variational inference, we must defined a Q-model as follows.

@inf.probmodel
def qmodel(k):
    with inf.datamodel():
        qz_loc = inf.Parameter(tf.ones([k])*0.5, name="qz_loc")
        qz_scale = tf.math.softplus(inf.Parameter(tf.ones([k]),name="qz_scale"))

        qz = inf.Normal(qz_loc, qz_scale, name="z")

Afterwards, we define the parameters of our inference algorithm and fit the data to the model.

# set the inference algorithm
VI = inf.inference.VI(qmodel(k), epochs=5000)

# learn the parameters
m.fit({"x": x_train}, VI)

The inference method can be further configured. But, as in Keras, a core principle is to try make things reasonably simple, while allowing the user the full control if needed.

Finally, we might extract the posterior of z, which is basically the hidden representation of our data.

#extract the hidden representation
hidden_encoding = m.posterior("z", data={"x":x_train})
print(hidden_encoding.sample())
Comments
  • Pip install system and other modules fail

    Pip install system and other modules fail

    Windows 10. pip 20.2 Python 3.8.2 Hello. I have been trying to install some packages like pyautogui, pyinstaller, system but I have the same error. I have uploaded many packages before and now I couldn't find the solution. Could you please help me figure out ?

    ERROR: Could not find a version that satisfies the requirement system (from versions: none)
    ERROR: No matching distribution found for system
    
    DEPRECATION: The -b/--build/--build-dir/--build-directory option is deprecated. pip 20.3 will remove support for this functionality. A possible replacement is use the TMPDIR/TEMP/TMP environment variable, possibly combined with --no-clean. You can find discussion regarding this at https://github.com/pypa/pip/issues/8333.
    ERROR: Could not find a version that satisfies the requirement system (from versions: none)
    ERROR: No matching distribution found for system
    
    opened by recepbalibey 8
  • Two issues using VAE with multiple inputs

    Two issues using VAE with multiple inputs

    I'm trying to implement a VAE with two input vectors rather than one. The purpose is to be able to sample the first vector conditional on known values of the second. My first attempt was the following:

    @inf.probmodel
    def vae(k, d0, dx, dy, decoderx, decodery):
        with inf.datamodel():
            z = inf.Normal(tf.ones(k), 1,name="z")
            x = inf.Normal(decoderx(z, d0, dx), 1, name="x")
            y = inf.Deterministic(decodery(z, d0, dy), name="y")
    
    # Neural networks for decoding and encoding
    def decoderx(z, d0, dx):
        h0 = tf.keras.layers.Dense(d0, activation=tf.nn.relu)
        h1 = tf.keras.layers.Dense(dx)
        return h1(h0(z))
    
    def decodery(z, d0, dy):
        h0 = tf.keras.layers.Dense(d0, activation=tf.nn.relu)
        h1 = tf.keras.layers.Dense(dy)
        return h1(h0(z))
    
    def encoder(x, y, d0, k):
        hm = tf.keras.layers.Concatenate(axis=1)
        h0 = tf.keras.layers.Dense(d0, activation=tf.nn.relu)
        h1 = tf.keras.layers.Dense(2*k)
        return h1(h0(hm([x, y])))
    
    # Q model for making inference
    @inf.probmodel
    def qmodel(k, d0, dx, dy, encoder):
        with inf.datamodel():
            x = inf.Normal(tf.ones(dx), 1, name="x")
            y = inf.Normal(tf.ones(dy), 1, name="y")
            print((x.shape, y.shape))
            output = encoder(x, y, d0, k)
            qz_loc = output[:, :k]
            qz_scale = tf.nn.softplus(output[:, k:]) + scale_epsilon
            qz = inf.Normal(qz_loc, qz_scale, name="z")
    
    k = 3
    d0 = 50
    dx = 4
    dy = 2
    scale_epsilon = 1e-6
    
    m = vae(k, d0, dx, dy, decoderx, decodery)
    sample = m.prior().sample(1000)
    
    q = qmodel(k, d0, dx, dy, encoder)
    m.fit(sample, inf.inference.VI(q, epochs=10000))
    

    This generates the following error:

    (TensorShape([Dimension(1), Dimension(4)]), TensorShape([Dimension(1), Dimension(2)]))
    (TensorShape([Dimension(1), Dimension(4)]), TensorShape([Dimension(2)]))
    ---------------------------------------------------------------------------
    IndexError                                Traceback (most recent call last)
    <ipython-input-15-48f880cfb1cd> in <module>()
    ----> 1 q = qmodel(k, d0, dx, dy, encoder)
          2 
          3 m.fit(sample, inf.inference.VI(q, epochs=10000))
    
    ...
    
    /home/wkp/.conda/envs/WKPenv/lib/python3.6/site-packages/tensorflow_core/python/keras/layers/merge.py in build(self, input_shape)
        383     shape_set = set()
        384     for i in range(len(reduced_inputs_shapes)):
    --> 385       del reduced_inputs_shapes[i][self.axis]
        386       shape_set.add(tuple(reduced_inputs_shapes[i]))
        387     if len(shape_set) > 1:
    
    IndexError: list assignment index out of range
    

    I can eliminate the error by reshaping y in the encoder function:

    output = encoder(x, tf.reshape(y, (x.shape[0], y.shape[-1])), d0, k)
    

    However, I then get the following error:

    ---------------------------------------------------------------------------
    InvalidArgumentError                      Traceback (most recent call last)
    /home/wkp/.conda/envs/WKPenv/lib/python3.6/site-packages/tensorflow_core/python/framework/ops.py in _create_c_op(graph, node_def, inputs, control_inputs)
       1606   try:
    -> 1607     c_op = c_api.TF_FinishOperation(op_desc)
       1608   except errors.InvalidArgumentError as e:
    
    ...
    
    ValueError: Cannot reshape a tensor with 2 elements to shape [1000,2] (2000 elements) for 'Reshape_1' (op: 'Reshape') with input shapes: [2], [2] and with input tensors computed as partial shapes: input[1] = [1000,2].
    

    I get the same error when I try SVI, unless I specify batch_size=1 , in which case it works.

    bug 
    opened by doctorwes 6
  • pip fails on install

    pip fails on install

    pip install inferpy Collecting inferpy Using cached inferpy-1.3.1.tar.gz (1.6 MB) ERROR: Could not find a version that satisfies the requirement tensorflow<2.0,>=1.12.1 (from inferpy) (from versions: 2.2.0rc1, 2.2.0rc2, 2.2.0rc3, 2.2.0rc4, 2.2.0, 2.3.0rc0) ERROR: No matching distribution found for tensorflow<2.0,>=1.12.1 (from inferpy)

    The result is the same adding to a clean poetry environment.

    opened by kasper-thofte 3
  • The documentation is full of typos and the references are not working

    The documentation is full of typos and the references are not working

    I was reading the documentation for InferPy. It is full of typos and the references are not working properly. For example, in https://inferpy.readthedocs.io/en/0.0.3/notes/guideinference.html, you write "infererence" rather than "inference". You also write "Look at ? for a detailed description of the available inference algorithms". This is not the only page of the documentation that contains typos.

    opened by nbro 3
  • No supported kernel for GPU devices is available.

    No supported kernel for GPU devices is available.

    I'm having trouble with running the Bayesian Linear Regression example as below on my GPUs. Two NVidia GeForce 1080Ti are available.

    Contained installation in tensorflow docker (tensorflow:1.14.0-gpu-py3-jupyter). Then installed inferpy by

    pip install inferpy[all]

    Then I had to downgrade the tensorflow-probability package from 0.8.0 to 0.7.0 (known bug). First, the script showed no GPUs available. Then I did:

    pip uninstall tensorflow pip install tensorflow-gpu

    The GPUs are now visible as shown by the prints, but inferpy still gives the same error.

    ` import inferpy as inf import tensorflow as tf import numpy as np

    @inf.probmodel
    def linear_reg(d):
        w0 = inf.Normal(0, 1, name="w0")
        w = inf.Normal(np.zeros([d, 1]), 1, name="w")
    
        with inf.datamodel():
    	x = inf.Normal(tf.ones(d), 2, name="x")
    	y = inf.Normal(w0 + x @ w, 1.0, name="y")
    
    
    @inf.probmodel
    def qmodel(d):
        qw0_loc = inf.Parameter(0., name="qw0_loc")
        qw0_scale = tf.math.softplus(inf.Parameter(1., name="qw0_scale"))
        qw0 = inf.Normal(qw0_loc, qw0_scale, name="w0")
    
        qw_loc = inf.Parameter(np.zeros([d, 1]), name="qw_loc")
        qw_scale = tf.math.softplus(inf.Parameter(tf.ones([d, 1]), name="qw_scale"))
        qw = inf.Normal(qw_loc, qw_scale, name="w")
    
    print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))
    print("GPU(s) available", tf.test.is_gpu_available())
    
    with tf.device('/device:GPU:1'):
        # create an instance of the model
        m = linear_reg(d=2)
        q = qmodel(2)
        # create toy data
        N = 1000
        data = m.prior(["x", "y"], data={"w0": 0, "w": [[2], [1]]}, size_datamodel=N).sample()
    
        x_train = data["x"]
        y_train = data["y"]
    
        # set and run the inference
        VI = inf.inference.VI(qmodel(2), epochs=10000)
        m.fit({"x": x_train, "y": y_train}, VI)
    
    
        # extract the parameters of the posterior
        m.posterior(["w", "w0"]).parameters()
    

    ` Num GPUs Available: 2 WARNING: Logging before flag parsing goes to stderr. W1008 15:36:36.023126 139756946933568 deprecation_wrapper.py:119] From /usr/local/lib/python3.6/dist-packages/inferpy/models/prob_model.py:63: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.

    W1008 15:36:36.042158 139756946933568 deprecation_wrapper.py:119] From /usr/local/lib/python3.6/dist-packages/inferpy/models/random_variable.py:425: The name tf.variables_initializer is deprecated. Please use tf.compat.v1.variables_initializer instead.
    
    GPU(s) available True
    W1008 15:36:36.610001 139756946933568 deprecation_wrapper.py:119] From /usr/local/lib/python3.6/dist-packages/inferpy/util/tf_graph.py:63: The name tf.get_default_graph is deprecated. Please use tf.compat.v1.get_default_graph instead.
    
    W1008 15:36:36.731642 139756946933568 deprecation_wrapper.py:119] From /usr/local/lib/python3.6/dist-packages/inferpy/models/prob_model.py:136: The name tf.global_variables is deprecated. Please use tf.compat.v1.global_variables instead.
    
    ---------------------------------------------------------------------------
    InvalidArgumentError                      Traceback (most recent call last)
    /usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py in _do_call(self, fn, *args)
       1355     try:
    -> 1356       return fn(*args)
       1357     except errors.OpError as e:
    
    /usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py in _run_fn(feed_dict, fetch_list, target_list, options, run_metadata)
       1338       # Ensure any changes to the graph are reflected in the runtime.
    -> 1339       self._extend_graph()
       1340       return self._call_tf_sessionrun(
    
    /usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py in _extend_graph(self)
       1373     with self._graph._session_run_lock():  # pylint: disable=protected-access
    -> 1374       tf_session.ExtendSession(self._session)
       1375 
    
    InvalidArgumentError: Cannot assign a device for operation inferpy-predict-enabled-w0: Could not satisfy explicit device specification '/device:GPU:1' because no supported kernel for GPU devices is available.
    Colocation Debug Info:
    Colocation group had the following types and supported devices: 
    Root Member(assigned_device_name_index_=-1 requested_device_name_='/device:GPU:1' assigned_device_name_='' resource_device_name_='/device:GPU:1' supported_device_types_=[CPU] possible_devices_=[]
    Assign: GPU CPU 
    Identity: GPU CPU XLA_CPU XLA_GPU 
    VariableV2: CPU 
    
    Colocation members, user-requested devices, and framework assigned devices, if any:
      inferpy-predict-enabled-w0 (VariableV2) /device:GPU:1
      inferpy-predict-enabled-w0/Assign (Assign) /device:GPU:1
      inferpy-predict-enabled-w0/read (Identity) /device:GPU:1
    
    Op: VariableV2
    Node attrs: shape=[], shared_name="", dtype=DT_BOOL, container=""
    Registered kernels:
      device='GPU'; dtype in [DT_INT64]
      device='GPU'; dtype in [DT_DOUBLE]
      device='GPU'; dtype in [DT_FLOAT]
      device='GPU'; dtype in [DT_HALF]
      device='CPU'
    
    	 [[{{node inferpy-predict-enabled-w0}}]]
    
    During handling of the above exception, another exception occurred:
    
    InvalidArgumentError                      Traceback (most recent call last)
    <ipython-input-1-f66d6dab9fcd> in <module>
         28 with tf.device('/device:GPU:1'):
         29     # create an instance of the model
    ---> 30     m = linear_reg(d=2)
         31     q = qmodel(2)
         32     # create toy data
    
    /usr/local/lib/python3.6/dist-packages/inferpy/models/prob_model.py in wrapper(*args, **kwargs)
         42             return builder(*args, **kwargs)
         43         return ProbModel(
    ---> 44             builder=fn
         45         )
         46     return wrapper
    
    /usr/local/lib/python3.6/dist-packages/inferpy/models/prob_model.py in __init__(self, builder)
         70 
         71         # Now initialize vars and params for the model (no sample_shape)
    ---> 72         self.vars, self.params = self._build_model()
         73 
         74         # This attribute contains the inference method used. If it is None, the `fit` function has not been used yet
    
    /usr/local/lib/python3.6/dist-packages/inferpy/models/prob_model.py in _build_model(self)
        139             # use edward2 model tape to capture RandomVariable declarations
        140             with ed.tape() as model_tape:
    --> 141                 self.builder()
        142 
        143             # get variables from parameters
    
    /usr/local/lib/python3.6/dist-packages/inferpy/util/runtime.py in wrapper(*args, **kwargs)
         84         with runner_scope():
         85             # now execute the function and return the result
    ---> 86             return f(*args, **kwargs)
         87 
         88     return wrapper
    
    /usr/local/lib/python3.6/dist-packages/inferpy/models/prob_model.py in fn()
         40         @util.tf_run_ignored
         41         def fn():
    ---> 42             return builder(*args, **kwargs)
         43         return ProbModel(
         44             builder=fn
    
    <ipython-input-1-f66d6dab9fcd> in linear_reg(d)
          5 @inf.probmodel
          6 def linear_reg(d):
    ----> 7     w0 = inf.Normal(0, 1, name="w0")
          8     w = inf.Normal(np.zeros([d, 1]), 1, name="w")
          9 
    
    /usr/local/lib/python3.6/dist-packages/inferpy/models/random_variable.py in func(*args, **kwargs)
        373 
        374             # build the respective boolean and tf.Variables
    --> 375             is_observed, observed_value = _make_predictable_variables(initial_value, rv_name)
        376 
        377             # use this context to intercept the value using the tf.cond dependent on the previous tf.Variables
    
    /usr/local/lib/python3.6/dist-packages/inferpy/models/random_variable.py in _make_predictable_variables(initial_value, rv_name)
        423                                  name="inferpy-predict-{name}".format(name=rv_name or "default"))
        424 
    --> 425     util.session.get_session().run(tf.variables_initializer([is_observed, observed_value]))
        426 
        427     return is_observed, observed_value
    
    /usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py in run(self, fetches, feed_dict, options, run_metadata)
        948     try:
        949       result = self._run(None, fetches, feed_dict, options_ptr,
    --> 950                          run_metadata_ptr)
        951       if run_metadata:
        952         proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)
    
    /usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
       1171     if final_fetches or final_targets or (handle and feed_dict_tensor):
       1172       results = self._do_run(handle, final_targets, final_fetches,
    -> 1173                              feed_dict_tensor, options, run_metadata)
       1174     else:
       1175       results = []
    
    /usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py in _do_run(self, handle, target_list, fetch_list, feed_dict, options, run_metadata)
       1348     if handle is None:
       1349       return self._do_call(_run_fn, feeds, fetches, targets, options,
    -> 1350                            run_metadata)
       1351     else:
       1352       return self._do_call(_prun_fn, handle, feeds, fetches)
    
    /usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py in _do_call(self, fn, *args)
       1368           pass
       1369       message = error_interpolation.interpolate(message, self._graph)
    -> 1370       raise type(e)(node_def, op, message)
       1371 
       1372   def _extend_graph(self):
    
    InvalidArgumentError: Cannot assign a device for operation inferpy-predict-enabled-w0: Could not satisfy explicit device specification '/device:GPU:1' because no supported kernel for GPU devices is available.
    Colocation Debug Info:
    Colocation group had the following types and supported devices: 
    Root Member(assigned_device_name_index_=-1 requested_device_name_='/device:GPU:1' assigned_device_name_='' resource_device_name_='/device:GPU:1' supported_device_types_=[CPU] possible_devices_=[]
    Assign: GPU CPU 
    Identity: GPU CPU XLA_CPU XLA_GPU 
    VariableV2: CPU 
    
    Colocation members, user-requested devices, and framework assigned devices, if any:
      inferpy-predict-enabled-w0 (VariableV2) /device:GPU:1
      inferpy-predict-enabled-w0/Assign (Assign) /device:GPU:1
      inferpy-predict-enabled-w0/read (Identity) /device:GPU:1
    
    Op: VariableV2
    Node attrs: shape=[], shared_name="", dtype=DT_BOOL, container=""
    Registered kernels:
      device='GPU'; dtype in [DT_INT64]
      device='GPU'; dtype in [DT_DOUBLE]
      device='GPU'; dtype in [DT_FLOAT]
      device='GPU'; dtype in [DT_HALF]
      device='CPU'
    
    	 [[node inferpy-predict-enabled-w0 (defined at /usr/local/lib/python3.6/dist-packages/inferpy/models/random_variable.py:420) ]]
    
    Original stack trace for 'inferpy-predict-enabled-w0':
      File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
        "__main__", mod_spec)
      File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
        exec(code, run_globals)
      File "/usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py", line 16, in <module>
        app.launch_new_instance()
      File "/usr/local/lib/python3.6/dist-packages/traitlets/config/application.py", line 658, in launch_instance
        app.start()
      File "/usr/local/lib/python3.6/dist-packages/ipykernel/kernelapp.py", line 505, in start
        self.io_loop.start()
      File "/usr/local/lib/python3.6/dist-packages/tornado/platform/asyncio.py", line 148, in start
        self.asyncio_loop.run_forever()
      File "/usr/lib/python3.6/asyncio/base_events.py", line 438, in run_forever
        self._run_once()
      File "/usr/lib/python3.6/asyncio/base_events.py", line 1451, in _run_once
        handle._run()
      File "/usr/lib/python3.6/asyncio/events.py", line 145, in _run
        self._callback(*self._args)
      File "/usr/local/lib/python3.6/dist-packages/tornado/ioloop.py", line 690, in <lambda>
        lambda f: self._run_callback(functools.partial(callback, future))
      File "/usr/local/lib/python3.6/dist-packages/tornado/ioloop.py", line 743, in _run_callback
        ret = callback()
      File "/usr/local/lib/python3.6/dist-packages/tornado/gen.py", line 781, in inner
        self.run()
      File "/usr/local/lib/python3.6/dist-packages/tornado/gen.py", line 742, in run
        yielded = self.gen.send(value)
      File "/usr/local/lib/python3.6/dist-packages/ipykernel/kernelbase.py", line 365, in process_one
        yield gen.maybe_future(dispatch(*args))
      File "/usr/local/lib/python3.6/dist-packages/tornado/gen.py", line 209, in wrapper
        yielded = next(result)
      File "/usr/local/lib/python3.6/dist-packages/ipykernel/kernelbase.py", line 272, in dispatch_shell
        yield gen.maybe_future(handler(stream, idents, msg))
      File "/usr/local/lib/python3.6/dist-packages/tornado/gen.py", line 209, in wrapper
        yielded = next(result)
      File "/usr/local/lib/python3.6/dist-packages/ipykernel/kernelbase.py", line 542, in execute_request
        user_expressions, allow_stdin,
      File "/usr/local/lib/python3.6/dist-packages/tornado/gen.py", line 209, in wrapper
        yielded = next(result)
      File "/usr/local/lib/python3.6/dist-packages/ipykernel/ipkernel.py", line 294, in do_execute
        res = shell.run_cell(code, store_history=store_history, silent=silent)
      File "/usr/local/lib/python3.6/dist-packages/ipykernel/zmqshell.py", line 536, in run_cell
        return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
      File "/usr/local/lib/python3.6/dist-packages/IPython/core/interactiveshell.py", line 2848, in run_cell
        raw_cell, store_history, silent, shell_futures)
      File "/usr/local/lib/python3.6/dist-packages/IPython/core/interactiveshell.py", line 2874, in _run_cell
        return runner(coro)
      File "/usr/local/lib/python3.6/dist-packages/IPython/core/async_helpers.py", line 67, in _pseudo_sync_runner
        coro.send(None)
      File "/usr/local/lib/python3.6/dist-packages/IPython/core/interactiveshell.py", line 3049, in run_cell_async
        interactivity=interactivity, compiler=compiler, result=result)
      File "/usr/local/lib/python3.6/dist-packages/IPython/core/interactiveshell.py", line 3214, in run_ast_nodes
        if (yield from self.run_code(code, result)):
      File "/usr/local/lib/python3.6/dist-packages/IPython/core/interactiveshell.py", line 3296, in run_code
        exec(code_obj, self.user_global_ns, self.user_ns)
      File "<ipython-input-1-f66d6dab9fcd>", line 30, in <module>
        m = linear_reg(d=2)
      File "/usr/local/lib/python3.6/dist-packages/inferpy/models/prob_model.py", line 44, in wrapper
        builder=fn
      File "/usr/local/lib/python3.6/dist-packages/inferpy/models/prob_model.py", line 72, in __init__
        self.vars, self.params = self._build_model()
      File "/usr/local/lib/python3.6/dist-packages/inferpy/models/prob_model.py", line 141, in _build_model
        self.builder()
      File "/usr/local/lib/python3.6/dist-packages/inferpy/util/runtime.py", line 86, in wrapper
        return f(*args, **kwargs)
      File "/usr/local/lib/python3.6/dist-packages/inferpy/models/prob_model.py", line 42, in fn
        return builder(*args, **kwargs)
      File "<ipython-input-1-f66d6dab9fcd>", line 7, in linear_reg
        w0 = inf.Normal(0, 1, name="w0")
      File "/usr/local/lib/python3.6/dist-packages/inferpy/models/random_variable.py", line 375, in func
        is_observed, observed_value = _make_predictable_variables(initial_value, rv_name)
      File "/usr/local/lib/python3.6/dist-packages/inferpy/models/random_variable.py", line 420, in _make_predictable_variables
        name="inferpy-predict-enabled-{name}".format(name=rv_name or "default"))
      File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/variables.py", line 259, in __call__
        return cls._variable_v1_call(*args, **kwargs)
      File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/variables.py", line 220, in _variable_v1_call
        shape=shape)
      File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/variables.py", line 198, in <lambda>
        previous_getter = lambda **kwargs: default_variable_creator(None, **kwargs)
      File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/variable_scope.py", line 2511, in default_variable_creator
        shape=shape)
      File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/variables.py", line 263, in __call__
        return super(VariableMetaclass, cls).__call__(*args, **kwargs)
      File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/variables.py", line 1568, in __init__
        shape=shape)
      File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/variables.py", line 1728, in _init_from_args
        name=name)
      File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/state_ops.py", line 79, in variable_op_v2
        shared_name=shared_name)
      File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/gen_state_ops.py", line 1609, in variable_v2
        shared_name=shared_name, name=name)
      File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/op_def_library.py", line 788, in _apply_op_helper
        op_def=op_def)
      File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/util/deprecation.py", line 507, in new_func
        return func(*args, **kwargs)
      File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py", line 3616, in create_op
        op_def=op_def)
      File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py", line 2005, in __init__
        self._traceback = tf_stack.extract_stack()`
    
    opened by rubenverhack 3
  • Multinomial batch shape

    Multinomial batch shape

    Batch shape is not set properly in Multinomial. This might affect to others with complex parameters or with event shep

    x = inf.Multinomial(total_count = 2, logits = [0., 0., 0.])
    
    x.event_shape   # 3
    x.batch_shape   # 3     (should be 1)
    x.sample_shape  # [] 
    
    bug 
    opened by rcabanasdepaz 3
  • Design prob model fit function

    Design prob model fit function

    The fit function should accept a set of N instances, each one containing samples from some random variables inside the data model.

    It should create a context to allow using other functions, like #118 , inside the context which will work with the expanded model (using N as plate size) and intercepting the values for the input samples.

    important enhancement desing 
    opened by jcozar87 3
  • sample_shape in non extended model

    sample_shape in non extended model

    Which should be the default sample_shape in the non-extended model? 1 or empytset?

    @models.probmodel
    def model():
        with models.datamodel():
            x = models.Normal(np.zeros([2,4], np.float32), 1., name='x')
    

    x.shape == [1,2,4] or x.shape == [2,4]. If we consider that the sample_shape is at least 1, any variable inside a data model will always have a shape of [N,....]. We assume that in the non-expanded model N==1.

    question 
    opened by rcabanasdepaz 3
  • bug - Poisson distribution - Fetch argument None has invalid type <class 'NoneType'>

    bug - Poisson distribution - Fetch argument None has invalid type

    Platform : Python 3.6.5 X64 on macOS Mojave 10.14.3 Associated Libraries: TensorFlow 1.7.1 , Numpy 1.14.3 Inferpy version: 0.2.1


    Upon running

    inferpy.models.Poisson(2).sample(2) This error trace is produced image

    bug 
    opened by parsa-asgari 3
  • Code cleanup

    Code cleanup

    As a revision process to understand inferPy, I will documentate each modification, typo, or improvement here. It is just for minor modifications or typos, not for functional change.

    enhancement re-code documentation 
    opened by jcozar87 3
  • Hey!

    Hey!

    How you doing? First, very cool program! This might be an issue, and it might be me not fully understanding TensorFlow or MDN. I used your MDN example on multidimensional data, and it works as I hoped in almost every single way. The thing I didnt figure out is that I had to send in equal amount of test data to posterior_predictive as I am sending in training data to VI.fit. I am thought I should use around 50-70 % of the data for traning, then split the rest between test and validation test, and I can't figure out how to do that. Is it something with the posterior_predictive function I could do to make this work as I want? The code is below and should be easy to copy paste to check it out

    Also is there a way to prevent overfitting and underfitting with somehow including the test set in VI.fit and breaking out at a reasonable place?

    
    
    from __future__ import absolute_import
    from __future__ import division
    from __future__ import print_function
    
    
    
    import numpy as np
    import matplotlib.pyplot as plt
    import seaborn as sns
    from mpl_toolkits import mplot3d
    from sklearn.model_selection import train_test_split
    from numpy.random import normal
    from sklearn.metrics import confusion_matrix
    import tensorflow as tf
    import inferpy as inf
    
    
    
    n_points = 750    # number of datapoints
    n_cat = 4   # number of categories
    noise = 0.1     # determine noise to add to the dataset
    
    
    
    
    def toy_data_set(categories, noise, N):
        # A dataset that in someplaces are impossible to seperate to different categories
        # (depending on the noise), making it ideal to test out bayesian inference. It is better 
        # to see the plot below than me explaining what is happening in this fuction
    
        theta = np.arange(0, np.pi, np.pi/(N+1))[:N]
        a = 1
        b = .1
    
        X = np.zeros((N*categories, 3))
        cat = []
        catnr = 0
        k = 0
    
        for dt in np.arange(0, ((categories-1)*2) + 0.1, 2):
    
            if k % 2 == 0:
                number = -1
            else:
                number = 1
    
            s1 = normal(loc = 0, scale = noise, size= N)
            s2 = normal(loc = 0, scale = noise, size= N)
            s3 = normal(loc = 0, scale = noise/2, size= N)
            x = a*np.cos(theta + dt)*np.exp(b*theta) + s1 
            y = a*np.sin(theta + dt)*np.exp(b*theta) + s2
            z = np.exp(np.linspace(1, 2, N)[::-1])
            z = (((z - np.min(z))/np.max(z)) * number) + s3
    
            X[N*k:N*(k+1), 0], X[N*k:N*(k+1), 1], X[N*k:N*(k+1), 2] = x, y, z
            cat.append(np.zeros(len(x)) + catnr)
            catnr += 1
            k += 1
    
        X = X / X.max(axis=0)
        y = np.concatenate(cat)
        return(X,y)
    
    

    Getting the data and splitting it 50/50, and this is what I need help with. Anything else than 50/50 split is not working with the posterior_predictive fuction

    X, y = toy_data_set(categories = n_cat, noise = noise, N = n_points)
    x_train, x_test, y_train, y_test = train_test_split(X, y, test_size=.5)
    
    
    
    
    
    def plot(X, y):
        """ Plot as a function, so we can easily skip it if we want """
    
        fig = plt.figure()
        ax = plt.axes(projection='3d')
        for k in np.unique(y):
          index_cat_n = np.where(y == k)[0]
          ax.scatter3D(X[index_cat_n,0], X[index_cat_n,1], X[index_cat_n,2])
        ax.set_title('Example with 4 categories');
        plt.show()
    
    
    
    
    
    plot(X, y)
    
    
    

    dataset

    
    
    
    D = 3    # number of features, which is equal to np.shape(X)[1]
    K = 20    # number of mixture components
    
    # Copy paste from MDN example
    
    def neural_network(X):
        """loc, scale, logits = NN(x; theta)"""
        # 2 hidden layers with 200 hidden units
        net = tf.keras.layers.Dense(200, activation=tf.nn.relu)(X)
        net = tf.keras.layers.Dense(200, activation=tf.nn.relu)(net)
        locs = tf.keras.layers.Dense(K, activation=None)(net)
        scales = tf.keras.layers.Dense(K, activation=tf.exp)(net)
        logits = tf.keras.layers.Dense(K, activation=None)(net)
        return locs, scales, logits
    
    
    @inf.probmodel
    def mdn():
        with inf.datamodel():
            x = inf.Normal(loc = tf.ones([D]), scale = 1.0, name="x")
            locs, scales, logits = neural_network(x)
            y = inf.MixtureGaussian(locs, scales, logits=logits, name="y")
    
    m = mdn()
    
    
    @inf.probmodel
    def qmodel():
            return;
    
    VI = inf.inference.VI(qmodel(), epochs=1500)
    m.fit({"y": y_train, "x":x_train}, VI)
    
    
    y_pred_list = []
    for i in range(1000):
        y_test_pred = m.posterior_predictive(["y"], data = {"x": x_test}).sample()
        y_pred_list.append(y_test_pred)
    
    # In pymc3 they seem to discard the n-first samples. You know why?
    
    y_mean = np.mean(y_pred_list, axis=0)
    y_sigma = np.std(y_pred_list, axis=0)
    
    y_pred = np.rint(y_mean).astype(int)
    
    
    print("\n Test accuracy : ", np.sum(y_pred == y_test)/len(y_pred))
    
    
    # This is just a quick use of the bayesian part of the network, 
    # removing 1/2 of the points with the highest standard deviation
    remove_indexes = y_sigma.argsort()[-int(len(y_sigma)/2):][::-1]
    y_pred = np.delete(y_pred, remove_indexes)
    y_test = np.delete(y_test, remove_indexes)
    
    
    # print(np.sum(y_pred == y_test))
    print(" Test accuracy after removing high std: ", np.sum(y_pred == y_test)/len(y_pred))
    
    sns.heatmap(confusion_matrix(y_test, y_pred))
    plt.show()
    
    

    snsheat

    Alright so hope this was readable and just ask if something was unclear. I am reading the great blog you linked too to understand MDN better (http://cbonnett.github.io/MDN.html)

    opened by FredrikNM 2
  • Poisson Matrix Factorization

    Poisson Matrix Factorization

    Hi,

    First of all, thank you so much for inferpy. Its an wonderful project. I am trying to implement Poisson Matrix factorization using this library. I first implemented the basic Matrix factorization using the example given in the older version of inferpy. The relevant part of the code is as follows : `

    # definition of a generic model
    @inf.probmodel
    def mf(M, K):
    	w_Item = inf.Normal(loc=tf.zeros([M, K]), scale=1, name="wItem") 
    	
    	with inf.datamodel():
    		w_User = inf.Normal(tf.ones(K), scale=1, name="wUser") 
    		Rating = inf.Normal(tf.matmul(w_User, w_Item, transpose_b = True), 1, name="Rating") 
    	   
    #In variational inference - define Q-model 
    @inf.probmodel
    def qmodel(M, K):
    	qw_Item_loc = inf.Parameter(tf.zeros([M, K]), name="qw_Item_loc")
    	qw_Item_scale = tf.math.softplus(inf.Parameter(tf.ones([M, K]),  name="qw_Item_scale"))
    	qw_Item = inf.Normal(qw_Item_loc, qw_Item_scale, name="wItem")
    	
    	with inf.datamodel():
    		qw_Userloc = inf.Parameter(np.ones(K), name="qw_Userloc")
    		qw_Userscale = tf.math.softplus(inf.Parameter(tf.ones(K), name="qw_Userscale"))
    		qw = inf.Normal(qw_Userloc, qw_Userscale, name="wUser")`
    

    This code seems to work ... so I modified the code for Poisson factorization as follows:

    `

    # definition of a generic model
    @inf.probmodel
    def mf(M, K):
    	w_Item = inf.Normal(loc=tf.zeros([M, K]), scale=1, name="wItem") # shape = [M,K]
    
    	with inf.datamodel():
    		w_User = inf.Normal(tf.ones(K), scale=1, name="wUser") # shape = [N,K]
    		Rating = inf.Poisson(tf.math.exp(w_User) @  tf.transpose(tf.math.exp(w_Item)), name="Rating")
    	   
    #In variational inference - define Q-model 
    @inf.probmodel
    def qmodel(M, K):
    	qw_Item_loc = inf.Parameter(tf.zeros([M, K]), name="qw_Item_loc")
    	qw_Item_scale = tf.math.softplus(inf.Parameter(tf.ones([M, K]),  name="qw_Item_scale"))
    	qw_Item = inf.Normal(qw_Item_loc, qw_Item_scale, name="wItem")
    	
    	with inf.datamodel():
    		qw_Userloc = inf.Parameter(np.ones(K), name="qw_Userloc")
    		qw_Userscale = tf.math.softplus(inf.Parameter(tf.ones(K), name="qw_Userscale"))
    		qw = inf.Normal(qw_Userloc, qw_Userscale, name="wUser")`
    

    Unfortunately it gives the following error ... LookupError: No gradient defined for operation 'Rating_46/sample/random_poisson/RandomPoissonV2' (op type: RandomPoissonV2)

    I tried to find some examples using Poisson distribution but could not find any ...where am I going wrong ? Kindly help ...

    opened by sommukh 0
  • Make inferpy compatible with TPF>0.7.0

    Make inferpy compatible with TPF>0.7.0

    Inferpy is compatible with tensorflow-probability (TFP) up to the version 0.7.0 (included). After this, some spacenames in TFP were changed making incompatible with previous versions.

    bug important enhancement 
    opened by rcabanasdepaz 0
  • Wrong sample_shape when name is given

    Wrong sample_shape when name is given

    Wrong sample_shape when name is given and using size in the data model

    import inferpy as inf
    import tensorflow as tf
    
    with inf.datamodel(size=100):
        x = inf.Normal(tf.ones(4), 1, name="x")
    
    x.sample_shape  # []
    
    with inf.datamodel(size=100):
        x = inf.Normal(tf.ones(4), 1)
        
        
    x.sample_shape  # [100]
    
    bug 
    opened by rcabanasdepaz 0
  • Support for convolutional neural network

    Support for convolutional neural network

    Hi, This library is very convenient. Does this library support convolutional neural networks, such as tfp.layers.Convolution2DFlipout?

    nnetwork = inf.layers.Sequential([ tfp.layers.Convolution2DFlipout(.....), tf.keras.layers.BatchNormalization(), tf.keras.layers.Activation('relu'), tf.keras.layers.MaxPooling2D(......), tf.keras.layers.Flatten(), tfp.layers.DenseFlipout(......), tfp.layers.DenseFlipout(........) ])

    opened by JonvoWoo 1
  • Sorry for asking this here

    Sorry for asking this here

    I am trying to implement the Rasch Model with the dataset below, I am quite confused at the moment of how to implement this. Could anyone give me a slight nudge in which direction to take this?

    Capture

    opened by airflow0 2
  • Error using MCMC

    Error using MCMC

    I am using the same model as in #195 (closed; thank you!), but attempting to use MCMC rather than VI.

    (Note that I can successfully run the sample notebook MCMC-logregression.ipynb)

    MC = inf.inference.MCMC(num_results=1000)
    m.fit({"x": data}, MC)
    

    I get the following error:

    ---------------------------------------------------------------------------
    FailedPreconditionError                   Traceback (most recent call last)
    /home/wkp/.conda/envs/WKPenv/lib/python3.6/site-packages/tensorflow/python/client/session.py in _do_call(self, fn, *args)
       1355     try:
    -> 1356       return fn(*args)
       1357     except errors.OpError as e:
    
    /home/wkp/.conda/envs/WKPenv/lib/python3.6/site-packages/tensorflow/python/client/session.py in _run_fn(feed_dict, fetch_list, target_list, options, run_metadata)
       1340       return self._call_tf_sessionrun(
    -> 1341           options, feed_dict, fetch_list, target_list, run_metadata)
       1342 
    
    /home/wkp/.conda/envs/WKPenv/lib/python3.6/site-packages/tensorflow/python/client/session.py in _call_tf_sessionrun(self, options, feed_dict, fetch_list, target_list, run_metadata)
       1428         self._session, options, feed_dict, fetch_list, target_list,
    -> 1429         run_metadata)
       1430 
    
    FailedPreconditionError: Error while reading resource variable mcmc_sample_chain_1/mh_bootstrap_results/hmc_kernel_bootstrap_results/maybe_call_fn_and_grads/value_and_gradients/value_and_gradient/dense_40/bias from Container: localhost. This could mean that the variable was uninitialized. Not found: Resource localhost/mcmc_sample_chain_1/mh_bootstrap_results/hmc_kernel_bootstrap_results/maybe_call_fn_and_grads/value_and_gradients/value_and_gradient/dense_40/bias/N10tensorflow3VarE does not exist.
    	 [[{{node mcmc_sample_chain_1/mh_bootstrap_results/hmc_kernel_bootstrap_results/maybe_call_fn_and_grads/value_and_gradients/value_and_gradient/dense_40/BiasAdd/ReadVariableOp}}]]
    
    opened by doctorwes 2
Releases(1.3.1)
  • 1.3.1(Jul 6, 2020)

    InferPy is a high-level API for defining probabilistic models containing deep neural networks in Python and capable of running on top of Edward and TensorFlow. InferPy’s API is strongly inspired by Keras, and it has a focus on enabling flexible data processing, easy-to-code probabilistic modeling, scalable inference and robust model validation.

    Changes:

    • Documentation updated.
    • Extras requirements modified: keyword all installs only CPU dependencies while all-gpu also those for GPUs are installed .
    Source code(tar.gz)
    Source code(zip)
  • 1.3.0(Feb 12, 2020)

    InferPy is a high-level API for defining probabilistic models containing deep neural networks in Python and capable of running on top of Edward and TensorFlow. InferPy’s API is strongly inspired by Keras, and it has a focus on enabling flexible data processing, easy-to-code probabilistic modeling, scalable inference and robust model validation.

    Changes:

    • Integration with Bayesian Layers from TFP.
    • Keras models can be defined inside InferPy models.
    • Inference with MCMC.
    • Documentation update.
    • Fixed bugs #200, #201, #202.

    Release Date: 12/02/2020 Further Information: Documentation

    Source code(tar.gz)
    Source code(zip)
  • 1.2.3(Oct 18, 2019)

    InferPy is a high-level API for defining probabilistic models containing deep neural networks in Python and capable of running on top of Edward and TensorFlow. InferPy’s API is strongly inspired by Keras and it has a focus on enabling flexible data processing, easy-to-code probabilistic modeling, scalable inference and robust model validation.

    Changes:

    • Bug detected at #195: false dependency is created between RVs which are acenstors of a trainable layer.
    • Documentation updated.

    Release Date: 18/10/2019 Further Information: Documentation

    Source code(tar.gz)
    Source code(zip)
  • 1.2.2(Oct 10, 2019)

    InferPy is a high-level API for defining probabilistic models containing deep neural networks in Python and capable of running on top of Edward and TensorFlow. InferPy’s API is strongly inspired by Keras and it has a focus on enabling flexible data processing, easy-to-code probabilistic modeling, scalable inference and robust model validation.

    Changes:

    • Hotfix at #193, dependency changed of tensorflow-probability from >=0.5.0,<0.1.0 to >=0.5.0,<0.8.0.

    Release Date: 10/10/2019 Further Information: Documentation

    Source code(tar.gz)
    Source code(zip)
  • 1.2.1(Sep 19, 2019)

    InferPy is a high-level API for defining probabilistic models containing deep neural networks in Python and capable of running on top of Edward and TensorFlow. InferPy’s API is strongly inspired by Keras and it has a focus on enabling flexible data processing, easy-to-code probabilistic modeling, scalable inference and robust model validation.

    Changes:

    • Function inf.MixtureGaussian encapsulating ed.MixtureSameFamily.
    • Documentation updated.

    Release Date: 19/09/2019 Further Information: Documentation

    Source code(tar.gz)
    Source code(zip)
  • 1.2.0(Aug 30, 2019)

    InferPy is a high-level API for defining probabilistic models containing deep neural networks in Python and capable of running on top of Edward and Tensorflow. InferPy’s API is strongly inspired by Keras and it has a focus on enabling flexible data processing, easy-to-code probabilistic modeling, scalable inference and robust model validation.

    Changes:

    • Data handling from memory and CSV files.
    • Renamed inferpy.datasets to inferpy.data.
    • Internal code enhancements.
    • Documentation extended.
    • Fixed some bugs.

    Release Date: 29/08/2019 Further Information: Documentation

    Source code(tar.gz)
    Source code(zip)
  • 1.1.3(Aug 26, 2019)

    InferPy is a high-level API for defining probabilistic models containing deep neural networks in Python and capable of running on top of Edward and Tensorflow. InferPy’s API is strongly inspired by Keras and it has a focus on enabling flexible data processing, easy-to-code probabilistic modeling, scalable inference and robust model validation.

    Changes:

    • Fixed some bugs related to posterior predictive computation.
    • Small internal improvements.

    Release Date: 26/08/2019 Further Information: Documentation

    Source code(tar.gz)
    Source code(zip)
  • 1.1.1(Aug 8, 2019)

    InferPy is a high-level API for defining probabilistic models containing deep neural networks in Python and capable of running on top of Edward and Tensorflow. InferPy’s API is strongly inspired by Keras and it has a focus on enabling flexible data processing, easy-to-code probabilistic modeling, scalable inference and robust model validation.

    Changes:

    • Updated requirements.
    • New extra requirements: visualization, datasets.

    Release Date: 08/08/2019 Further Information: Documentation

    Source code(tar.gz)
    Source code(zip)
  • 1.1.0(Jul 4, 2019)

    InferPy is a high-level API for defining probabilistic models containing deep neural networks in Python and capable of running on top of Edward and Tensorflow. InferPy’s API is strongly inspired by Keras and it has a focus on enabling flexible data processing, easy-to-code probabilistic modeling, scalable inference and robust model validation.

    Changes:

    • API for prior, posterior, and posterior_predictive queries.
    • GPU support.
    • Small changes in code structure.
    • Fixed compatibility issue with TFP 0.7.0.
    • Documentation updated.
    • Fixed some bugs.

    Release Date: 04/07/2019 Further Information: Documentation

    Source code(tar.gz)
    Source code(zip)
  • 1.0.0(May 27, 2019)

    InferPy is a high-level API for defining probabilistic models containing deep neural networks in Python and capable of running on top of Edward and Tensorflow. InferPy’s API is strongly inspired by Keras and it has a focus on enabling flexible data processing, easy-to-code probabilistic modeling, scalable inference and robust model validation.

    Changes:

    • Extensive re-design of the API.
    • Compatible with TFP/Edward 2.
    • Edward 1 is not further supported.

    Release Date: 27/05/2019 Further Information: Documentation

    Source code(tar.gz)
    Source code(zip)
  • 0.2.2(Jan 31, 2019)

    InferPy is a high-level API for probabilistic modeling written in Python and capable of running on top of Edward and Tensorflow. InferPy’s API is strongly inspired by Keras and it has a focus on enabling flexible data processing, easy-to-code probabilistic modeling, scalable inference and robust model validation.

    Changes:

    • fixed bug #110 when defining a Poisson.

    Release Date: 31/01/2019 Further Information: Documentation

    Source code(tar.gz)
    Source code(zip)
  • 0.2.1(Nov 23, 2018)

    InferPy is a high-level API for probabilistic modeling written in Python and capable of running on top of Edward and Tensorflow. InferPy’s API is strongly inspired by Keras and it has a focus on enabling flexible data processing, easy-to-code probabilistic modeling, scalable inference and robust model validation.

    Changes:

    • batch parameter in random variable definitions.
    • Changes in the documentation.
    • Name reference to replicate constructs.
    • Predefined and custom parametrized models (inf.models.predefiend)
    • Version flag moved to inferpy/__init__.py
    • Fixed some bugs.

    Release Date: 23/11/2018 Further Information: Documentation

    Source code(tar.gz)
    Source code(zip)
  • 0.2.0(Oct 2, 2018)

    InferPy is a high-level API for probabilistic modeling written in Python and capable of running on top of Edward and Tensorflow. InferPy’s API is strongly inspired by Keras and it has a focus on enabling flexible data processing, easy-to-code probabilistic modeling, scalable inference and robust model validation.

    Changes:

    • Fixed some bugs.
    • matmul and dot operations support new input types (numpy, tensors, lists and InferPy variables).
    • Extended documentation.
    • Moved Qmodel module to inferences package.
    • Multidimensional InferPy variables are now indexed in the same way than numpy arrays (get_item operator).
    • Auto-install dependencies fixed.

    Release Date: 02/10/2018 Further Information: Documentation

    Source code(tar.gz)
    Source code(zip)
  • 0.1.2(Aug 3, 2018)

    InferPy is a high-level API for probabilistic modeling written in Python and capable of running on top of Edward and Tensorflow. InferPy’s API is strongly inspired by Keras and it has a focus on enabling flexible data processing, easy-to-code probabilistic modeling, scalable inference and robust model validation.

    Changes:

    • MetropolisHastings (MCMC) inference method
    • Creation of empirical q variables
    • dot operator
    • indexation operator
    • MultivariateNormalDiag distribution
    • methods mean(), variance() and sddev() for random variables

    Release Date: 3/08/2018 Further Information: Documentation

    Source code(tar.gz)
    Source code(zip)
  • 0.1.1(Jun 21, 2018)

    InferPy is a high-level API for probabilistic modeling written in Python and capable of running on top of Edward and Tensorflow. InferPy’s API is strongly inspired by Keras and it has a focus on enabling flexible data processing, easy-to-code probabilistic modelling, scalable inference and robust model validation.

    Changes:

    • Fixed some bugs
    • Prediction and evaluation functionality
    • Function inf.case_states allows lists of variables as input
    • Simple output string for distributions
    • Added inf.gather operation
    • Transpose is allowed when using inf.matmul
    • inf.case works inside a replicate construct
    • ProbModel.copy()
    • Code reorganization

    Release Date: 21/06/2018 Further Information: Documentation

    Source code(tar.gz)
    Source code(zip)
  • 0.1.0(May 14, 2018)

    InferPy is a high-level API for probabilistic modeling written in Python and capable of running on top of Edward and Tensorflow. InferPy’s API is strongly inspired by Keras and it has a focus on enabling flexible data processing, easy-to-code probablistic modelling, scalable inference and robust model validation.

    Changes:

    • Fixed some bugs
    • Qmodel class
    • New distributions: Gamma, Bernoulli, InverseGamma, Laplace
    • inferpy.models.ALLOWED_VARS is a list with all the types of variables (i.e., distributions) allowed.
    • infMethod argument in compile method
    • inferpy.case function wrapping tensorflow.case
    • Boolean operators
    • Correlated samples from ProbModel

    Release Date: 14/05/2018 Further Information: Documentation

    Source code(tar.gz)
    Source code(zip)
  • 0.0.3(May 14, 2018)

    InferPy is a high-level API for probabilistic modeling written in Python and capable of running on top of Edward and Tensorflow. InferPy’s API is strongly inspired by Keras and it has a focus on enabling flexible data processing, easy-to-code probablistic modelling, scalable inference and robust model validation.

    Changes:

    • Fixed some bugs
    • New distributions: Beta, Exponential, Uniform, Poisson, Categorical, Multinomial, Dirichlet
    • Integration with pandas

    Release Date: 25/03/2018 Further Information: Documentation

    Source code(tar.gz)
    Source code(zip)
  • 0.0.2(Mar 2, 2018)

    InferPy is a high-level API for probabilistic modeling written in Python and capable of running on top of Edward and Tensorflow. InferPy’s API is strongly inspired by Keras and it has a focus on enabling flexible data processing, easy-to-code probablistic modelling, scalable inference and robust model validation.

    Changes:

    • Fixed some bugs
    • RandomVariable base class
    • Optional parameter for returning a Tensorflow object
    • Latent variables
    • Dependency between variables
    • Definition of probabilistic models
    • Inference with KLqp

    Release Date: 02/03/2018 Further Information: Documentation, Pypi package

    Source code(tar.gz)
    Source code(zip)
  • 0.0.1(Feb 9, 2018)

    InferPy is a high-level API for probabilistic modeling written in Python and capable of running on top of Edward and Tensorflow. InferPy’s API is strongly inspired by Keras and it has a focus on enabling flexible data processing, easy-to-code probablistic modelling, scalable inference and robust model validation.

    This version includes the basic functionality:

    • Normal distribution
    • Replicate construct

    Release Date: 09/02/2018 Further Information: Documentation

    Source code(tar.gz)
    Source code(zip)
(ICCV 2021) ProHMR - Probabilistic Modeling for Human Mesh Recovery

ProHMR - Probabilistic Modeling for Human Mesh Recovery Code repository for the paper: Probabilistic Modeling for Human Mesh Recovery Nikos Kolotouros

Nikos Kolotouros 209 Dec 13, 2022
Implementation based on Paper - Learning a Probabilistic Latent Space of Object Shapes via 3D Generative-Adversarial Modeling

Implementation based on Paper - Learning a Probabilistic Latent Space of Object Shapes via 3D Generative-Adversarial Modeling

HamasKhan 3 Jul 8, 2022
Generative Flow Networks for Discrete Probabilistic Modeling

Energy-based GFlowNets Code for Generative Flow Networks for Discrete Probabilistic Modeling by Dinghuai Zhang, Nikolay Malkin, Zhen Liu, Alexandra Vo

Narsil-Dinghuai Zhang 51 Dec 20, 2022
Fast, flexible and easy to use probabilistic modelling in Python.

Please consider citing the JMLR-MLOSS Manuscript if you've used pomegranate in your academic work! pomegranate is a package for building probabilistic

Jacob Schreiber 3k Dec 29, 2022
Deep universal probabilistic programming with Python and PyTorch

Getting Started | Documentation | Community | Contributing Pyro is a flexible, scalable deep probabilistic programming library built on PyTorch. Notab

null 7.7k Dec 30, 2022
Deep Probabilistic Programming Course @ DIKU

Deep Probabilistic Programming Course @ DIKU

null 52 May 14, 2022
Registration Loss Learning for Deep Probabilistic Point Set Registration

RLLReg This repository contains a Pytorch implementation of the point set registration method RLLReg. Details about the method can be found in the 3DV

Felix Järemo Lawin 35 Nov 2, 2022
DeepProbLog is an extension of ProbLog that integrates Probabilistic Logic Programming with deep learning by introducing the neural predicate.

DeepProbLog DeepProbLog is an extension of ProbLog that integrates Probabilistic Logic Programming with deep learning by introducing the neural predic

KU Leuven Machine Learning Research Group 94 Dec 18, 2022
PyTorch deep learning projects made easy.

PyTorch Template Project PyTorch deep learning project made easy. PyTorch Template Project Requirements Features Folder Structure Usage Config file fo

Victor Huang 3.8k Jan 1, 2023
Deep Learning with PyTorch made easy 🚀 !

Deep Learning with PyTorch made easy ?? ! Carefree? carefree-learn aims to provide CAREFREE usages for both users and developers. It also provides a c

null 381 Dec 22, 2022
TensorFlow implementation for Bayesian Modeling and Uncertainty Quantification for Learning to Optimize: What, Why, and How

Bayesian Modeling and Uncertainty Quantification for Learning to Optimize: What, Why, and How TensorFlow implementation for Bayesian Modeling and Unce

Shen Lab at Texas A&M University 8 Sep 2, 2022
Deep generative modeling for time-stamped heterogeneous data, enabling high-fidelity models for a large variety of spatio-temporal domains.

Neural Spatio-Temporal Point Processes [arxiv] Ricky T. Q. Chen, Brandon Amos, Maximilian Nickel Abstract. We propose a new class of parameterizations

Facebook Research 75 Dec 19, 2022
A Pytorch implementation of "Manifold Matching via Deep Metric Learning for Generative Modeling" (ICCV 2021)

Manifold Matching via Deep Metric Learning for Generative Modeling A Pytorch implementation of "Manifold Matching via Deep Metric Learning for Generat

null 69 Dec 10, 2022
Urban mobility simulations with Python3, RLlib (Deep Reinforcement Learning) and Mesa (Agent-based modeling)

Deep Reinforcement Learning for Smart Cities Documentation RLlib: https://docs.ray.io/en/master/rllib.html Mesa: https://mesa.readthedocs.io/en/stable

null 1 May 15, 2022
aka "Bayesian Methods for Hackers": An introduction to Bayesian methods + probabilistic programming with a computation/understanding-first, mathematics-second point of view. All in pure Python ;)

Bayesian Methods for Hackers Using Python and PyMC The Bayesian method is the natural approach to inference, yet it is hidden from readers behind chap

Cameron Davidson-Pilon 25.1k Jan 2, 2023
Supervised domain-agnostic prediction framework for probabilistic modelling

A supervised domain-agnostic framework that allows for probabilistic modelling, namely the prediction of probability distributions for individual data

The Alan Turing Institute 112 Oct 23, 2022
Probabilistic Programming and Statistical Inference in PyTorch

PtStat Probabilistic Programming and Statistical Inference in PyTorch. Introduction This project is being developed during my time at Cogent Labs. The

Stefano Peluchetti 109 Nov 26, 2022