GithubHelp home page GithubHelp logo

Export quantized model about distiller HOT 5 CLOSED

cattpku avatar cattpku commented on May 22, 2024
Export quantized model

from distiller.

Comments (5)

nzmora avatar nzmora commented on May 22, 2024

Hi @cattpku,

We're waiting for the ONNX quantization standard, before supporting ONNX export of quantized models. See #23 for some discussion.
You can export a non-quantized model to ONNX using --summary=onnx.
Cheers
Neta

from distiller.

cattpku avatar cattpku commented on May 22, 2024

Hi Neta,
I tried to export a non-quantized model to ONNX as advised, however, got a RuntimeError 'ONNX export failed: Couldn't export operator aten::softmax'.

I know this layer is added in Distiller, and I checked the corresponding 'torch/onnx/symbolic.py', the 'softmax' definition is there.

After checking Pytorch 0.4.0 doc, for 'torch.onnx' it stated 'softmax (only dim=-1 supported)', while in 'model_summaries.py', it is 'softmax = torch.nn.Softmax(dim=1)'.

Can you kindly advise? Thanks.

from distiller.

nzmora avatar nzmora commented on May 22, 2024

Hi @cattpku ,

Please share your command-line, so I can try to recreate this problem.
I think that using

softmax = torch.nn.Softmax(dim=-1)

is probably more correct, but I want to see why it fails for you before making changes to the code.

BTW, you can also try to change it to -1 and report if this fixes the fail you see.

Thanks
Neta

from distiller.

cattpku avatar cattpku commented on May 22, 2024

Hi Neta,
I am not using command-line, as I put the whole code in Pycharm to run it. I just set the following args:
--data: my own dataset path
--arch: my own network definition
--summary: default = 'onnx'

I tried to change it to -1 as suggested, it went well, no error occurred.

from distiller.

nzmora avatar nzmora commented on May 22, 2024

Thanks, for classification tasks the softmax input has shape==(1, num_classes) so

softmax = torch.nn.Softmax(dim=1)

and

softmax = torch.nn.Softmax(dim=-1)

are the same. But as you point out, for the general case we should follow the PyTorch ONNX limitations.

from distiller.

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.