Coder Social home page Coder Social logo

Comments (2)

seanmor5 avatar seanmor5 commented on May 29, 2024 1

Ahh that makes sense - sorry for the easy question! Thank you so much, this is exactly what I needed! I am glad you enjoyed the book :)

from protox.

ahamez avatar ahamez commented on May 29, 2024

Hello! I'm glad to know that you found the library easy to use :-)

The output you got is expected: protox outputs IO data, a data structure to optimize the generation of large volumes of data.
All output functions should be able to take this kind of data as a parameter. In your case, if you want to write encoded to a file:

iex> data = File.read!("resnet18-v1-7.onnx")
iex> decoded = Onnx.ModelProto.decode!(data)
iex> encoded = Onnx.ModelProto.encode!(decoded)
iex> {:ok, file} = File.open("msg.bin", [:write])
iex> IO.binwrite(file, encoded)

If you want a good old binary, use :binary.list_to_bin():

iex> encoded = decoded |> Onnx.ModelProto.encode!() |> :binary.list_to_bin()
<<8, 3, 58, 244, 218, 169, 22, 10, 172, 1, 10, 4, 100, 97, 116, 97, 10, 22, 114,
  101, 115, 110, 101, 116, 118, 49, 53, 95, 99, 111, 110, 118, 48, 95, 119, 101,
  105, 103, 104, 116, 18, 19, 114, 101, 115, 110, 101, 116, 118, 49, ...>>
iex>  data == encoded
true

Does this answer your question?

BTW, I really enjoyed your book on genetic algorithms, and congrats for your work on Nx ;-)

from protox.

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.