本文介绍了用keras保存的ML.NET加载模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用Keras用Python实现的神经网络.培训之后,我就导出了模型,并得到了两个文件:model.js和model.h5.现在,我想在.NET项目中进行实时分类,并希望使用经过训练的神经网络.

I have a Neural Network implemented in Python with Keras. Once I have trained it I have exported the model and I have got two files: model.js and model.h5. Now I want to classify in real time inside a .NET project and I want to use the trained Neural Network for it.

在ML.NET中,有没有一种方法可以将通过python导出的模型和训练后的权重加载到模型对象中?

Is there a way in ML.NET of loading the model and trained weights exported with python into a model object?

我在文档[1]中看到可以加载以前保存的模型,但是显然是以.zip格式存储的,我找不到格式(也许是从python和'将其转换为ML.NET模型.

I have seen in the documentation[1] that a previous saved model can be loaded, but apparently is storage in a .zip and I could not find the format (maybe to make a script that takes the model from python and 'translate' it to the ML.NET model.

hdf5格式显然是一种标准[2],有没有办法用ML.NET加载它?

Apparently the hdf5 format is a standard[2], there is a way to load it with ML.NET?

[1] https://docs.microsoft.com/zh-CN/dotnet/machine-learning/how-to-guides/using-model-ml-net

[2] https://support.hdfgroup.org/HDF5/doc1.6/UG/10_Datasets.html

推荐答案

ML.net支持ONNX模型.

ML.net supports ONNX models.

https://github.com/dotnet/machinelearning-samples/tree/master/samples/csharp/getting-started/DeepLearning_ObjectDetection_Onnx

您可以通过 WinMLTools

这篇关于用keras保存的ML.NET加载模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 01:04