locked
Running inference over multiple datasets (Migrated from community.research.microsoft.com) RRS feed

  • Question

  • Ravi Pandya posted on 08-21-2010 7:59 AM

    I use variables to hold the length of observation datasets and use that range to control the size of VariableArrays for data, e.g.

                observationCount = Variable.New<int>().Named("observationCount");
                observationCount.ObservedValue = 0; // dummy value
                observations = new Range(observationCount).Named("observations");
    I then set observationCount.ObservedValue and the various dataset arrays when I run inference. I get an ArgumentException when I try to run it on a second dataset "that.Count (311) != this.Count (101)"

    The user guide shows an example of manually extracting an algorithm, informing it of changes to observed variables, etc.:

    http://research.microsoft.com/en-us/um/cambridge/projects/infernet/docs/Controlling%20how%20inference%20is%20performed.aspx

    Is this the correct way to run multiple inferences, or is there a simpler way? Thanks,

    Ravi

    Friday, June 3, 2011 5:59 PM

Answers

  • Ravi Pandya replied on 08-24-2010 7:46 AM

    I am setting the ObservedValue property, and I also tried Reset, but still get the exception. I am working around it for now by using two models - I only have two dataset sizes. The exception detail is:

    System.ArgumentException was unhandled
      Message=that.Count (311) != this.Count (101)
      Source=Infer.Runtime
      StackTrace:
           at MicrosoftResearch.Infer.Collections.Array`1.SetTo(Array`1 that) in C:\Users\minka\Depots\dev\groups\ml\infernet\Infer2\Runtime\Core\Collections\Array2d.cs:line 238
           at MicrosoftResearch.Infer.Distributions.DistributionStructArray`2.SetTo(DistributionStructArray`2 that) in C:\Users\minka\Depots\dev\groups\ml\infernet\Infer2\Runtime\Distributions\DistributionArray.cs:line 463
           at MicrosoftResearch.Infer.Factors.ReplicateOp.UsesAverageLogarithm[T,TDef](TDef Def, Int32 resultIndex, T result) in C:\Users\minka\Depots\dev\groups\ml\infernet\Infer2\Runtime\Factors\Replicate.cs:line 587
           at MicrosoftResearch.Infer.Factors.ReplicateOp.MarginalAverageLogarithm[T,TDef](TDef Def, T result) in C:\Users\minka\Depots\dev\groups\ml\infernet\Infer2\Runtime\Factors\Replicate.cs:line 569
           at MicrosoftResearch.Infer.Models.User.Model_VMP.Changed_numberOfIterationsDecreased_observationCount_hasTimeSeries_rnaExpressionChanged0_rnaExpressi1(Int32 numberOfIterations) in c:\Users\ravip\Documents\Extreme\Dream\Stitch\Test\bin\Debug\GeneratedSource\Model_VMP.cs:line 5315
           at MicrosoftResearch.Infer.Models.User.Model_VMP.Execute(Int32 numberOfIterations) in c:\Users\ravip\Documents\Extreme\Dream\Stitch\Test\bin\Debug\GeneratedSource\Model_VMP.cs:line 920
           at MicrosoftResearch.Infer.CompiledAlgorithm.Execute(Int32 numberOfIterations) in C:\Users\minka\Depots\dev\groups\ml\infernet\Infer2\Compiler\Infer\Algorithms\CompiledAlgorithm.cs:line 101
           at MicrosoftResearch.Infer.CompiledAlgorithm.Execute() in C:\Users\minka\Depots\dev\groups\ml\infernet\Infer2\Compiler\Infer\Algorithms\CompiledAlgorithm.cs:line 89
           at MicrosoftResearch.Infer.InferenceEngine.Infer(IVariable var) in C:\Users\minka\Depots\dev\groups\ml\infernet\Infer2\Compiler\Infer\InferenceEngine.cs:line 150
           at MicrosoftResearch.Infer.InferenceEngine.Infer[TReturn](IVariable var) in C:\Users\minka\Depots\dev\groups\ml\infernet\Infer2\Compiler\Infer\InferenceEngine.cs:line 213
           at Stitch.Model.Infer(Dataset data, Parameters updated) in C:\Users\ravip\Documents\Extreme\Dream\Stitch\Stitch\Model.cs:line 528
           at Test.Program.<>c__DisplayClass21.<AnalyzeEdges>b__11(Int32[] p) in C:\Users\ravip\Documents\Extreme\Dream\Stitch\Test\Program.cs:line 185
           at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
           at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
           at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
           at Test.Program.AnalyzeEdges(Observation[] steady, Observation[] series, Int32 perturbationCount, Parameters parameters, String[] names, Graph all) in C:\Users\ravip\Documents\Extreme\Dream\Stitch\Test\Program.cs:line 185
           at Test.Program.Main(String[] args) in C:\Users\ravip\Documents\Extreme\Dream\Stitch\Test\Program.cs:line 59
           at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
           at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()
      InnerException:

    Friday, June 3, 2011 6:00 PM

All replies

  • minka replied on 08-23-2010 1:31 PM

    Changing the ObservedValue property of a variable should be sufficient.  If you are sure that the array sizes have been set correctly, you can try forcing a reset with engine.Reset().  Normally this is unnecessary.  But if it fixes the problem, then let us know and we can investigate the issue.

    Friday, June 3, 2011 6:00 PM
  • Ravi Pandya replied on 08-24-2010 7:46 AM

    I am setting the ObservedValue property, and I also tried Reset, but still get the exception. I am working around it for now by using two models - I only have two dataset sizes. The exception detail is:

    System.ArgumentException was unhandled
      Message=that.Count (311) != this.Count (101)
      Source=Infer.Runtime
      StackTrace:
           at MicrosoftResearch.Infer.Collections.Array`1.SetTo(Array`1 that) in C:\Users\minka\Depots\dev\groups\ml\infernet\Infer2\Runtime\Core\Collections\Array2d.cs:line 238
           at MicrosoftResearch.Infer.Distributions.DistributionStructArray`2.SetTo(DistributionStructArray`2 that) in C:\Users\minka\Depots\dev\groups\ml\infernet\Infer2\Runtime\Distributions\DistributionArray.cs:line 463
           at MicrosoftResearch.Infer.Factors.ReplicateOp.UsesAverageLogarithm[T,TDef](TDef Def, Int32 resultIndex, T result) in C:\Users\minka\Depots\dev\groups\ml\infernet\Infer2\Runtime\Factors\Replicate.cs:line 587
           at MicrosoftResearch.Infer.Factors.ReplicateOp.MarginalAverageLogarithm[T,TDef](TDef Def, T result) in C:\Users\minka\Depots\dev\groups\ml\infernet\Infer2\Runtime\Factors\Replicate.cs:line 569
           at MicrosoftResearch.Infer.Models.User.Model_VMP.Changed_numberOfIterationsDecreased_observationCount_hasTimeSeries_rnaExpressionChanged0_rnaExpressi1(Int32 numberOfIterations) in c:\Users\ravip\Documents\Extreme\Dream\Stitch\Test\bin\Debug\GeneratedSource\Model_VMP.cs:line 5315
           at MicrosoftResearch.Infer.Models.User.Model_VMP.Execute(Int32 numberOfIterations) in c:\Users\ravip\Documents\Extreme\Dream\Stitch\Test\bin\Debug\GeneratedSource\Model_VMP.cs:line 920
           at MicrosoftResearch.Infer.CompiledAlgorithm.Execute(Int32 numberOfIterations) in C:\Users\minka\Depots\dev\groups\ml\infernet\Infer2\Compiler\Infer\Algorithms\CompiledAlgorithm.cs:line 101
           at MicrosoftResearch.Infer.CompiledAlgorithm.Execute() in C:\Users\minka\Depots\dev\groups\ml\infernet\Infer2\Compiler\Infer\Algorithms\CompiledAlgorithm.cs:line 89
           at MicrosoftResearch.Infer.InferenceEngine.Infer(IVariable var) in C:\Users\minka\Depots\dev\groups\ml\infernet\Infer2\Compiler\Infer\InferenceEngine.cs:line 150
           at MicrosoftResearch.Infer.InferenceEngine.Infer[TReturn](IVariable var) in C:\Users\minka\Depots\dev\groups\ml\infernet\Infer2\Compiler\Infer\InferenceEngine.cs:line 213
           at Stitch.Model.Infer(Dataset data, Parameters updated) in C:\Users\ravip\Documents\Extreme\Dream\Stitch\Stitch\Model.cs:line 528
           at Test.Program.<>c__DisplayClass21.<AnalyzeEdges>b__11(Int32[] p) in C:\Users\ravip\Documents\Extreme\Dream\Stitch\Test\Program.cs:line 185
           at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
           at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
           at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
           at Test.Program.AnalyzeEdges(Observation[] steady, Observation[] series, Int32 perturbationCount, Parameters parameters, String[] names, Graph all) in C:\Users\ravip\Documents\Extreme\Dream\Stitch\Test\Program.cs:line 185
           at Test.Program.Main(String[] args) in C:\Users\ravip\Documents\Extreme\Dream\Stitch\Test\Program.cs:line 59
           at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
           at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()
      InnerException:

    Friday, June 3, 2011 6:00 PM