pgm-lab / inferpy Goto Github PK
View Code? Open in Web Editor NEWInferPy: Deep Probabilistic Modeling with Tensorflow Made Easy
Home Page: https://inferpy-docs.readthedocs.io/en/stable/index.html
License: Apache License 2.0
InferPy: Deep Probabilistic Modeling with Tensorflow Made Easy
Home Page: https://inferpy-docs.readthedocs.io/en/stable/index.html
License: Apache License 2.0
pca.compile(infMethod = 'KLqp', Q = qmodel)
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
matplotlib 1.3.1 requires nose, which is not installed.
matplotlib 1.3.1 requires tornado, which is not installed.
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?
Allow to define latent variables in the prob models. Now, all the variables are assumed observed.
Implement the class for encapsulating the functionality related to prob. models and for simplifying their definitions:
x = Normal(loc = 0, scale = 1, dim = 2)
y = Normal(loc = 2*x, scale = 1, dim = 2)
model = ProbModel(vars = [x, y])
https://docs.google.com/document/d/1W_JtNWHMnlZ3PwdnJYv3kFm6wee8qVMzuVuJ-r8Gd4c/edit?usp=sharing
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]
Write documentation in the code of the code implemented until now. Then synchronise it with sphinx
Methods for defining variables with the plateau structure. For example:
with inf.replicate(size = K)
x = Normal(loc = 0, scale = 1, dim = 2)
Make consistent the distribution of the prior with the type of the posterior
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].
The Normal distribution with location loc and scale parameters. Example:
x = Normal (loc = 0, scale = 1, dim = 5)
discussion details in https://docs.google.com/document/d/1eHoNEnyErCMoupzme5RJeqRIK2k63m4r4cjuxN95zTw/edit?usp=sharing
Prepare the basic version for PyPl for being able to install with the following command:
pip install inferpy
Base class for random variables.
Implement an self-updated symbol in inferpy.models.ALLOWED_VARS
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.
implement prob log at RandomVariable and ProbModel classes
Implement cas and fond functions for allowing parameters conditioned on the value of some other variabels:
https://www.tensorflow.org/api_docs/python/tf/cond
https://www.tensorflow.org/api_docs/python/tf/case
Check the consistency in a ProbModel, for example, that all the required variables are in the ProbModel
Implement TransformedDistribution
http://edwardlib.org/api/ed/models/TransformedDistribution
change location of inf.INF_METHODS
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
If some variables are dependant in a model, their samples should be correlated
The parameters of a random variable might be others random variables.
Implement tests for Normal and Replicate classes. Make compatible with travis
TODO: standardise the use of tensors of type float32 or float64
Create tests for multiple random variable types and shapes.
Related issue: #12
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)
Implement: ==, and, or
The result should be a deterministic variable
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], [].
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)
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
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 \
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.