tensorflow / adanet

Fast and flexible AutoML with learning guarantees.
https://adanet.readthedocs.io
Apache License 2.0
3.47k stars 529 forks source link

Adding different loss to tf.estimator.Head #149

Open le-dawg opened 4 years ago

le-dawg commented 4 years ago

Hi all,

I seek to optimize an ensemble for binary classification. My established baseline uses the binary_crossentropy loss provided by keras. Using the same notation yields unsupported callable, because it seems the base_head.Head()does not tie into the default tf implementation.

What can I do train with the binary crossetropy?

cweill commented 4 years ago

Have you tried tf.estimator.BinaryClassHead()? I believe it uses the same loss under the hood, specifically sigmoid_cross_entropy.

le-dawg commented 4 years ago

Well, I figured that out in the meantime. But a problem persists: BinaryClassHead It uses the correct loss but when I predict using a simple_dnn AdaNet of three iterations via estimator.predict() the network always predicts with class 0.

The same head works on the canned tf.estimator.LinearClassifier which I would suspect to be a problem regarding an incorrect loss function. I can't troubleshoot the AdaNet estimator any deeper than this. I will take any help I can!