GithubHelp home page GithubHelp logo

pgm-lab / inferpy Goto Github PK

View Code? Open in Web Editor NEW
143.0 10.0 14.0 31.79 MB

InferPy: Deep Probabilistic Modeling with Tensorflow Made Easy

Home Page: https://inferpy-docs.readthedocs.io/en/stable/index.html

License: Apache License 2.0

Python 3.86% Jupyter Notebook 96.13% Shell 0.01%
probabilistic-programming neural-network tensorflow keras-tensorflow probabilistic-modeling user-friendly

inferpy's People

Contributors

andresmasegosa avatar jcozar87 avatar rcabanasdepaz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

inferpy's Issues

ImportError: cannot import name 'Bernoulli'

Hi,

I'm trying to run some of the examples on the documentation page, but it seems like it's not possible to import the Bernoulli model. Has it been removed or am I doing something wrong perhaps?

error with normal of dimension>1

When a multidimensional Normal variable is created, the dimension remains equal to 1, i.e.:

import inferpy as inf

# define a 2-dimension Normal distribution of 2·3=6 batches
with inf.replicate(size=2):
	with inf.replicate(size=3):
		x = inf.models.Normal(loc=0., scale=1., dim=2)


>>> x.shape
[6, 1]

FutureWarning

warning with inference:

...InferPy/env2.7/lib/python2.7/site-packages/edward/util/random_variables.py:52: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  not np.issubdtype(value.dtype, np.float) and \

latent variables

Allow to define latent variables in the prob models. Now, all the variables are assumed observed.

ValueError with multidimensional parameter distribution

Problem when defining a parameter which is a multidimensional distribution:

theta = inf.models.Normal(loc=[0., 0.], scale=1.)
x = inf.models.Normal(loc=theta, scale=1., observed=True)

raises the error below:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Users/rcabanas/Documents/UAL/inferpy/repo/InferPy/inferpy/models/normal.py", line 90, in __init__
    loc_rep = self.__reshape_param(loc, self_shape)
  File "/Users/rcabanas/Documents/UAL/inferpy/repo/InferPy/inferpy/models/normal.py", line 165, in __reshape_param
    param_tf_mat = tf.reshape(tf.stack(param_vect), (D,))
  File "/Users/rcabanas/Documents/UAL/inferpy/repo/InferPy/env2.7/lib/python2.7/site-packages/tensorflow/python/ops/gen_array_ops.py", line 3997, in reshape
    "Reshape", tensor=tensor, shape=shape, name=name)
  File "/Users/rcabanas/Documents/UAL/inferpy/repo/InferPy/env2.7/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
    op_def=op_def)
  File "/Users/rcabanas/Documents/UAL/inferpy/repo/InferPy/env2.7/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 3162, in create_op
    compute_device=compute_device)
  File "/Users/rcabanas/Documents/UAL/inferpy/repo/InferPy/env2.7/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 3208, in _create_op_helper
    set_shapes_for_outputs(op)
  File "/Users/rcabanas/Documents/UAL/inferpy/repo/InferPy/env2.7/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2427, in set_shapes_for_outputs
    return _set_shapes_for_outputs(op)
  File "/Users/rcabanas/Documents/UAL/inferpy/repo/InferPy/env2.7/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2400, in _set_shapes_for_outputs
    shapes = shape_func(op)
  File "/Users/rcabanas/Documents/UAL/inferpy/repo/InferPy/env2.7/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2330, in call_with_requiring
    return call_cpp_shape_fn(op, require_shape_fn=True)
  File "/Users/rcabanas/Documents/UAL/inferpy/repo/InferPy/env2.7/lib/python2.7/site-packages/tensorflow/python/framework/common_shapes.py", line 627, in call_cpp_shape_fn
    require_shape_fn)
  File "/Users/rcabanas/Documents/UAL/inferpy/repo/InferPy/env2.7/lib/python2.7/site-packages/tensorflow/python/framework/common_shapes.py", line 691, in _call_cpp_shape_fn_impl
    raise ValueError(err.message)
ValueError: Cannot reshape a tensor with 2 elements to shape [1] (1 elements) for 'Reshape_25' (op: 'Reshape') with input shapes: [1,2], [1] and with input tensors computed as partial shapes: input[1] = [1].

Error with Binomial

with Edward:

Traceback (most recent call last):
File "", line 1, in
File "/Users/rcabanas/venv/2.7/inferpy2.7/lib/python2.7/site-packages/edward/models/random_variables.py", line 21, in init
_RandomVariable.init(self, *args, **kwargs)
File "/Users/rcabanas/venv/2.7/inferpy2.7/lib/python2.7/site-packages/edward/models/random_variable.py", line 133, in init
.format(self.class.name))
NotImplementedError: sample is not implemented for Binomial. You must either pass in the value argument or implement sample for Binomial.

parameter which are variables of dimension higher than 1

The code

t = inf.models.Normal(0.4,0.001,dim=2)
y = inf.models.Beta([t,0.5], 1)

raises the error:

ValueError: Shapes must be equal rank, but are 1 and 0
From merging shape 0 with other shapes. for 'stack_11' (op: 'Pack') with input shapes: [2], [].

Type of posterior

Make consistent the distribution of the prior with the type of the posterior

bug in probmodel constructor

The definition of a new probmodel keeps the variables of the previous models, i.e.:


with inf.ProbModel() as m:

    x = Normal(loc=1., scale=1., name="x", observed=True)
    y = Normal(loc=x, scale=1., dim=3, name="y")


with inf.ProbModel() as m2:

    x = Normal(loc=1., scale=1., name="x", observed=True)
    y = Normal(loc=x, scale=1., dim=3, name="y")


len(m2.varlist)   # 4 instead of 2

Categorical dimension bug

t = inf.models.Normal(loc = [0.1, 0.4, 0.6], scale= 0.06)

x = inf.models.Categorical(probs = [t, 1])

x.dim

raises:

Traceback (most recent call last):
File "", line 1, in
File "/Users/rcabanas/Documents/UAL/inferpy/repo/InferPy/inferpy/models/random_variable.py", line 63, in dim
return self.base_object.shape.as_list()[-1]
IndexError: list index out of range

Simple inference algorithm

Implement a simple inference algorithm for learning the parameters from data:


model.compile(infMethod = 'KLqp')
model.fit(data_training, epochs=10)

x_post = model.posterior(x)

simplify seed management

In edward, the seed is set using:

ed.set_seed(1234)

though this command should be invoked at the begining. Make possible to update at any moment

Initial documentation

Write documentation in the code of the code implemented until now. Then synchronise it with sphinx

Plateau

Methods for defining variables with the plateau structure. For example:

with inf.replicate(size = K)
    x = Normal(loc = 0, scale = 1, dim = 2)

Factory tests

Create tests for multiple random variable types and shapes.

matplotlib dependency

matplotlib 1.3.1 requires nose, which is not installed.
matplotlib 1.3.1 requires tornado, which is not installed.

QModel class

For example:

pca = ProbModel(vars = [mu,w_n,x_n])

q_mu = inf.inference.Q.Normal(bind = mu, initializer='random_unifrom')
q_w_n = inf.inference.Q.Normal(bind = w_n, initializer='random_unifrom')

qmodel = QModel(vars = [q_mu,q_w_n])

pca.compile(infMethod = 'KLqp', Q = qmodel)
pca.fit(x_train)
posterior_mu = pca.posterior(mu)


consistency in a ProbModel

Check the consistency in a ProbModel, for example, that all the required variables are in the ProbModel

prob_log

implement prob log at RandomVariable and ProbModel classes

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.