Answered by:
WCF (localhost)

Question
-
When using a WCF (localhost) application using infer.net, I get an exception at the following line:
Dirichlet pPost = engine.Infer<Dirichlet>(p);
double[] alpha = new double[] { 1.2, 3.4 }; Range dim = new Range(alpha.Length).Named("dim"); Variable<Vector> p = Variable.Dirichlet(dim, alpha).Named("p"); int n = 10; VariableArray<int> x = Variable.Multinomial(n, p).Named("x"); InferenceEngine engine = new InferenceEngine(new VariationalMessagePassing()); int[] k = new int[] { 3, 7 }; x.ObservedValue = k; Dirichlet pPost = engine.Infer<Dirichlet>(p);
Please advise?
matekus
Illiud Latine dici non potest.
Wednesday, October 2, 2013 10:07 PM
Answers
-
Looks like it is trying to write the generated source files to disk, and hitting an error. Try setting engine.Compiler.WriteSourceFiles = false; engine.Compiler.GenerateInMemory = true;
- Marked as answer by _matekus_ Friday, October 4, 2013 6:29 PM
Friday, October 4, 2013 12:22 PMOwner
All replies
-
What exception do you get? What does WCF have to do with it? I just built your model (in a console app) and it ran just fine.Thursday, October 3, 2013 12:21 AM
-
Yordan,
Thanks for the prompt follow-up.
Yes, I agree that there is no problem with using the above code in a console application. However, I get the following stack trace when I attempt to use it in a WCF context (see "C:\infernetBuilds\19-04-2013_13-25\Compiler\Infer\InferenceEngine.cs:line 496"):<StackTrace>at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, Object dirSecurityObj, Boolean checkHost) at System.IO.Directory.InternalCreateDirectoryHelper(String path, Boolean checkHost) at System.IO.Directory.CreateDirectory(String path) at MicrosoftResearch.Transforms.CodeCompiler.WriteSource(List`1 typeDeclarations, IList`1 filenames, ICollection`1& referencedAssemblies) in C:\infernetBuilds\19-04-2013_13-25\Compiler\TransformFramework\CodeTransformer.cs:line 135 at MicrosoftResearch.Transforms.CodeCompiler.WriteAndCompile(List`1 typeDeclarations) in C:\infernetBuilds\19-04-2013_13-25\Compiler\TransformFramework\CodeTransformer.cs:line 199 at MicrosoftResearch.Infer.ModelCompiler.CompileWithoutParams(ITypeDeclaration itd, MethodBase method, AttributeRegistry`2 inputAttributes) in C:\infernetBuilds\19-04-2013_13-25\Compiler\Infer\ModelCompiler.cs:line 506 at MicrosoftResearch.Infer.InferenceEngine.Compile() in C:\infernetBuilds\19-04-2013_13-25\Compiler\Infer\InferenceEngine.cs:line 188 at MicrosoftResearch.Infer.InferenceEngine.BuildAndCompile(Boolean inferOnlySpecifiedVars, IEnumerable`1 vars) in C:\infernetBuilds\19-04-2013_13-25\Compiler\Infer\InferenceEngine.cs:line 531 at MicrosoftResearch.Infer.InferenceEngine.GetCompiledInferenceAlgorithm(Boolean inferOnlySpecifiedVars, IVariable var) in C:\infernetBuilds\19-04-2013_13-25\Compiler\Infer\InferenceEngine.cs:line 496 at MicrosoftResearch.Infer.InferenceEngine.InferAll(Boolean inferOnlySpecifiedVars, IVariable var) in C:\infernetBuilds\19-04-2013_13-25\Compiler\Infer\InferenceEngine.cs:line 415 at MicrosoftResearch.Infer.InferenceEngine.Infer[TReturn](IVariable var) in C:\infernetBuilds\19-04-2013_13-25\Compiler\Infer\InferenceEngine.cs:line 234 at multibayes.Service1.DirichletCounts() in c:\wip_matekus\appdev\vs2013\projects\wcf\multibayes\Service1.svc.cs:line 64 at SyncInvokeDirichletCounts(Object , Object[] , Object[] ) at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</StackTrace>
matekus
Illiud Latine dici non potest.
- Edited by _matekus_ Thursday, October 3, 2013 1:59 PM
Thursday, October 3, 2013 1:57 PM -
Looks like it is trying to write the generated source files to disk, and hitting an error. Try setting engine.Compiler.WriteSourceFiles = false; engine.Compiler.GenerateInMemory = true;
- Marked as answer by _matekus_ Friday, October 4, 2013 6:29 PM
Friday, October 4, 2013 12:22 PMOwner -
Thanks Tom.
Your solution worked.
matekus
Illiud Latine dici non potest.
Friday, October 4, 2013 6:28 PM