Tensorflow visualizer “Tensorboard” not working un

2020-06-17 04:40发布

问题:

I'm currently using tensorflow and I want to visualize the effect of the convolutional neural network that I'm writing. However, I can't use tensorboard. I see the tensorboard underneath my conda env as envs/tensorenv/bin/tensorboard (python file). It imports this thing called tensorflow.tensorboard.tensorboard that it can't find.

(tensorenv)wifi-131-179-39-186:TensorflowTutorial hongshuhong$ tensorboard --logdir=log/
Traceback (most recent call last):
  File "/Users/hongshuhong/anaconda/envs/tensorenv/bin/tensorboard", line 4, in <module>
    import tensorflow.tensorboard.tensorboard
ImportError: No module named 'tensorflow.tensorboard.tensorboard'
  • I tried looking for the tensorflow.tensorboard.tensorboard but I don't see it anywhere in my directories.
  • I'm using Mac OSX distro of tensorflow under anaconda, using python 3.5.1 and using anaconda's packages.
  • I'm using ipython notebook for the code for the convnet.

Any help would be appreciated. Let me know if extra information is needed, thanks.

回答1:

Work it like this command

python /Users/USERNAME/anaconda/envs/tf/lib/python3.5/site-packages/tensorboard/main.py --logdir=./logs/

tensorboard.py is changed to main.py



回答2:

Actually @Andras Deak helped me with this answer, but according to this github issue link: https://github.com/tensorflow/tensorflow/issues/1790 The anaconda version doesn't work because for some reason the tensorboard is inside of the "backend" directory. you have to navigate yourself to the correct directory and execute the python script, which is:

python ~/anaconda/envs/tensorenv/lib/python3.5/site-packages/tensorflow/tensorboard/backend/tensorboard.py

It worked for me:

I'm currently working on a way for a permanent fix, but this is a temporary way to fix it.

EDIT: So actually for the permanent fix, all you need to do is copy tensorboard.py into the outer directory. For me, it was inside of

..../site-packages/tensorflow/tensorboard/backend/tensorboard.py 

into

..../site-packages/tensorflow/tensorboard/tensorboard.py. 

I kept the one in backend, and just copied it over and it seems to work for a scalar_summary display. Let me know if any errors come up guys!



回答3:

Try update your tensorflow in your specific conda environment if you are having the same issue as I did.

I am also using Anaconda and conda install the tensorflow and tensorboard and was repeatedly getting this issue while I was trying the tensorboard command:

Traceback (most recent call last):
  File "/Users/.../anaconda/envs/mlbook/bin/tensorboard", line 4, in <module>
    import tensorflow.tensorboard.tensorboard
ImportError: No module named 'tensorflow.tensorboard'

The above solution doesn't work for me because I can't find the tensorboard.py.

What I did is:

(mlbook) ... anaconda $ conda update tensorflow
Fetching package metadata .........
Solving package specifications: .

Package plan for installation in environment /Users/W.Zhan/anaconda/envs/mlbook:

The following packages will be SUPERSEDED by a higher-priority channel:

    tensorflow: 1.4.0-py35_0 conda-forge --> 1.1.0-np112py35_0

Proceed ([y]/n)? y

And after I updated the tensorflow in conda and tried the tensorboard command again in the shell, it worked.