您的位置:首页 > 其它

ML.NET 发布0.11版本:.NET中的机器学习,为TensorFlow和ONNX添加了新功能

2019-03-12 13:50 459 查看

微软发布了其最新版本的机器学习框架:ML.NET0.11带来了新功能和突破性变化。

新版本的机器学习开源框架为TensorFlow和ONNX添加了新功能,但也包括一些重大变化,这也是发布RC版本之前的最后一个预览版,这个月底将发布0.12版本,也就是RC1。

ML.NET的创新0.11

0.11版本的ML.NET现在还支持TensorFlowTransformer组件中的文本输入数据。TensorFlow模型不仅可用于图像,还可用于文本分析。这在.NET博客的代码示例中进行了说明,该博客使用TensorFlow模型进行情感分析:

publicclassTensorFlowSentiment

{
publicstringSentiment_Text;
[VectorType(600)]
publicint[]Features;
[VectorType(2)]
publicfloat[]Prediction;
}
[TensorFlowFact]
publicvoidTensorFlowSentimentClassificationTest()
{
varmlContext=newMLContext(seed:1,conc:1);
vardata=new[]{newTensorFlowSentiment(){Sentiment_Text="thisfilmwasjustbrilliantcastinglocationscenerystorydirectioneveryone'sreallysuitedtheparttheyplayedandyoucouldjustimaginebeingthererobert isanamazingactorandnowthesamebeingdirector fathercamefromthesamescottishislandasmyselfsoilovedthefacttherewasarealconnectionwiththisfilmthewittyremarksthroughoutthefilmweregreatitwasjustbrilliantsomuchthatiboughtthefilmassoonasitwasreleasedfor andwouldrecommendittoeveryonetowatchandtheflyfishingwasamazingreallycriedattheenditwassosadandyouknowwhattheysayifyoucryatafilmitmusthavebeengoodandthisdefinitelywasalso tothetwolittleboy'sthatplayedthe ofnormanandpaultheywerejustbrilliantchildrenareoftenleftoutofthe listithinkbecausethestarsthatplaythemallgrownuparesuchabigprofileforthewholefilmbutthesechildrenareamazingandshouldbepraisedforwhattheyhavedonedon'tyouthinkthewholestorywassolovelybecauseitwastrueandwassomeone'slifeafterallthatwassharedwithusall"}};
vardataView=mlContext.Data.ReadFromEnumerable(data);
varlookupMap=mlContext.Data.ReadFromTextFile(@"sentiment_model/imdb_word_index.csv",
columns:new[]
{
newTextLoader.Column("Words",DataKind.TX,0),
newTextLoader.Column("Ids",DataKind.I4,1),
},
separatorChar:','
);
varestimator=mlContext.Transforms.Text.TokenizeWords("TokenizedWords","Sentiment_Text")
.Append(mlContext.Transforms.Conversion.ValueMap(lookupMap,"Words","Ids",new[]{("Features","TokenizedWords")}));
vardataPipe=estimator.Fit(dataView)
.CreatePredictionEngine<TensorFlowSentiment,TensorFlowSentiment>(mlContext);
stringmodelLocation=@"sentiment_model";
vartfEnginePipe=mlContext.Transforms.ScoreTensorFlowModel(modelLocation,new[]{"Prediction/Softmax"},new[]{"Features"})
.Append(mlContext.Transforms.CopyColumns(("Prediction","Prediction/Softmax")))
.Fit(dataView)
.CreatePredictionEngine<TensorFlowSentiment,TensorFlowSentiment>(mlContext);
//Predictthesentimentforthesampledata
varprocessedData=dataPipe.Predict(data[0]);
Array.Resize(refprocessedData.Features,600);
varprediction=tfEnginePipe.Predict(processedData);
}
还为MLContext目录添加了其他机器学习组件。这应该可以更容易地找到类和操作。该图显示了基于智能提示的用户体验。 该ONNX组件还进行了重构:Microsoft.ML.ONNX 更改为Microsoft.ML.ONNXConverter和Microsoft.ML.ONNXTrans.FORM更改为Microsoft.ML.ONNXTransformer。这更清晰的表达ONNX转换和转换之间的区别。ONNX是一种开放且可互操作的模型格式,允许您在框架中训练模型,以及在另一个框架中使用。例如:Scikit-learn或TensorFlow训练的模型放到在ML.NET中使用。与之前版本的ML.NET0.10相比,ML.NET0.11包含一些重大更改,包括删除Microsoft.ML.Core命名空间。破坏性性更改列表已发布在GitHub上。有关ML.NET0.11中的新功能的更详细信息参见.NET博客文章:https://devblogs.microsoft.com/dotnet/announcing-ml-net-0-11-machine-learning-for-net/。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐