I'm trying to output a trained Tensorflow 2.0 model to PMML using the nyoka package. When I do so, it errors out. The problem seems to be different from that in this answer, even though the error is the same, because my model does not have a complicated creation function and does, in fact, train appropriately and transform appropriately.
def create_and_train(x_training,y_training,n_cols_in,modelparams):
layers = [tf.keras.layers.Dense(n_cols_in,activation="relu"),
tf.keras.layers.Dropout(.5)]
for param in modelparams:
layers.extend([tf.keras.layers.Dense(param,activation="sigmoid"),tf.keras.layers.Dropout(.5)])
layers.append(tf.keras.layers.Dense(1,activation="sigmoid"))
model = tf.keras.models.Sequential(layers)
model.compile(optimizer='adam', loss='binary_crossentropy', metrics=[tf.keras.metrics.AUC()])
model.fit(x_training, y_training, epochs = epochs)
with open("NN"+"_".join([str(m) for m in modelparams])+".pmml","w") as pmml_file:
pmml = KerasToPmml(model)
pmml.export(pmml_file)
Instead of a PMML file, I'm getting
AttributeError: The layer has never been called and thus has no defined input shape.