Run onnxruntime with uint8 input - onnx

Is there any possible way to run onnxruntime session with uint8 numpy array input?
[ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Unexpected input data type. Actual: (tensor(uint8)) , expected: (tensor(float))
Above comment pops up everytime.
Thx in advance!

Looks like the error came from the model which expects float type but you provided uint8. It is not a problem of onnxruntime. In onnxruntime, a session is binded to a model.
To know what data type a model expects, netron can be used to check it.
Here documents the operators and data types supported by onnxruntime.

Related

How should i process the data in a json/dataframe format so that is suitable for rasa chatbots

I'm new with NLP and the rasa api. I'm trying to prepare the data so that it can be used as training data for intent recognition. The function that I'm trying to use is:
from rasa_nlu.training_data import load_data #Import function
train_data_rasa=load_data('/content/data_file.json') #Json file
However the next error pop ups:
AttributeError: 'str' object has no attribute 'get'
The json file is the result of using pandas.to_json() function. The original dataset, is the ATIS flight intent dataframe in which there are two columns: The text and the intent.
Here is a preview of the json file:
{"Intent":{"0":"atis_flight","1":"atis_flight_time","2":"atis_airfare","3":"atis_airfare","4":"atis_flight","5":"atis_aircraft","6" ........
I don't really know what is going on as the dataset seems to be clean. I have also tried multiple alternatives such as markdown (md) type of file but it does not seem to work.
Thank you in advance !!
I would suggest to try the rasa data convert command (that converts your training data from json to yml format) and then try to train your data (with command rasa train from the cli) to see if you get the same error. Also, the Training Data format page in the docs might be a useful resource for you since it explains the types of training data and their expected structure. Another idea would be to post your question also on the Rasa forum where there might be more people that have encountered the same error like here. That way you might get more ideas on how to solve your issue or more people will jump in and help.

CNTK: "inferred dimension cannot be calculated from input and new shape size."

I've set up a model for CIFAR-10 using Pytorch, and saved it as an ONNX file.
But it looks like I can't load it from CNTK.
I've already loaded another ONNX file from the same source code (by mistake), so the dependencies look OK. The problem occurs when I call Function.Load()
var deviceDescriptor = DeviceDescriptor.CPUDevice; ;
var function = Function.Load(ONNX_PATH, deviceDescriptor, ModelFormat.ONNX);
I get this exception (Unhandled exception):
System.ApplicationException : 'Reshape: inferred dimension cannot be calculated from input and new shape size.
[CALL STACK]
- CNTK::TrainingParameterSchedule:: GetMinibatchSize
- CNTK:: XavierInitializer (x6)
- CNTK::Function::Load
- CSharp_CNTK_Function__Load__SWIG_0
- 00007FFB0C41C307 (SymFromAddr() error: Le module spécifié est introuvable.)
It looks like this model can't be loaded in CNTK. CNTK has good support for exporting (saving) to ONNX, importing (loading) can be problematic for some operations.
CNTK development is frozen, what's your motivation to use it?
The recommended way now is to use ONNX Runtime https://github.com/microsoft/onnxruntime for inference, it has first-class support for ONNX.

"strip" onnx graph from its constants (initializers)

I have an onnx graph/model that has big constants in it, so it is taking a lot of time to load it and parse it. Can I "strip" the data from the graph, so I inspect the graph nodes without its data ?
Initializer is one of the field in GraphProto. You should be able to clear initializer field with simple python script. I haven't tested the following code but should be something like this:
import onnx
def clear_initializer(model_path):
model = onnx.load_model(model_path)
model.graph.ClearField('initializer')
onnx.save_model(model)
references:
https://developers.google.com/protocol-buffers/docs/reference/python/google.protobuf.message.Message-class
https://github.com/onnx/onnx/blob/2e7099ee7c37b196c197c9a084a97698a41da232/onnx/init.py

"numpy.ndarray' object has no attribute 'get_support" error message after running SelectKBest in Scikit Learn

I met a question related to this old one: The easiest way for getting feature names after running SelectKBest in Scikit Learn
When trying to use "get_support()" to get the selected features, I got the error message:
numpy.ndarray' object has no attribute 'get_support
I would greatly appreciate your kind help!
Jeff
Without doing fitting you cannot get support. You need to do the fitting so that the selector can analyze the data, and then call get_support() on the selector, not the output of fit_transform()
Currently you are doing something like:
selector = SelectKBest()
#fit_transform returns the data after selecting the best features
new_data = selector.fit_transform(old_data, labels)
#so you are trying to access get_support() on new data, which is not possible
new_data.get_support()
After you call fit() or fit_transform(), do this:
# get_support is a method of SelectKBest class
selector.get_support()
I think I found out the reason why I got the errors. I used "get_support()" on the results after fit() or fit_transform(), which led to the error message.
I should have used the "get_support()" on the selector itself (but still need to use selector to do fit() or fit_transform() first).
Thanks!
Jeff

getting error while running fancyRpart command

Please help me
I am not able plot using fancyRpart command though I have installed rattle and other dependency like RGtk2,rpart.plot& rpart.
I am using R version 3.4.2 (2017-09-28) on windows 10 getting following error
set.seed(123456)
modelFit<-train(classe ~.,method="rpart", data=TrainSet)
fancyrpartPlot(modelFit)
Error: the object passed to prp is not an rpart object
In addition: Warning message:
In max(model$frame$yval) : no non-missing arguments to max; returning -Inf
Please do provide complete reproducible exapmles otherwise we have to guess.
I think you are using caret::train(). This returns an object of class "train", not the actual final model but it does encapsulate the model and much more meta data: see ?caret::train.
Try:
fancyRpartPlot(modelFit$finalModel)
A reproducible example:
library(caret)
library(rattle)
modelFit<-train(Species ~., method="rpart", data=iris)
fancyRpartPlot(modelFit$finalModel)

Resources