Giter VIP home page Giter VIP logo

Comments (7)

jmitrevs avatar jmitrevs commented on May 27, 2024

It it possible to put the model somewhere or paste a script to create a simple untrained model that has the same issue?

from hls4ml.

zsrabbani avatar zsrabbani commented on May 27, 2024

rf_in = Input(shape=(1024, 2), name = 'rf_input')

x = QConv1D(64, 5, kernel_quantizer="quantized_bits(16,6)", padding='same', use_bias=False)(rf_in)
x = QBatchNormalization()(x)
x = QActivation("quantized_relu(16,6)")(x)
x = MaxPooling1D(2, strides = 2, padding='same') (x)

x = QConv1D(32, 5, kernel_quantizer="quantized_bits(16,6)", padding='same', use_bias=False)(x)
x = QBatchNormalization()(x)
x = QActivation("quantized_relu(16,6)")(x)
x = MaxPooling1D(2, strides = 2, padding='same') (x)

x = QConv1D(16, 5, kernel_quantizer="quantized_bits(16,6)", padding='same', use_bias=False)(x)
x = QBatchNormalization()(x)
x = QActivation("quantized_relu(16,6)")(x)
x = MaxPooling1D(2, strides=2, padding='same') (x)

x = Flatten()(x)

dense_1 = QDense(128, activation="quantized_relu(16,6)", use_bias=False)(x)
dropout_1 = Dropout(0.25)(dense_1)
dense_2 = QDense(128, activation="quantized_relu(16,6)", use_bias=False)(dropout_1)
dropout_2 = Dropout(0.5)(dense_2)
softmax = QDense(7, kernel_quantizer="quantized_bits(16,6)", use_bias=False)(dropout_2)
softmax = Activation('softmax')(softmax)

opt = keras.optimizers.Adam(learning_rate=0.0001)
model= keras.Model(rf_in, softmax)
model.compile(loss='categorical_crossentropy', optimizer=opt, metrics=["accuracy"])
model.summary()

from hls4ml.

jmitrevs avatar jmitrevs commented on May 27, 2024

I think I understand the problem. The hls4ml software assumes that QDense will always have kernel_quantizer defined, but that is not the case here. I will add a check for it, but in the meantime, here is a workaround. Replace:

dense_1 = QDense(128, activation="quantized_relu(16,6)", use_bias=False)(x)

by

dense_1_noact = Dense(128, use_bias=False)(x)
dense_1 = QActivation(activation="quantized_relu(16,6)")(dense_1_noact)

from hls4ml.

jmitrevs avatar jmitrevs commented on May 27, 2024

Try using https://github.com/fastmachinelearning/hls4ml/tree/weight_quantizer_none

from hls4ml.

zsrabbani avatar zsrabbani commented on May 27, 2024

I think I understand the problem. The hls4ml software assumes that QDense will always have kernel_quantizer defined, but that is not the case here. I will add a check for it, but in the meantime, here is a workaround. Replace:

dense_1 = QDense(128, activation="quantized_relu(16,6)", use_bias=False)(x)

by

dense_1_noact = Dense(128, use_bias=False)(x)
dense_1 = QActivation(activation="quantized_relu(16,6)")(dense_1_noact)

I added the two code line to my code, but still the same error. nothing change.

dense_1 = Dense(128, use_bias=False)(x)
dense_1 = QActivation("quantized_relu(16,6)")(dense_1)
dropout_1 = Dropout(0.25)(dense_1)
dense_2 = Dense(128, use_bias=False)(dropout_1)
dense_2 = QActivation("quantized_relu(16,6)")(dense_2)
dropout_2 = Dropout(0.5)(dense_2)
softmax = Dense(7, use_bias=False)(dropout_2)
softmax = QActivation("quantized_relu(16,6)")(softmax)
output = Activation('softmax')(softmax)

from hls4ml.

zsrabbani avatar zsrabbani commented on May 27, 2024

Even I installed hls4ml library again and still same error.

from hls4ml.

johanjino avatar johanjino commented on May 27, 2024

+1 Same issue when using QKeras layers (QLSTM)

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.