Is SoftMax function supported by CubeMx-AI?
I am building CNN model on TensorFlow and after that I generate C code for STM32 micro using CubeMX-AI.
Here's my model
model = models.Sequential()
model.add(layers.Conv2D(32, (3, 3), activation='relu', input_shape=(32, 32,1)))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(64, (3, 3), activation='relu'))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(64, (3, 3), activation='relu'))
model.add(layers.Flatten())
model.add(layers.Dense(32, activation='relu'))
model.add(layers.Dense(4))I tested it on micro controller and get good results.
here's the result of the 4 classes when input belongs to 3rd class
Output =-9.430237
Output =-7.165620
Output =1.203057
Output =-10.133130
but in order to get the probability I added SoftMax classifier to the last layer, here's the new model
model = models.Sequential()
model.add(layers.Conv2D(32, (3, 3), activation='relu', input_shape=(32, 32,1)))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(64, (3, 3), activation='relu'))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(64, (3, 3), activation='relu'))
model.add(layers.Flatten())
model.add(layers.Dense(32, activation='relu'))
model.add(layers.Dense(4, activation='softmax'))
after testing the modified model, results are OK for 3 classes -1st,2nd and 4th class- but I get wrong results for the 3rd class.
here's the output of the 4 classes while using input of the 3rd class
Output =0.523477
Output =0.476523
Output =0.000000
Output =0.000000according to my understanding the SoftMax is just exp(out_i)/sum(exp(out_j)) and the results Should be

am I doing something wrong or do I understand SoftMax function mistakenly ?
or there's something wrong in my tensorflow model?
