locked
Can infer.net's inference engine cope with a Bayesian network with 200+ nodes? RRS feed

  • Question

  • I'm trying to run InferenceEngine on a large Bayesian network with 200+ nodes (taken from old UAI inference competitions), and I get in an out-of-memory exception after 10 minutes of runtime.

    I read through the performance tips page and it seems that the main tip is to move from .net arrays to Variable.Array.

    I'm not sure how applicable this tip is to my case, where I have this large network where each node has associated with is a unique CPT. 

    Any idea?

    Roni Stern

    Thursday, December 18, 2014 7:18 AM

All replies

  • The tip does apply to large networks.  See How to represent large irregular graphs.  Still, 200 nodes should not be a problem.  How are you encoding the CPTs?  Are you compiling for 64-bit?
    Thursday, December 18, 2014 12:29 PM
    Owner
  • First, thanks for the quick reply!

    The Bayesian network I have has about 200 nodes (a bit more).
    Every node has a potentially different domain, which is a set of discrete values. 
    Maybe I'm doing something wrong, but I was unable to define all the 200 nodes as a VariableArray
    and still define (with the SetTo method) different factors for each node.
    Is there a way to define different factors for different members of a VariableArray?

    Anyhow, I ended up defining a C# array of Variable<int> objects instead, and setting the factors for each variable with the SetTo and Case methods. 

    I modified the target platform now to be x86 and still get an out of memory error. 
    Any ideas/tips?
    Thursday, December 18, 2014 3:34 PM
  • In your project's properties, go to the Build tab and select x64 as the platform target. Also, untick the Prefer 32-bit checkbox.
    Thursday, December 18, 2014 9:58 PM
  • Tried this too and I still cannot get marginals for my large network. 

    Just to clarify my previous question: if I have 10 variables, each with different factors affecting it,

    can I still put these variables in a VariableArry? 

    I tried and could not but maybe I did something wrong.

    Sunday, December 21, 2014 11:19 AM
  • Hi

    Do you know of someone that have tried to run inference over such large networks (>200 nodes)?

    This is a real problem in my current research, and I really love the infer.net framework in general.

    Roni

    Wednesday, December 24, 2014 1:03 PM
  • Here is an example of a Bayes net with 500 nodes that works fine even under 32-bit.  It completes in less than a minute, with most of this time spent on compilation.

                int NumberOfExamples = 1;
                Range N = new Range(NumberOfExamples).Named("N");
                Range R = new Range(2).Named("R");
                var tablePrior = new Dirichlet(1,1);
                int numNodes = 500;
                var nodes = new VariableArray<int>[numNodes];
                var node = Variable.Array<int>(N).Named("node0");
                node[N] = Variable.Discrete(tablePrior.Sample()).ForEach(N);
                node.SetValueRange(R);
                nodes[0] = node;
                for (int i = 1; i < numNodes; i++)
                {
                    var table = Variable.Array<Vector>(R).Named("table"+i);
                    table.SetValueRange(R);
                    table.ObservedValue = Util.ArrayInit(2, j => tablePrior.Sample());
                    nodes[i] = AddChildFromOneParent(nodes[i - 1], table).Named("node"+i);
                }
                InferenceEngine engine = new InferenceEngine();
                int nodeToInfer = numNodes - 1;
                Console.WriteLine("node[{0}] = {1}", nodeToInfer, engine.Infer(nodes[nodeToInfer]));

    Monday, January 12, 2015 6:59 PM
    Owner