Who it is forA developer who trains a small model in Go and needs to run it in onnxruntime or another ONNX consumer.
The problemTrained Go models are stuck in Go unless they can be exported to a standard format.
The outcomeAn ONNX file (opset 13, FP32) whose outputs match Tensai Predict to about 1e-7 relative error.
What you need first
- Go toolchain (Go 1.26 or 1.27 is needed only for the GOEXPERIMENT=simd build)
- git to clone the repository
- Disk space for model checkpoints when using the image, audio, or embedding commands
Steps
- Build a small Sequential model from the layer package and train it with Compile and Fit. (inferred, check the README)
- Call the marshal function in the encoding/onnx package on the trained model and write the bytes to a .onnx file. (inferred, check the README)
- Load the file in onnxruntime and run the same input through it. (inferred, check the README)
- Compare the onnxruntime output with Predict on the same input and confirm the relative error is near 1e-7.
Prompt for your agent
In the mattn/tensai repository, train a small Sequential model, export it with encoding/onnx, and run the file in onnxruntime. Report the maximum relative error between Predict and onnxruntime outputs. Verify that the error is about 1e-7 or below.
Caveat. The README says onnxruntime reproduces Predict to about 1e-7 relative error but does not name the exact marshal function, so the function call above is inferred.
Use this in your AI agent
Ask your agent
Using the Deduped MCP, get the setup steps for mattn/tensai and "Export a trained Sequential model to ONNX"
Add Deduped to Claude Code once
claude mcp add --transport http deduped https://dedupedai.com/mcp
Every Monday: the 5 hottest repos and exactly how to use them. Free, one email a week, unsubscribe anytime.
Get them freeShare: X LinkedIn Hacker News Email Copy link
Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer