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.

'TensorBoard' object has no attribute 'sess'

See original GitHub issue

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): No
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Mac Os
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:
  • TensorFlow installed from (source or binary):binary
  • TensorFlow version (use command below):1.12
  • Tensorboard: 1.12
  • Python version:3.6
  • Bazel version (if compiling from source):
  • GCC/Compiler version (if compiling from source):
  • CUDA/cuDNN version:N/A
  • GPU model and memory:N/A

You can collect some of this information using our environment capture script You can also obtain the TensorFlow version with python -c “import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)” v1.12.0-rc2-3-ga6d8ffae09 1.12.0 Describe the current behavior I want to use the tensorboard callback in keras to show the embeddings in the projector view Describe the expected behavior I’m getting an error while training. Code to reproduce the issue Provide a reproducible test case that is the bare minimum necessary to generate the problem.

    tensorboard = keras.callbacks.TensorBoard(
        log_dir='./logs',
        batch_size=128,
        histogram_freq=1,
        embeddings_freq=1,
        embeddings_metadata='./metadata.tsv',
        embeddings_data=X_Test
    )
    history = model.fit(ready_data, ready_labels, batch_size=128, epochs=20,validation_data=(X_Test,Y_test),callbacks=[tensorboard])

Other info / logs Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.

Traceback (most recent call last):
  File "/Users/alcaljos/Projects/issue-classifer-ml/src/main.py", line 193, in <module>
    history = model.fit(ready_data, ready_labels, batch_size=128, epochs=20,validation_data=(X_Test,Y_test),callbacks=[tensorboard,checkpointer])
  File "/Users/alcaljos/anaconda/envs/issue-classifier/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py", line 1639, in fit
    validation_steps=validation_steps)
  File "/Users/alcaljos/anaconda/envs/issue-classifier/lib/python3.6/site-packages/tensorflow/python/keras/engine/training_arrays.py", line 239, in fit_loop
    callbacks.on_epoch_end(epoch, epoch_logs)
  File "/Users/alcaljos/anaconda/envs/issue-classifier/lib/python3.6/site-packages/tensorflow/python/keras/callbacks.py", line 214, in on_epoch_end
    callback.on_epoch_end(epoch, logs)
  File "/Users/alcaljos/anaconda/envs/issue-classifier/lib/python3.6/site-packages/tensorflow/python/keras/callbacks.py", line 1144, in on_epoch_end
    self.sess.run(self.assign_embeddings, feed_dict=feed_dict)
AttributeError: 'TensorBoard' object has no attribute 'sess'

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8

github_iconTop GitHub Comments

2reactions
nfeltcommented, Mar 12, 2019

Fixed by https://github.com/tensorflow/tensorflow/commit/d994300bde00c7dee8bacccdbc5d67c3f3f2b322

This fix should be available in the upcoming 1.14 release of TensorFlow, or you can check out the nightly release tf-nightly, which should already have it.

2reactions
thomasgassmanncommented, Feb 12, 2019

As a temporary workaround, just overwrite the existing TensorBoard with a new one, that has a session:

class TensorBoardWithSession(tf.keras.callbacks.TensorBoard):

    def __init__(self, **kwargs):
        from tensorflow.python.keras import backend as K
        self.sess = K.get_session()

        super().__init__(**kwargs)

 tf.keras.callbacks.TensorBoard = TensorBoardWithSession

Then, just continue using TensorBoard normally.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AttributeError: module 'tensorflow' has no attribute 'Session'
I believe "Session()" has been removed with TF 2.0. ... rewrite it to not use Session() , since that's no longer necessary in...
Read more >
'module' object has no attribute 'Session' in tensorflow ...
AttributeError : 'module' object has no attribute 'Session' in tensorflow/tensorflow:latest-gpu-jupyter TF 2.0-alpah0 in Docker Container #26816.
Read more >
TensorFlow 2.0 has no attribute session - RoseIndia.Net
Today we will see the main reason behind the "TensorFlow 2.0 has no attribute session" error in TensorFlow and also see what can...
Read more >
AttributeError: module 'tensorflow' has no attribute 'Session'
For TF 1:1 Symbols Map, in TF 2.0 you have to use: tf.compat.v1.Session() instead of tf.Session(). But one cannot benefit many improvements ...
Read more >
'module' object has no attribute 'Session'
2020-03-18 14:52:57.209326: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:30] Cannot dlopen some TensorRT libraries. If you would like to ...
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