Keras network executor output for class predictions

Hi all,
I adapted the example workflow for image-classification with the keras integration but for multiple classes, such that my output is an array of the N class probabilities returned by a softmax layer.

It works fine but for prediction I get the probabilities as either a collection column (see below with N=2 classes, the collection column next to the ground truth Inflated/Elongated) or as separate columns called Probabilities.

image

The probabilities are ordered according to the order of columns fed to the corresponding trainer as far as I understood, but I was wondering if there is a more straightforward way to recover the names of the class and the associated probabilities.
Like for other predictor nodes like random forest… which yield columns named like p(class1)

I know it’s not as straightforward since the keras network executor needs to account for all possible kind of output and scenario.

Also the example here is for N=2 classes which I could classify as in the example workflow with a sigmoid layer instead but the workflow is designed to accept any number of classes, hence the softmax.

Hi @l.thomas,

unfortunately, the Keras Network Executor is currently only able to provide the direct output of the network without post processing, i.e. a softmax vector in this case. As you already stated, this means one has to map them to class names manually. One way to do it is using the Column Expression node. If you configured the Keras Network Executor to output a collection you can use the argmax and max functions of the Column Expression node to recover the index and the probability. Then to get actual class names, you need the initial mapping of the names and their index in a separate table. This can then be joined with the argmax index of the softmax output. I created a little example based on the MNIST classification example. This should work with any number of classes.

I hope that helps.

Cheers,
David

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.