Qkeras for CNN

199 views
Skip to first unread message

Mahdieh Grailoo

unread,
Dec 11, 2020, 9:27:43 AM12/11/20
to hls4m...@gmail.com
Dear HLS4ML help,

I defined a quantized CNN as follows:
model = Sequential()    
model.add(QConv2D(filters=12, kernel_size=(3, 3), input_shape=(28, 28, 1),
                  kernel_quantizer=quantized_bits(q,0,alpha=1), bias_quantizer=quantized_bits(q,0,alpha=1),
                 kernel_initializer='lecun_uniform', kernel_regularizer=l1(0.0001)))
model.add(QActivation(activation=quantized_relu(q), name='relu1'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.3))
model.add(Flatten())
model.add(QDense(10, name='output',
                 kernel_quantizer=quantized_bits(q,0,alpha=1), bias_quantizer=quantized_bits(q,0,alpha=1),
                 kernel_initializer='lecun_uniform', kernel_regularizer=l1(0.0001)))
model.add(Activation(activation='softmax', name='softmax'))

And adjust yml file as follows:

config = hls4ml.utils.config_from_keras_model(model, granularity='name')
config['Model'] = {'Precision' : 'ap_fixed<16,6>','ReuseFactor':2028, 'Strategy':'Resource'}

config['LayerName']['softmax']['exp_table_t'] = 'ap_fixed<12,8>'
config['LayerName']['softmax']['inv_table_t'] = 'ap_fixed<12,4>'
config['LayerName']['max_pooling2d']['Precision'] = 'ap_fixed<6,1>'
config['LayerName']['q_conv2d']['ReuseFactor'] = 54 #112
config['LayerName']['output']['ReuseFactor'] = 2028 #128

When I tried to compile hls_model, hls_model.compile(), I received the following error:

OSError: firmware/myproject-bE8FaBde.so: cannot open shared object file: No such file or directory

Would you please guide me how I could solve the problem?

Thanks in advance,
Regards,

 

--
Mahdieh Grailoo,
School of Electrical and Computer Engineering
University of Tehran
Email: mgra...@ut.ac.ir

Mahdieh Grailoo

unread,
Jan 2, 2021, 10:22:44 PM1/2/21
to hls4ml help
the error on Linux:
 
../../../../firmware/myproject.cpp:68:65: error: no matching function for call to 'pooling2d_cl(layer4_t [8112], layer5_t [2028])'
     nnet::pooling2d_cl<layer4_t, config5>(layer4_out, layer5_out);
Reply all
Reply to author
Forward
0 new messages