3

I built a neural network for a multiclass classification in Keras and need to export it to a PMML file. I'm aware of the keras2pmml package, but unfortunately this only support binary classification problems.

My code:

modelnew2 = Sequential()

# Add the first layer
modelnew2.add(Dense(output_dim=9, activation='tanh',input_shape=(12,)))
modelnew2.add(Dense(output_dim=8, input_dim=9, activation='tanh'))

# Add the output layer
modelnew2.add(Dense(5, activation='softmax'))

# Compile the model !!!! Sinds je met declining learning rate werkt, ga je wel vooruit. Hierop zou je verder kunnen 
#met hyperparameter tuning
#sgd = SGD(lr=0.01)  
learning_rate = 0.2
epochs=20
decay_rate = learning_rate / epochs
Adam(lr=learning_rate, beta_1=0.9, beta_2=0.999, epsilon=None, decay=decay_rate, amsgrad=False)
modelnew2.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])

When running keras2pmml, you get Keyerror: 'softmax' as he doesn't support multiclass classification model conversions to pmml.

How can I export my Keras model to pmml ?

Ioannis Nasios
  • 8,292
  • 4
  • 33
  • 55

0 Answers0