Git Product home page Git Product logo

Comments (2)

vloncar avatar vloncar commented on June 10, 2024

This is a known issue and it happens due to the optimization of 1x1 Conv1D/2D to PointwiseConv1D/2D. However, even if you anticipate that and try to change the layers parameter to include PointwiseConv1D (or the name of the layer, q_conv1d) it won't affect the outcome due to the order in which the optimizers are applied. I hope to get rid of the output_rounding_saturation_mode in the future as this was a workaround to increase the compatibility with QKeras when we didn't have enough flexibility with other optimizers.

A solution that I suggest in this case is to change the hls_config that you pass to the converter. In your example that could be:

config = hls4ml.utils.config_from_keras_model(model, granularity='name')
config['LayerName']['q_conv1d']['Precision']['result'] = 'fixed<16,6, RND_CONV, SAT>'

You can do this for other layers as well and avoid using the optimizer at all. To avoid guessing the name of the layer, you can name them in Keras, a nice practice regardless. Similar can be achieved with granularity='type' if you want to type less, that would be a more direct equivalent to what you were doing with the optimizer.

from hls4ml.

qberthet avatar qberthet commented on June 10, 2024

Thanks @vloncar, this is helpful.

I forgot to mention in the issue that I am already explicitly defining the precision for each named layer as a workaround (I my project, not in this example code). Setting the default precision to fixed<16,6, RND_CONV, SAT> also works but is even less flexible than the optimizer pass.

I noticed the conversion of 1x1 Conv1D/2D to PointwiseConv1D/2D, but looking at this optimizer code I don't understand why the initial precision is not transferred to the new layer and this appeared to me as a bug. But I agree that it is not that important once known (Maybe could be mentioned in the doc/code/tutorial?) as the optimizer pass is useful during exploration when the model structure is changing a lot, less when the structure is fixed and explicit layer config can be defined.

IMO this issue can be closed if there is plan for a better solution in the future.

from hls4ml.

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.