autonomio / talos

Hyperparameter Experiments with TensorFlow and Keras
https://autonom.io
MIT License
1.62k stars 270 forks source link

'TrainingLog' object has no attribute '_implements_train_batch_hooks' #498

Closed ghost closed 2 years ago

ghost commented 3 years ago

66 ## 1) Confirm the below

2) Include the output of:

talos.__version__ - 1.0.0

3) Explain what actually happened

I am trying to perform hyperparameter tuning using the TextCNN model and the IMDB Dataset on Colab. I followed the steps mentioned in one of the example notebooks on how to set up the required parameter space and run talos using the Scan() function.

The problem is when I try to execute the following statement:

t = talos.Scan(x=X_train, y=y_train, model=build_model, params=p, experiment_name='sentiment_analysis', fraction_limit = 0.1)

I am getting the following error message:

AttributeError: 'TrainingLog' object has no attribute '_implements_train_batch_hooks'

5) Provide a code-complete reference

Input model:

image

Parameter dictionary:

# then we can go ahead and set the parameter space p = {'batch_size': [32, 64], 'epochs': [50, 100], 'kernel_initializer': ['uniform', 'normal', 'glorot_uniform', 'he_normal'], 'optimizer': ['SGD', 'RMSprop', 'Adagrad', 'Adadelta', 'Adam', 'Adamax', 'Nadam'], 'activation':['relu', 'elu'], }

Please help me out with this. Am I doing something wrong? Also, how can I make use of the GPU/TPU facility provided in Colab. When I try to run the code using talos, it is using CPU and not GPU.

github-actions[bot] commented 3 years ago

Welcome to Talos community! Thanks so much for creating your first issue :)

fabero commented 3 years ago

Hi @shaksham-4176, I ran into this issue as well.

As with many strange Tensorflow errors, this was caused by mixing tensorflow.keras with keras.

It appears that talos is using keras, so replacing all occurences of from tensorflow.keras import ... with from keras import ... in your code will probably fix your issue (assuming you have standalone Keras installed).

mikkokotila commented 3 years ago

In Talos 1.0 onwards all imports should be already handled through tf.

mikkokotila commented 3 years ago

Closing this as resolved, feel free to open new issue if anything :)

rsouza commented 3 years ago

In Talos 1.0 onwards all imports should be already handled through tf.

Is it already working like this? I am still having the same problem (Talos 1.0, TensorFlow 2.3.1, no standalone Keras) Thanks for the attention.

mikkokotila commented 3 years ago

This is a known issue in an underlying package Astetik.

Will have to fix it there.

mikkokotila commented 2 years ago

This has now been fixed in the underlying dependency. Closing here.