Comments (5)
In Z
, the number of states is implicitly given by alpha
. That is, Z
doesn't have K
plates axis, instead it is an integer variable in range {0, ..., K-1}, and this range is determined by the dimensionality of alpha
. That is, Z
doesn't have K
repeated variables but each single value is in range {0, ..., K-1}. Thus, you need to remove that plate axis, because that just adds an extra plate axis which has nothing to do with the mixture clusters. The parameter cluster_plate
is related to the parameters of the Poisson distribution, that is, rate_parameter
has the clusters on the second last plate axis, as you have correctly done. So, I think this should fix:
Z = Categorical(alpha, plates=(NSamples, D))
from bayespy.
You can also simplify the following line:
rate_parameter = Gamma(alpha, beta, plates=(K,D))
You don't need to do explicit broadcasting with np.ones(D)
because broadcasting of plates is done automatically.
from bayespy.
Also, just noting that you are using separate cluster assignments for each of the D
dimensions. If you don't want to do that, this should work:
Z = Categorical(alpha, plates=(NSamples, 1))
But in case you wanted separate cluster assignments for each dimension, then never mind. Just wanted to let you know if you hadn't noticed.
from bayespy.
Thanks - while I understand the plates in theory, I've been having trouble getting things to align properly once I get to the mixture model (being new to python and broadcasting doesn't help). Below is my updated/working code, where the order of the plate dimensions for the rate_parameter is different than you suggest above. Any advice on symmetry breaking in this model (I get rapid, but nonsensical convergence)?
rate_parameter = Gamma(alpha, beta, plates=(D,K))
a0 = Dirichlet(1e-3*np.ones(K))
Z = Categorical(a0, plates=(NSamples, 1))
Y = Mixture(Z, Poisson, rate_parameter)
Y.observe(y)
from bayespy.
That looks good! I suggest you initialize randomly with:
Z.initialize_from_random()
Then, make sure rate_parameter
is learned before Z
. Easiest way to do this, is by listing them in that order for VB
:
Q = VB(Y, rate_parameter, Z, a0)
And yep, aligning plates and other axes can sometimes be a bit of a head ache. I've been thinking about some simpler and clearer syntax which would still utilize "array properties". Haven't come up with a good solution yet. Of course, if you have an idea what kind of syntax you would find intuitive, I'd be happy to hear and take that into account. :)
from bayespy.
Related Issues (20)
- ImageComparisonFailure error during tests HOT 1
- Creating Gaussian Node Raises Error HOT 4
- Extended Marble Example HOT 1
- Fast Variational Bayesian Linear State-Space Model HOT 2
- Performance Doubt HOT 3
- Implamenting
- How to approach bayesian?
- Online/Iterative Learning for Bayespy?
- Higher order Markov chains? HOT 3
- Anaconda install of bayespy causes a downgrade of ipython HOT 6
- Gate for Non Categorical Variable HOT 4
- How to extract posterior over latent states from CategoricalMarkovChain HOT 2
- Remove deprecated time.clock() call HOT 1
- Array of counts doesn't work in multinomial mixture HOT 2
- Using the posterior distribution? HOT 1
- Gaussian mixture HOT 2
- Increase the usage of augmented assignment statements
- Errors in the demos HOT 1
- More projects for "Similar projects"
- Equations not showing in docs HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bayespy.