microsoft / vs-tools-for-ai

Visual Studio Tools for AI is a free Visual Studio extension to build, test, and deploy deep learning / AI solutions. It seamlessly integrates with Azure Machine Learning for robust experimentation capabilities, including but not limited to submitting data preparation and model training jobs transparently to different compute targets. Additionally, it provides support for custom metrics and run history tracking, enabling data science reproducibility and auditing. Enterprise ready collaboration, allow to securely work on project with other people.
http://aka.ms/vstoolsforai
352 stars 80 forks source link

can`t convert model in visual studio #19

Open dorademon opened 6 years ago

dorademon commented 6 years ago

HI, I want to convert a scikit-learn model to onnx,but I dont now how to set up the input_featrues parameters. thanks :)

my model featrues : Sepal Length float 1 Sepal Width float 1 Petal Length float 1 Petal Width float 1

Here are the error logs :

System.Exception: D:\sofatware\microsoft Visual Studio\shared\Python36_64\lib\site-packages\sklearn\base.py:311: UserWarning: Trying to unpickle estimator LogisticRegression from version 0.18.1 when using version 0.19.1. This might lead to breaking code or invalid results. Use at your own risk. UserWarning) Traceback (most recent call last): File "C:\USERS\H00316469\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\15.0_04A81442\EXTENSIONS\Y2LMQEZR.VBA\RuntimeSDK\model\model_converter_cli.py", line 203, in convert_sklearn_to_onnx model_onnx = convert_sklearn(model_sklearn, extra_args.get(paramname_graph_name), input_features) File "D:\sofatware\microsoft Visual Studio\shared\Python36_64\lib\site-packages\winmltools\convert\main.py", line 20, in convert_sklearn return _convert_sklearn(model, name, input_features) File "D:\sofatware\microsoft Visual Studio\shared\Python36_64\lib\site-packages\onnxmltools\convert\sklearn\convert.py", line 109, in convert nodes += _convert_sklearn_node(context, model, node_inputs) File "D:\sofatware\microsoft Visual Studio\shared\Python36_64\lib\site-packages\onnxmltools\convert\sklearn\convert.py", line 159, in _convert_sklearn_node return _do_convert(context, converter, node, inputs) File "D:\sofatware\microsoft Visual Studio\shared\Python36_64\lib\site-packages\onnxmltools\convert\sklearn\convert.py", line 148, in _do_convert node = converter.convert(context, sk_node, inputs) File "D:\sofatware\microsoft Visual Studio\shared\Python36_64\lib\site-packages\onnxmltools\convert\sklearn\GLMClassifierConverter.py", line 63, in convert class_labels = utils.cast_list(int, classes) File "D:\sofatware\microsoft Visual Studio\shared\Python36_64\lib\site-packages\onnxmltools\convert\common\utils.py", line 144, in cast_list return [type(item) for item in items] File "D:\sofatware\microsoft Visual Studio\shared\Python36_64\lib\site-packages\onnxmltools\convert\common\utils.py", line 144, in return [type(item) for item in items] ValueError: invalid literal for int() with base 10: 'Iris-setosa'

Best regards

dorademon commented 6 years ago

Add this feature Species string 1 (this is a label, can it be used as a feature ?)

Now my model features: Sepal Length float 1 Sepal Width float 1 Petal Length float 1 Petal Width float 1 Species string 1

Error log: System.Exception: D:\sofatware\microsoft Visual Studio\shared\Python36_64\lib\site-packages\sklearn\base.py:311: UserWarning: Trying to unpickle estimator LogisticRegression from version 0.18.1 when using version 0.19.1. This might lead to breaking code or invalid results. Use at your own risk. UserWarning) Traceback (most recent call last): File "D:\sofatware\microsoft Visual Studio\shared\Python36_64\lib\site-packages\onnxmltools\convert\sklearn\convert.py", line 97, in convert nodes.extend(_combine_inputs(context, model_inputs)) File "D:\sofatware\microsoft Visual Studio\shared\Python36_64\lib\site-packages\onnxmltools\convert\sklearn\convert.py", line 176, in _combine_inputs "These types are not supported when specifying multiple inputs {0}".format(onnx_unsupported_types)) RuntimeError: Unsupported type specified.These types are not supported when specifying multiple inputs [8]

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\USERS\H00316469\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\15.0_04A81442\EXTENSIONS\Y2LMQEZR.VBA\RuntimeSDK\model\model_converter_cli.py", line 203, in convert_sklearn_to_onnx model_onnx = convert_sklearn(model_sklearn, extra_args.get(paramname_graph_name), input_features) File "D:\sofatware\microsoft Visual Studio\shared\Python36_64\lib\site-packages\winmltools\convert\main.py", line 20, in convert_sklearn return _convert_sklearn(model, name, input_features) File "D:\sofatware\microsoft Visual Studio\shared\Python36_64\lib\site-packages\onnxmltools\convert\sklearn\convert.py", line 103, in convert raise ValueError('Invalid input_features argument.') ValueError: Invalid input_features argument.

tocean commented 6 years ago

Could you share you model file?

dorademon commented 6 years ago

@tocean Thanks for your attention, I can't share my model file because of information security. the main question is
how can I set the Extra arguments (Graph name/Input features including name,type and shape)? docs of tools for AI doesn't tell this.

tocean commented 6 years ago

It depends on the input of your model. For this case, if the input feature is a float array with shape [4], I think the following should work. image Graph name is only an attribute of the ONNX graph. So input a meaningful name you like. If it is empty, a guid will filled automatically.