{
 "schema_version": 1,
 "generated": "2026-10-26",
 "id": "mattn-tensai--export-trained-model-to-onnx",
 "repo": "mattn/tensai",
 "repo_url": "https://github.com/mattn/tensai",
 "repo_slug": "mattn-tensai",
 "title": "Export a trained Sequential model to ONNX",
 "page_title": "How to export a trained Sequential model to ONNX with Tensai",
 "summary": "Train a Sequential model in Tensai, then marshal it to ONNX with the encoding/onnx package.",
 "who": "A developer who trains a small model in Go and needs to run it in onnxruntime or another ONNX consumer.",
 "problem": "Trained Go models are stuck in Go unless they can be exported to a standard format.",
 "outcome": "An ONNX file (opset 13, FP32) whose outputs match Tensai Predict to about 1e-7 relative error.",
 "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."
 ],
 "agent_prompt": "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.",
 "agents": [
  "any"
 ],
 "difficulty": "Advanced",
 "time": "90 minutes",
 "basis": "readme",
 "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.",
 "category": "Software and DevOps",
 "tags": [
  "Software and DevOps"
 ],
 "lang": "go",
 "requirements": [
  "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"
 ],
 "risk": "none",
 "seen_in_the_wild": false,
 "mentioned_publicly": false,
 "risks": [],
 "best": false,
 "score": 0.7,
 "evidence": [],
 "url": "https://dedupedai.com/use-cases/mattn-tensai/export-trained-model-to-onnx/",
 "md": "https://dedupedai.com/use-cases/mattn-tensai/export-trained-model-to-onnx/index.md",
 "disclaimer": "Deduped lists open-source repositories that belong to other people. We do not own, maintain, audit, or vouch for any of them, and a repo appearing here is not an endorsement or a safety check. The use cases, steps, and prompts are written by AI and may be incomplete, outdated, or just wrong. Where a use case is marked \"Seen in the wild\", we link to public posts where someone described something similar, but we have not verified those posts and the use case itself is still our AI's own write-up. Use all of this at your own risk. Only run code, commands, or agents on systems and accounts you are authorized to use, and read the code and every command before you run it, especially anything that touches credentials, files, or the network. Nothing here is professional, security, legal, or financial advice. All trademarks and project names belong to their respective owners, and their use here does not imply affiliation. Content is provided as is, without warranties of any kind. Found a mistake, a safety problem, or something you want removed? Email hello@dedupedai.com and we will look at it promptly.",
 "api": "https://dedupedai.com/api/v1/usecases/mattn-tensai--export-trained-model-to-onnx.json",
 "api_version": "v1"
}
