CSIM Inference Output Discrepancy
Created by: veyron8800
Hello,
I am running into an issue where HLS4ML model inference output from CSIM does not match what is produced by using tf.keras. I have compiled the model into this repository, so that the bug can be easily reproduced.
The model in question is a simplistic CNN with the following architecture:
model = models.Sequential()
model.add(layers.Conv2D(4, (3, 3), activation='relu', input_shape=(28, 28, 1)))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(8, (3, 3), activation='relu'))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(16, (3, 3), activation='relu'))
model.add(layers.Flatten())
model.add(layers.Dense(16, activation='relu'))
model.add(layers.Dense(10, activation='softmax'))
Unfortunately, the inference output on the test image set for the csim of the hls4ml model is nowhere close to what is produced by tf.keras. The thing that really caught my eye is the hls4ml output is that there are values that exceed the bounds of [0,1], when the final layer has a softmax activation. This suggests to me that the problem is most likely with the cpp definition of the softmax function.
Here are some more links to the example repo for convenience: Model creation and training: ModelTraining.py Config file: DC.yml Inference output generation: InferenceComp.py Inference output: InferenceComp
Thanks