Open
Description
In the official example ”part6_cnns“(https://github.com/fastmachinelearning/hls4ml-tutorial/blob/main/part6_cnns.ipynb), I used keras and qkeras to train the model, and after converting it using the "Vitis" backend, I got the correct prediction results. Then, when I switched to the "Vivado" backend, the keras model still performed correctly, but the qkeras model conversion went wrong and the accuracy was significantly reduced.
Here is part of transform code:
# First, the baseline model
hls_config = hls4ml.utils.config_from_keras_model(
model, granularity='name', backend='Vivado', default_precision='ap_fixed<16,6>'
)
hls_config['Model']['Strategy'] = 'Resource'
plotting.print_dict(hls_config)
hls_model = hls4ml.converters.convert_from_keras_model(
model,
hls_config=hls_config,
# backend='Vitis',
backend='Vivado',
output_dir='model_1/hls4ml_prj',
part='xcu250-figd2104-2L-e',
io_type='io_stream',
)
hls_model.compile()
# Then the QKeras model
hls_config_q = hls4ml.utils.config_from_keras_model(qmodel, granularity='name', backend='Vivado')
hls_config_q['Model']['Strategy'] = 'Resource'
plotting.print_dict(hls_config_q)
hls_model_q = hls4ml.converters.convert_from_keras_model(
qmodel, hls_config=hls_config_q, output_dir='quantized_pruned_cnn', backend='Vivado', io_type='io_stream'
)
hls_model_q.compile()
ROC Plotting results:
Accuracy Keras: 0.8876666666666667
Accuracy hls4ml: 0.887
Accuracy Keras: 0.834
Accuracy hls4ml: 0.19966666666666666

