我在这里查看cs文件:https:
//www.microsoft.com/net/learn/apps/machine-learning-and-ai/ml-dotnet/get-started/windows
并尝试翻译它到F#它编译得很好但是System.Reflection.TargetInvocationException
在运行时抛出:FormatException: One of the identified items was in an invalid format
.我错过了什么?
open Microsoft.ML
open Microsoft.ML.Runtime.Api
open Microsoft.ML.Trainers
open Microsoft.ML.Transforms
open System
type IrisData =
[<Column("0")>] val mutable SepalLength : float
[<Column("1")>] val mutable SepalWidth : float
[<Column("2")>] val mutable PetalLength : float
[<Column("3")>] val mutable PetalWidth : float
[<Column("4");ColumnName("Label")>] val mutable Label : string
new(sepLen, sepWid, petLen, petWid, label) =
{ SepalLength = sepLen
SepalWidth = sepWid
PetalLength = petLen
PetalWidth …
Run Code Online (Sandbox Code Playgroud) 我创建了一个新的控制台应用程序 .net46,安装了最新的 ML 并尝试了一个简单的 LDA。得到上面的错误。我在网上找到的修复程序似乎都不起作用。它正在寻找不存在的 System.Numerics.Vectors 的 4.1.3.0 版本。
我有一个我构建的 TensorFlow 模型(一个 1D CNN),我现在想将其实现到 .NET 中。
为此,我需要知道输入和输出节点。
当我将模型上传到Netron 时,根据我的保存方法,我得到了一个不同的图表,唯一看起来正确的图表来自 h5 上传。这是model.summary()
:
如果我将模型保存为 h5model.save("Mn_pb_model.h5")
并将其加载到 Netron 中以绘制图形,一切看起来都是正确的:
但是,ML.NET 不接受 h5 格式,因此需要将其保存为 pb。
在查看在 ML.NET 中采用 TensorFlow 的示例时,该示例显示了一个 TensorFlow 模型,该模型以与SavedModel格式类似的格式保存- 由 TensorFlow 推荐(同时也是 ML.NET在此处推荐的“下载未冻结的 [SavedModel 格式] ……”)。但是,当将 pb 文件保存并加载到 Netron 时,我得到了这个:
再放大一点(在最右边),
正如你所看到的,它看起来不像它应该的那样。
此外,输入节点和输出节点不正确,因此它不适用于 ML.NET(我认为有些问题)。
我使用TensorFlow推荐的方法来确定输入/输出节点:
当我尝试获取冻结图并将其加载到 Netron 时,起初它看起来是正确的,但我不认为它是:
有四个原因我认为这是不正确的。
我在这里查看cs文件:https://www.microsoft.com/net/learn/apps/machine-learning-and-ai/ml-dotnet/get-started/windows,一切正常.
现在我想改进一下这个例子:我想预测一个只有数字的数据集而不是数字字符串数据集,例如预测七段显示的输出.
这是我的超级简单数据集,最后一列是我想要预测的int数:
1,0,1,1,1,1,1,0
0,0,0,0,0,1,1,1
1,1,1,0,1,1,0,2
1,1,1,0,0,1,1,3
0,1,0,1,0,1,1,4
1,1,1,1,0,0,1,5
1,1,1,1,1,0,1,6
1,0,0,0,0,1,1,7
1,1,1,1,1,1,1,8
1,1,1,1,0,1,1,9
Run Code Online (Sandbox Code Playgroud)
这是我的测试代码:
public class Digit
{
[Column("0")] public float Up;
[Column("1")] public float Middle;
[Column("2")] public float Bottom;
[Column("3")] public float UpLeft;
[Column("4")] public float BottomLeft;
[Column("5")] public float TopRight;
[Column("6")] public float BottomRight;
[Column("7")] [ColumnName("DigitValue")]
public float DigitValue;
}
public class DigitPrediction
{
[ColumnName("PredictedDigits")] public float PredictedDigits;
}
public PredictDigit()
{
var pipeline = new LearningPipeline();
var dataPath = Path.Combine("Segmenti", "segments.txt");
pipeline.Add(new TextLoader<Digit>(dataPath, …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用一些随机测试数据的ML.net框架.我的数据存在DepartmentId(1-25)和Body(字符串).我希望我的机器预测应该分配正文的部门(例如在像Zendesk这样的票务系统中).
使用以下代码,我收到一个错误:
ArgumentOutOfRangeException:缺少分数列
我不确定为什么它会说Score
列缺失,因为它出现在我的预测课程中.
这是我训练模型以及课程的设置.
主要
var pipeline = new LearningPipeline();
pipeline.Add(new TextLoader(_dataPath).CreateFrom<DepartmentData>(userHeader: true, seperator: ','));
pipeline.Add(new TextFeaturizer("Features", "Body"));
pipeline.Add(new Dictionarizer("Label"));
pipeline.Add(new StochasticDualCoordinateAscentClassifier());
pipeline.Add(new PredictedLabelColumnOriginalValueConverter() { PredictedLabelColumn = "PredictedLabel" });
var model = pipeline.Train<DepartmentData, DepartmentPrediction>();
Run Code Online (Sandbox Code Playgroud)
DepartmentData和DepartmentPrediction
public class DepartmentData
{
[Column(ordinal: "0", name: "Label")]
public float Department;
[Column(ordinal: "1")]
public string Body;
}
public class DepartmentPrediction
{
[ColumnName("PredictedLabel")]
public float Department;
[ColumnName("Score")]
public float[] Score;
}
Run Code Online (Sandbox Code Playgroud)
示例数据
Department, Body
1, Hello. 4 weeks ago I requested a replacement …
Run Code Online (Sandbox Code Playgroud) 这是从TaxiFarePrediction示例复制的ML.Net管道对象的创建.
LearningPipeline pipeline = new LearningPipeline
{
new TextLoader(TrainDataPath).CreateFrom<TaxiTrip>(separator:','),
new ColumnCopier(("FareAmount", "Label")),
new CategoricalOneHotVectorizer("VendorId","RateCode","PaymentType"),
new ColumnConcatenator("Features","VendorId","RateCode","PassengerCount","TripDistance","PaymentType"),
new FastTreeRegressor()
};
Run Code Online (Sandbox Code Playgroud)
基本上,我想在ColumnCopier,CategoricalOneHotVectorizer和ColumnConcatenator应用之后返回数据.
我是机器学习的新手。我遇到了 ML.NET(微软的机器学习框架)。我们可以使用这个框架进行语音识别吗?如果您想在 ML.NET 中进行语音识别,您应该了解哪些知识?
我是VS code/F#的新手(如果这很傻,那就是preapologies),我正在尝试构建一个F#控制台应用程序(在Windows工作站和我的Linux计算机上).
我和FAKE一起安装了Ionide扩展.
我正在考虑的代码是Iris示例(请参阅如何将介绍ML.Net演示转换为F#?),使用Ionide创建一个新的F#项目并使用Microsoft.ML.
我的iris.fsproj
是
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net461</TargetFramework>
<DebugType>portable</DebugType>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<ItemGroup>
<Compile Include="iris.fs" />
<None Include="App.config" />
</ItemGroup>
<Import Project="..\.paket\Paket.Restore.targets" />
</Project>
Run Code Online (Sandbox Code Playgroud)
运行脚本时(我使用"播放"按钮,也就是F#:运行VS Code/Ionide提供的脚本),我得到:
C:\Users\MyUser\.nuget\packages\microsoft.ml\0.2.0\build\Microsoft.ML.targets(16,5): error : Microsoft.ML currently supports 'x64' processor architectures. Please ensure your application is targeting 'x64'.
和...一起
Running build failed.
Error:
System.Exception: dotnet build failed
如何使用Ionide提供的项目结构来定位x64?
我正在培训ML.Net机器学习模型.我可以训练它并从中预测,并从磁盘中保存/加载它.但我需要能够将其从磁盘上加载,然后重新训练,或者添加新信息以便随着时间的推移对其进行改进.
有谁知道这是否可能?我在MS文档中没有找到任何关于如何做到这一点的内容,但对于ML来说这是一个非常标准的事情,所以如果不可能的话我会感到惊讶.
谢谢
我正在使用ML.NET 0.7,并且具有一个带有以下结果类的MulticlassClassification模型:
public class TestClassOut
{
public string Id { get; set; }
public float[] Score { get; set; }
public string PredictedLabel { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我想知道该Scores
物业的分数和相应的标签。感觉像我应该能够使该属性成为a Tuple<string,float>
或类似属性以获得得分所代表的标签。
我了解V0.5上有一种方法:
model.TryGetScoreLabelNames(out scoreLabels);
Run Code Online (Sandbox Code Playgroud)
但似乎找不到V0.7中的等效项。
能做到吗?如果是这样怎么办?