在F#中运行ML.Net Iris演示时,我是否使用TextLoader错误?

编程入门 行业动态 更新时间:2024-10-27 14:27:14
本文介绍了在F#中运行ML.Net Iris演示时,我是否使用TextLoader错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是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错误?

本文发布于:2023-11-09 10:41:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1572161.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:演示   错误   Net   ML   TextLoader

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!