Code Monkey home page Code Monkey logo

Comments (9)

Craigacp avatar Craigacp commented on June 5, 2024

Tribuo needs to know what the mapping is from the feature names it produces to the feature indices that the ONNX model expects. If your model expects a feature vector (rather than an image or some other kind of structured input) then you need to pass in a DenseTransformer to the ONNXExternalModel, along with the string -> int mapping. The feature names are user controlled in some senses, they either come from the headers/field names of the csv/db/json data, or are constructed as the string representation of padded indices (i.e. 000, 001 etc).

For your example with a feature vector of [2][7] is that a batch size of 2 and a 7 element feature vector?

from tribuo.

paranjapeved15 avatar paranjapeved15 commented on June 5, 2024

Yes @Craigacp, the 2 is a batch. So it really needs a float array with 7 elements as input.

from tribuo.

Craigacp avatar Craigacp commented on June 5, 2024

Ok, so you'd want to make a Tribuo example containing those 7 features, with appropriate names. Those can be semantic ones if the features actually have names, or just 00,...,06, then supply the mapping as appropriate.

from tribuo.

paranjapeved15 avatar paranjapeved15 commented on June 5, 2024

okay, but what about the key "input" do I not need that in tribuo?

from tribuo.

Craigacp avatar Craigacp commented on June 5, 2024

It's the last argument when constructing an ONNXExternalModel - https://tribuo.org/learn/4.3/javadoc/org/tribuo/interop/onnx/ONNXExternalModel.html#createOnnxModel(org.tribuo.OutputFactory,java.util.Map,java.util.Map,org.tribuo.interop.onnx.ExampleTransformer,org.tribuo.interop.onnx.OutputTransformer,ai.onnxruntime.OrtSession.SessionOptions,java.nio.file.Path,java.lang.String).

from tribuo.

paranjapeved15 avatar paranjapeved15 commented on June 5, 2024

Oh I see. And at inference time what should be the format of my input? What type of object and what function should I be using to run inference on the Model object? @Craigacp

from tribuo.

Craigacp avatar Craigacp commented on June 5, 2024

The model exposes a predict function which accepts Iterable<Example<T>> or Example<T>, returning Prediction<T> which contains the predicted values and any confidence scores produced by the model.

from tribuo.

paranjapeved15 avatar paranjapeved15 commented on June 5, 2024

Any code example which shows how to build an Example object from raw values?

from tribuo.

Craigacp avatar Craigacp commented on June 5, 2024

Not specifically, but you can see how the examples are built in all the DataSource implementations, e.g. this one for loading in LibSVM format data - https://github.com/oracle/tribuo/blob/main/Core/src/main/java/org/tribuo/datasource/LibSVMDataSource.java#L348.

from tribuo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.