Better tuning (Migrated from community.research.microsoft.com) RRS feed

  • Question

  • Ali Yaghoubi posted on 03-01-2011 3:31 PM

    Thanks Dear John for your sincere response.

    I have some experience in c# programming and this is why I am obsessed with the programming

    tasks by that. Would you mind illustrating the behind of the sense events of this jagged array code part

    specially lines number three and afters.


    int[] sizes = new int[] { 2, 3 };
    Range item = new Range(sizes.Length).Named("item");
    VariableArray<int> sizesVar = Variable.Constant(sizes, item).Named("sizes");
    Range feature = new Range(sizesVar[item]).Named("feature");
    var x = 
    Variable.Array(Variable.Array<double>(feature), item).Named("x");

    Friday, June 3, 2011 6:28 PM


  • John Guiver replied on 03-03-2011 10:35 AM

    Hi Ali

    This is covered in the jagged array section of the user guide,

    The inner range is jagged as given by 'sizes' so the size of the outer array is the number of sizes of the inner array. We make an Infer.NET variable out of this sizes array in the third line. The Infer.NET Range object accepts a constructor argument which is a model expression - in this case sizesVar[item] in the fourth line. The fifth line then creates an instance of a Variable array of variable arrays of type double. Each call to one of the model-building lines (line 2-5) records the necessary information behind the scenes. When you query the model by running the Infer method this information is used to compile the model into some inference code to provide the answer to the query.


    Friday, June 3, 2011 6:28 PM