Dynamic BN
Dynamic BN
Hi,
I am using your SMILE lib, and it works good! I am just wandering, if there is any dynamic Bayesian Net libs in SMILE? And is there any simple documents for that?
Thanks a lot!
I am using your SMILE lib, and it works good! I am just wandering, if there is any dynamic Bayesian Net libs in SMILE? And is there any simple documents for that?
Thanks a lot!
-
- Site Admin
- Posts: 1441
- Joined: Mon Nov 26, 2007 5:51 pm
Re: Dynamic BN
SMILE supports dynamic BNs (DBNs), but the only docs available is this forum thread:
http://genie.sis.pitt.edu/forum/viewtopic.php?f=2&t=223
Feel free to ask more questions on the forum - I'll try to help.
http://genie.sis.pitt.edu/forum/viewtopic.php?f=2&t=223
Feel free to ask more questions on the forum - I'll try to help.
Re: Dynamic BN
Hi,
I'm also looking for a simple document or example how to create and initialize Dynamic Bayesian Networks using SMILE.
I could not find any documentation (except for parameter learning in Wiki), and the link in the previous post does not seem to be up to date.
Is there any resource I am missing?
I'm also looking for a simple document or example how to create and initialize Dynamic Bayesian Networks using SMILE.
I could not find any documentation (except for parameter learning in Wiki), and the link in the previous post does not seem to be up to date.
Is there any resource I am missing?
-
- Site Admin
- Posts: 1441
- Joined: Mon Nov 26, 2007 5:51 pm
Re: Dynamic BN
Unfortunately, we don't have proper docs for DBNs in SMILE yet. The link in this thread points to our old forum, which is no longer active. On this forum, use the following link:Is there any resource I am missing?
http://support.bayesfusion.com/forum/vi ... ?f=2&t=223
Re: Dynamic BN
Hello,
I am reading the draft related to DBNs.
I am wondering how to get access to a specific probability matrix at a specific temporal slice in order to modify the probabilities.
Thank you in advance!
I am reading the draft related to DBNs.
I am wondering how to get access to a specific probability matrix at a specific temporal slice in order to modify the probabilities.
Thank you in advance!
-
- Site Admin
- Posts: 1441
- Joined: Mon Nov 26, 2007 5:51 pm
Re: Dynamic BN
You need to get the node's definition and cast it to DSL_cpt, then call GetTemporalProbabilities:
Code: Select all
DSL_cpt* cptDef = static_cast<DSL_cpt *>(net.GetNode(handle)->Definition());
const DSL_Dmatrix* probs = cptDef->GetTemporalProbabilities();
Re: Dynamic BN
That way, I only get access to the matrix but I cannot modify the probabilities.
In case of no temporal slices, I use the following code to get access and modify the probabilities.
DSL_nodeDefinition *successDef = net.GetNode(handle)->Definition();
DSL_doubleArray sp(successDef->GetMatrix()->GetSize());
sp[0] = 0.8; sp[1] = 0.2;
res = successDef->SetDefinition(sp);
Do you have any similar approach in case of temporal slices?
In case of no temporal slices, I use the following code to get access and modify the probabilities.
DSL_nodeDefinition *successDef = net.GetNode(handle)->Definition();
DSL_doubleArray sp(successDef->GetMatrix()->GetSize());
sp[0] = 0.8; sp[1] = 0.2;
res = successDef->SetDefinition(sp);
Do you have any similar approach in case of temporal slices?
-
- Site Admin
- Posts: 1441
- Joined: Mon Nov 26, 2007 5:51 pm
Re: Dynamic BN
Use one of these two methods of the DSL_cpt class:
Code: Select all
int SetTemporalProbabilities(int order, const DSL_Dmatrix &probs);
int SetTemporalProbabilities(int order, const DSL_doubleArray &probs);
Re: Dynamic BN
I tried the following code to get access to node "Ignition" and modify the CPT at time slice 0.
Unfortunately the code is crashing and I do not understand the reason.
After updating the beliefs, I try to print the matrix of the beliefs of a target node "Safe" using this code:
Can you please suggest any possible mistake in my codes?
Thank you!
Code: Select all
int handle = net.FindNode("Ignition");
if (handle < 0)
{
return handle;
}
DSL_cpt* cptDef = static_cast<DSL_cpt *>(net.GetNode(handle)->Definition());
DSL_doubleArray prob0(cptDef->GetTemporalProbabilities(0)->GetSize());
prob0[0] = 0.99;prob0[1] = 0.01;
res = cptDef->SetTemporalProbabilities(0, prob0);
After updating the beliefs, I try to print the matrix of the beliefs of a target node "Safe" using this code:
Code: Select all
net.UpdateBeliefs();
DSL_node *f = net.GetNode(target);
const DSL_beliefVector &beliefs = *f->Value()->GetMatrix();
for (int i = 0; i < 6; i++)
{
printf("Safe=%g at time %d\n", beliefs[i,1], i);
}
Thank you!
-
- Site Admin
- Posts: 1441
- Joined: Mon Nov 26, 2007 5:51 pm
Re: Dynamic BN
Where exactly does the crash happen?Unfortunately the code is crashing and I do not understand the reason.
Re: Dynamic BN
I believe it crashes at the GetSize(); to initialize the size of "prob0" to be equal to the CPT size.
-
- Site Admin
- Posts: 1441
- Joined: Mon Nov 26, 2007 5:51 pm
Re: Dynamic BN
Code: Select all
DSL_doubleArray prob0(cptDef->GetTemporalProbabilities(0)->GetSize());
For the conditional probabilities between the node in the same slice use non-temporal functions.