Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何处理infer.net和pythonnet?_Python_.net_Python.net_Inference Engine_Infer.net - Fatal编程技术网

如何处理infer.net和pythonnet?

如何处理infer.net和pythonnet?,python,.net,python.net,inference-engine,infer.net,Python,.net,Python.net,Inference Engine,Infer.net,我试图在Python3.6中使用infer.net()。为此,我安装了pythonnet包,并下载了使用infer.net所需的dll文件。文件/包的导入、新类型的使用都在起作用,但是当我试图推断一个基本模型时,我得到了一个PlatformNotSupportedException,我不知道如何处理这种错误。有人能帮我吗?我用的是Jupyter笔记本这是我用的代码 import clr import System import numpy as np from System import C

我试图在Python3.6中使用infer.net()。为此,我安装了pythonnet包,并下载了使用infer.net所需的dll文件。文件/包的导入、新类型的使用都在起作用,但是当我试图推断一个基本模型时,我得到了一个PlatformNotSupportedException,我不知道如何处理这种错误。有人能帮我吗?我用的是Jupyter笔记本这是我用的代码


import clr
import System
import numpy as np

from System import Console
from System import Array
from System import IO
from System import Array, Double, Type

clr.AddReference("Microsoft.ML.Probabilistic")
clr.AddReference("Microsoft.ML.Probabilistic.Compiler")
clr.AddReference("Microsoft.ML.Probabilistic.Learners")
clr.AddReference("System.CodeDom")



#---------import all classes and methods from above namespaces-----------
from Microsoft.ML.Probabilistic.Distributions import *
from Microsoft.ML.Probabilistic.Models import *
from Microsoft.ML.Probabilistic.Collections import *
from Microsoft.ML.Probabilistic.Factors import *
from Microsoft.ML.Probabilistic.Math import *

from Microsoft.ML.Probabilistic.Models import Variable, VariableArray, Range, InferenceEngine
from Microsoft.ML.Probabilistic.Distributions import Gaussian, Gamma


len = Variable.New[int]()
dataRange = Range(len)
x = Variable.Array[float](dataRange)
mean = Variable.GaussianFromMeanAndVariance(0.0, 100.0).Named('mean')
precision = Variable.GammaFromShapeAndScale(1.0, 1.0).Named('precision')
x.set_Item(dataRange,
           Variable.GaussianFromMeanAndPrecision(mean,
                                                 precision).ForEach(dataRange))


data = []  # System.Array.CreateInstance(float, 100)
for i in range(0, 100):
    data.append(np.random.normal(42, 1))

ie = InferenceEngine()
len.ObservedValue = 100
x.ObservedValue = data

engine = InferenceEngine() 
engine.ModelName = 'Gaussian_priors'

engine.Infer(mean)

---------------------------------------------------------------------------
PlatformNotSupportedException             Traceback (most recent call last)
PlatformNotSupportedException: L'opération n'est pas prise en charge sur cette plateforme.
   à Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch(CompilerParameters options, String[] fileNames)
   à Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromFileBatch(CompilerParameters options, String[] fileNames)
   à Microsoft.ML.Probabilistic.Compiler.CodeCompiler.CompileWithCodeDom(List`1 filenames, List`1 sources, ICollection`1 referencedAssemblies)
   à Microsoft.ML.Probabilistic.Compiler.CodeCompiler.Compile(List`1 filenames, List`1 sources, ICollection`1 referencedAssemblies)

The above exception was the direct cause of the following exception:

PlatformNotSupportedException             Traceback (most recent call last)
<ipython-input-1-c6ab7cf71833> in <module>()
     47 engine.ModelName = 'Gaussian_priors'
     48 
---> 49 engine.Infer(mean)

PlatformNotSupportedException: Current platform is not supported by the current compiler choice Auto. Try a different one.
   à Microsoft.ML.Probabilistic.Compiler.CodeCompiler.Compile(List`1 filenames, List`1 sources, ICollection`1 referencedAssemblies)
   à Microsoft.ML.Probabilistic.Compiler.CodeCompiler.WriteAndCompile(List`1 typeDeclarations)
   à Microsoft.ML.Probabilistic.Compiler.ModelCompiler.CompileWithoutParams[T](List`1 itds)
   à Microsoft.ML.Probabilistic.Models.InferenceEngine.Compile()
   à Microsoft.ML.Probabilistic.Models.InferenceEngine.GetCompiledInferenceAlgorithm(Boolean inferOnlySpecifiedVars, IVariable var)
   à Microsoft.ML.Probabilistic.Models.InferenceEngine.Infer(IVariable var)

导入clr
导入系统
将numpy作为np导入
从系统导入控制台
从系统导入数组
从系统导入IO
从系统导入数组,双精度,键入
clr.AddReference(“Microsoft.ML.xml”)
clr.AddReference(“Microsoft.ML.probability.Compiler”)
clr.AddReference(“Microsoft.ML.probability.Learners”)
clr.AddReference(“System.CodeDom”)
#---------从上述名称空间导入所有类和方法-----------
从Microsoft.ML.probability.import导入*
从Microsoft.ML.probability.Models导入*
从Microsoft.ML.probability.Collections导入*
从Microsoft.ML.probability.Factors导入*
从Microsoft.ML.probability.Math导入*
从Microsoft.ML.probability.Models导入变量、变量数组、范围、推断引擎
从Microsoft.ML.probability.Distributions导入高斯、伽马分布
len=变量。新[int]()
数据范围=范围(len)
x=变量。数组[float](数据范围)
均值=变量。高斯均值和方差(0.01100.0)。命名为('mean')
精度=变量。GammaFromShapeAndScale(1.0,1.0)。命名为('precision')
x、 设置_项(数据范围,
变量。高斯平均值和精度(平均值,
精度)。ForEach(数据范围))
data=[]#System.Array.CreateInstance(float,100)
对于范围(0,100)内的i:
数据。追加(np。随机。正常(42,1))
ie=推理引擎()
len.ObservedValue=100
x、 观测值=数据
引擎=推断引擎()
engine.ModelName='Gaussian_priors'
发动机。推断(平均值)
---------------------------------------------------------------------------
PlatformNotSupportedException回溯(最后一次最近调用)
平台不支持例外情况:平台上的所有费用均不包括在内。
§Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch(编译器参数选项,字符串[]文件名)
§Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAsemblyFromFileBatch(CompilerParameters选项,字符串[]文件名)
§Microsoft.ML.probability.Compiler.CodeCompiler.CompileWithCodeDom(列出`1个文件名,列出`1个源,ICollection`1个引用程序集)
§Microsoft.ML.probability.Compiler.CodeCompiler.Compile(列出`1个文件名,列出`1个源,ICollection`1个引用程序集)
上述异常是以下异常的直接原因:
PlatformNotSupportedException回溯(最后一次最近调用)
在()
47 engine.ModelName='Gaussian_priors'
48
--->49发动机。推断(平均值)
PlatformNotSupportedException:当前编译器选项Auto不支持当前平台。试试另一个。
§Microsoft.ML.probability.Compiler.CodeCompiler.Compile(列出`1个文件名,列出`1个源,ICollection`1个引用程序集)
§Microsoft.ML.probability.Compiler.CodeCompiler.WriteAndCompile(列表'1类型声明)
§Microsoft.ML.probability.Compiler.modelcomiler.CompileWithoutParams[T](列表'1 ITD)
§Microsoft.ML.probability.Models.推理引擎.Compile()
§Microsoft.ML.probability.Models.推理引擎.GetCompiledReferenceAlgorithm(布尔推理指定变量,IVVariable变量)
áMicrosoft.ML.probability.Models.推理引擎.inference(可变var)