我是F#/.NET的新手,我正在尝试运行如何使用 ML.NET库,在Visual Studio上使用F#,并使用Microsoft.ML(0.2. 0).
I am new to F#/.NET and I am trying to run the F# example provided in the accepted answer of How to translate the intro ML.Net demo to F#? with the ML.NET library, using F# on Visual Studio, using Microsoft.ML (0.2.0).
构建时出现错误error FS0039: The type 'TextLoader' is not defined.
为避免这种情况,我添加了一行
To avoid this, I added the line
open Microsoft.ML.Data到源. 然后,那条线
pipeline.Add(new TextLoader<IrisData>(dataPath,separator = ","))触发器: error FS0033: The non-generic type 'Microsoft.ML.Data.TextLoader' does not expect any type arguments, but here is given 1 type argument(s)
更改为:
pipeline.Add(new TextLoader(dataPath,separator = ","))产量: error FS0495: The object constructor 'TextLoader' has no argument or settable return property 'separator'. The required signature is TextLoader(filePath: string) : TextLoader.
更改为:
pipeline.Add(new TextLoader(dataPath))使构建成功,但是在运行时代码失败 ArgumentOutOfRangeException: Column #1 not found in the dataset (it only has 1 columns),我认为是因为逗号分隔符未正确拾取(顺便说一句,您可以在 archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data ).
makes the build successful, but the code fails when running with ArgumentOutOfRangeException: Column #1 not found in the dataset (it only has 1 columns), I assume because the comma separator is not correctly picked up (incidentally, you can find and inspect the iris dataset at archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data).
也
pipeline.Add(new TextLoader(dataPath).CreateFrom<IrisData>(separator: ','))不起作用.
我了解到TextLoader最近发生了变化(请参见例如 github/dotnet/machinelearning/issues/332 ),有人可以指出我做错了什么吗?
I understand that there have been changes in TextLoader recently (see e.g. github/dotnet/machinelearning/issues/332), can somebody point me to what I am doing wrong?
推荐答案F#只是有些不同的语法,可能需要一些习惯.它不使用new关键字实例化新类,也不使用命名参数,而是使用=而不是C#中的:.
F# just has a bit of a different syntax that can take some getting used to. It doesn't use the new keyword to instantiate a new class and to use named parameters it uses the = instead of : that you would in C#.
因此对于C#中的这一行:
So for this line in C#:
pipeline.Add(new TextLoader(dataPath).CreateFrom<IrisData>(separator: ','))在F#中会是这样:
pipeline.Add(TextLoader(dataPath).CreateFrom<IrisData>(separator=','))更多推荐
在F#中运行ML.Net Iris演示时,我是否使用TextLoader错误?
发布评论