question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Keras Progress Bar broken when importing kerastuner

See original GitHub issue

Looks like importing kerastuner into a trivial keras proj causes the progress bar to not overwrite each update:-

`import tensorflow as tf import tensorflow_addons as tfa

from tensorflow.keras.datasets import mnist from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense from tensorflow.keras.optimizers import SGD

#import kerastuner as kt

(x_train, y_train), (x_test, y_test) = mnist.load_data() x_train, x_test = x_train / 255.0, x_test / 255.0

model_keras_static = Sequential()
model_keras_static.add(Dense(512, input_dim=784, activation=‘sigmoid’)) model_keras_static.add(Dense(128, activation=‘sigmoid’)) model_keras_static.add(Dense(10, activation=‘softmax’))

model_keras_static.compile(loss=‘sparse_categorical_crossentropy’, metrics=[‘accuracy’], optimizer=SGD(learning_rate=0.1)) model_keras_static.fit(x_train.reshape(x_train.shape[0], 784), y_train, batch_size=1000, epochs=2, verbose=1)`

Train on 60000 samples Epoch 1/2 60000/60000 [==============================] - 2s 29us/sample - loss: 2.2526 - accuracy: 0.2699 Epoch 2/2 60000/60000 [==============================] - 1s 25us/sample - loss: 2.1220 - accuracy: 0.5087 <tensorflow.python.keras.callbacks.History at 0x1eb9e9f9408>

However if I uncomment the kerastuner import the output no longer overwrites

Train on 60000 samples Epoch 1/2 60000/60000 [==============================] - ETA: 12s - loss: 2.6233 - accuracy: 0.115 - ETA: 2s - loss: 2.3653 - accuracy: 0.102 - ETA: 1s - loss: 2.3288 - accuracy: 0.12 - ETA: 0s - loss: 2.3130 - accuracy: 0.12 - ETA: 0s - loss: 2.3037 - accuracy: 0.14 - ETA: 0s - loss: 2.2962 - accuracy: 0.17 - ETA: 0s - loss: 2.2882 - accuracy: 0.18 - ETA: 0s - loss: 2.2811 - accuracy: 0.20 - ETA: 0s - loss: 2.2743 - accuracy: 0.21 - ETA: 0s - loss: 2.2680 - accuracy: 0.23 - ETA: 0s - loss: 2.2618 - accuracy: 0.24 - 1s 13us/sample - loss: 2.2607 - accuracy: 0.2506 Epoch 2/2 60000/60000 [==============================] - ETA: 0s - loss: 2.1928 - accuracy: 0.40 - ETA: 0s - loss: 2.1914 - accuracy: 0.44 - ETA: 0s - loss: 2.1852 - accuracy: 0.42 - ETA: 0s - loss: 2.1791 - accuracy: 0.45 - ETA: 0s - loss: 2.1721 - accuracy: 0.45 - ETA: 0s - loss: 2.1650 - accuracy: 0.46 - ETA: 0s - loss: 2.1577 - accuracy: 0.47 - ETA: 0s - loss: 2.1507 - accuracy: 0.48 - ETA: 0s - loss: 2.1420 - accuracy: 0.48 - ETA: 0s - loss: 2.1332 - accuracy: 0.49 - 1s 9us/sample - loss: 2.1293 - accuracy: 0.4950 <tensorflow.python.keras.callbacks.History at 0x196d7342408>

Any suggestions ?

absl-py==0.9.0 argon2-cffi @ file:///C:/ci/argon2-cffi_1596828549974/work astor==0.8.0 attrs==19.3.0 backcall==0.2.0 bleach==3.1.5 blinker==1.4 brotlipy==0.7.0 cachetools @ file:///tmp/build/80754af9/cachetools_1596822027882/work certifi==2020.6.20 cffi==1.14.0 chardet==3.0.4 click==7.1.2 colorama==0.4.3 cryptography==2.9.2 cycler==0.10.0 decorator==4.4.2 defusedxml==0.6.0 entrypoints==0.3 future==0.18.2 gast==0.2.2 google-auth @ file:///tmp/build/80754af9/google-auth_1596863485713/work google-auth-oauthlib==0.4.1 google-pasta==0.2.0 grpcio==1.27.2 h5py==2.10.0 idna @ file:///tmp/build/80754af9/idna_1593446292537/work importlib-metadata @ file:///C:/ci/importlib-metadata_1593446525189/work ipykernel @ file:///C:/ci/ipykernel_1596208728219/work/dist/ipykernel-5.3.4-py3-none-any.whl ipython @ file:///C:/ci/ipython_1596868620883/work ipython-genutils==0.2.0 ipywidgets==7.5.1 jedi==0.15.2 Jinja2==2.11.2 joblib @ file:///home/conda/feedstock_root/build_artifacts/joblib_1593624380152/work json5==0.9.5 jsonschema @ file:///C:/ci/jsonschema_1594363671836/work jupyter-client @ file:///tmp/build/80754af9/jupyter_client_1594826976318/work jupyter-core==4.6.3 jupyterlab==2.1.5 jupyterlab-server @ file:///tmp/build/80754af9/jupyterlab_server_1594164409481/work Keras-Applications @ file:///tmp/build/80754af9/keras-applications_1594366238411/work Keras-Preprocessing==1.1.0 keras-tuner==1.0.1 kiwisolver==1.2.0 Markdown==3.1.1 MarkupSafe @ file:///C:/ci/markupsafe_1594405949945/work matplotlib @ file:///C:/ci/matplotlib-base_1592846084747/work mistune @ file:///C:/ci/mistune_1594373272338/work mkl-fft==1.1.0 mkl-random==1.1.1 mkl-service==2.3.0 nbconvert @ file:///C:/ci/nbconvert_1594372737468/work nbformat==5.0.7 notebook @ file:///C:/ci/notebook_1596837179121/work numpy @ file:///C:/ci/numpy_and_numpy_base_1596233945180/work oauthlib==3.1.0 opt-einsum==3.1.0 packaging==20.4 pandas @ file:///D:/bld/pandas_1595958729109/work pandocfilters==1.4.2 parso @ file:///tmp/build/80754af9/parso_1596826841367/work pickleshare @ file:///C:/ci/pickleshare_1594374056827/work prometheus-client==0.8.0 prompt-toolkit==3.0.5 protobuf==3.12.3 pyasn1==0.4.8 pyasn1-modules==0.2.7 pycparser @ file:///tmp/build/80754af9/pycparser_1594388511720/work Pygments==2.6.1 PyJWT==1.7.1 pyOpenSSL @ file:///tmp/build/80754af9/pyopenssl_1594392929924/work pyparsing==2.4.7 pyreadline==2.1 pyrsistent==0.16.0 PySocks @ file:///C:/ci/pysocks_1594394709107/work python-dateutil==2.8.1 pytz==2020.1 pywin32==227 pywinpty==0.5.7 pyzmq==19.0.1 requests @ file:///tmp/build/80754af9/requests_1592841827918/work requests-oauthlib==1.3.0 rsa @ file:///tmp/build/80754af9/rsa_1596998415516/work scikit-learn @ file:///D:/bld/scikit-learn_1596546337481/work scipy @ file:///C:/ci/scipy_1592916958183/work seaborn==0.10.1 Send2Trash==1.5.0 six==1.15.0 tabulate==0.8.7 tensorboard==2.2.1 tensorboard-plugin-wit==1.6.0 tensorflow==2.1.0 tensorflow-addons==0.9.1 tensorflow-estimator==2.1.0 termcolor==1.1.0 terminado==0.8.3 terminaltables==3.1.0 testpath==0.4.4 threadpoolctl @ file:///tmp/tmp79xdzxkt/threadpoolctl-2.1.0-py3-none-any.whl tornado==6.0.4 tqdm @ file:///home/conda/feedstock_root/build_artifacts/tqdm_1596476591553/work traitlets==4.3.3 typeguard==2.9.1 urllib3==1.25.9 wcwidth @ file:///tmp/build/80754af9/wcwidth_1593447189090/work webencodings==0.5.1 Werkzeug==0.14.1 widgetsnbextension @ file:///D:/bld/widgetsnbextension_1594164533747/work win-inet-pton==1.1.0 wincertstore==0.2 wrapt==1.12.1 zipp==3.1.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
msaad1311commented, Aug 19, 2020

I am facing the similar issue. Im running my code on Jupyter Notebook. The versions which i am using are TF=2.2.0 and Keras=2.3.1

0reactions
jpodivincommented, May 2, 2021

The tensorflow API version 2.1 doesn’t seem to have that member in its namespace. https://www.tensorflow.org/versions/r2.1/api_docs/python/tf/keras/layers/experimental/preprocessing

The easiest fix would be updating your TF to a version that does. For example the 2.2. https://www.tensorflow.org/versions/r2.2/api_docs/python/tf/keras/layers/experimental/preprocessing

Read more comments on GitHub >

github_iconTop Results From Across the Web

Keras verbose training progress bar writing a new line on ...
It seems as if the info makes the bar too long for the terminal and so it breaks to a new line. So...
Read more >
Getting started with KerasTuner
In this tutorial, you will see how to tune model architecture, training process, and data preprocessing steps with KerasTuner.
Read more >
Release 3.15.1 Gev Sogomonian, Gor Arakelyan et al. - Aim
20 Log messages during training process ... It only takes 2 steps to easily integrate aim in keras to record experimental information.
Read more >
4. Model Training Patterns - Machine Learning Design ...
You can implement transfer learning in Keras using one of these two methods: Loading a pre-trained model on your own, removing the layers...
Read more >
Time series forecasting | TensorFlow Core
import matplotlib.pyplot as plt ... origin='https://storage.googleapis.com/tensorflow/tf-keras-datasets/ ... plt.bar(x = range(len(train_df.columns)),
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found