tensorflow / adanet

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

[Bug] AutoEnsembleEstimator() cannot be instatiated if tf< 2.x #154

Open le-dawg opened 4 years ago

le-dawg commented 4 years ago

Intent: I am following the code sample given by @cweill and given in the docs v0.8.0 to instatiate an AutoEnsembleEstimator() with the simplest use case of one candidate.

Error: The given object is not an Optimizer instance. Given: <tensorflow.python.keras.optimizer_v2.rmsprop.RMSprop object at 0x7fd6f61ca160> Minimal reproducible example HERE Call context:

candmax_iteration_steps = TRAIN_STEPS // ADANET_ITERATIONS

# Learn to ensemble linear and DNN models.
adaestimator = adanet.AutoEnsembleEstimator(
    head=head,
    candidate_pool=lambda config: {
        "linearest":
            tf.estimator.LinearEstimator(
                head=head,
                feature_columns=feature_columns,
                optimizer = lambda: tf.compat.v2.optimizers.RMSprop(),
                config=make_config("ada_linearest"))},max_iteration_steps=candmax_iteration_steps)

Details: The same error occurs when

The error, possibly, lies within .../tensorflow_estimator/python/estimator/head/base_head.py. The check for compatibility appears broken. Not sure if this is still an issue within AdaNet. lambda trick

cweill commented 4 years ago

@le-dawg We just released adanet v0.9.0 which drops TF 1.* support. Could you please try upgrading adanet to the latest version?