Tensorboard name logdir is not defined - tensorflow

I was installing tensorboard using pip install tensorboard. All worked fine
I run my network and the writer also worked fine
with tf.Session() as sess:
writer = tf.summary.FileWriter("pathtofolder", sess.graph)
print(sess.run(h))
writer.close()
now I wanted to see in tensorboard how it learned
I inserted
import tensorflow, tensorboard
tensorboard --logdir /pathtofolder
and received the error message.
NameError: name 'logdir' is not defined

You should execute the command on terminal/cmd.
Open your terminal/cmd and run:
tensorboard --logdir ./PATH_TO_THE_EVENT_FILES
If you want to run Tensorboard on python file see here:

Related

Printing a specific dimension of a tensor in tensorflow

I have a tensor x of shape (4,64,5,5). How can I print (or just visualize) the content of a specific dimension?
What I'm trying to do is
with tf.Session() as sess: print(x[0,:,:,:].eval())
but I got the following error:
FailedPreconditionError: Error while reading resource variable dense_2/kernel from Container: localhost. This could mean that the variable was uninitialized. Not found: Container localhost does not exist. (Could not find resource: localhost/dense_2/kernel)
I'm using Tensorflow
1.14
I tried the same in colab in Tensorflow version 1.14 using tf.ones(shape=(4,64,5,5)). It is working fine. Here's the code:
! pip install tensorflow==1.14
import tensorflow as tf
print(tf.__version__)
x=tf.ones(shape=(4,64,5,5))
with tf.Session() as sess: print(x[:,0,0,0].eval())
Output:
1.14.0
[1. 1. 1. 1.]
Let us know if the issue still persists. Thanks!

Issue in tensorflow 2 google colab tutorial

I'm trying to follow the steps as dictated through this blog post https://medium.com/swlh/tensorflow-2-object-detection-api-with-google-colab-b2af171e81cc. I have edited the pipeline.config file as mentioned on step 13. After which I tried to run it on colab. While executing the following line of code I get the error as
#Step 15- Train the model.
#run the cell to start model training
!python model_main_tf2.py --model_dir=models/my_ssd_resnet50_v1_fpn --pipeline_config_path=models/my_ssd_resnet50_v1_fpn/pipeline.config
ValueError: Unsuccessful TensorSliceReader constructor: Failed to get matching files on pre-trained-models/ssd_resnet50_v1_fpn_640x640_coco17_tpu-8/checkpoint/ckpt-0: Not found: pre-trained-models/ssd_resnet50_v1_fpn_640x640_coco17_tpu-8/checkpoint; No such file or directory
Any idea where I'm going wrong?

Converting a saved tensorflow model to IR using openvino model optimizer

I trained a custom CNN model using keras and tensorflow 2.2.0 as background. After that, I saved the model as .ckpt file having assets, variables, .pb file as subfolders init. After that to convert it into IR in openvino documentation it is given that we have use the following command:
**To convert such TensorFlow model:
Go to the <INSTALL_DIR>/deployment_tools/model_optimizer directory
Run the mo_tf.py script with a path to the SavedModel directory to convert a model:
python3 mo_tf.py --saved_model_dir <SAVED_MODEL_DIRECTORY>**
so, I went to the following directory as mentioned and tired the following command:
python3 mo_tf.py --saved_model_dir C:\Users\vyas\Desktop\saved_model\cp.ckpt
There is no output or anything. There is no error also.
Also, I tried the following command:
python3 mo_tf.py --saved_model_dir C:\Users\vyas\Desktop\saved_model\cp.ckpt --output_dir C:\Users\vyas\Desktop\out
Still there is no output.
Can someone please help.
I am using tensorflow 2.2.0
Can someone please help me with this
--saved_model_dir must provide a path to the SavedModel directory.
Modify your command as follows:
python3 mo_tf.py --saved_model_dir C:\Users\vyas\Desktop\saved_model

UsageError: Line magic function `%tensorboard` not found

I try to use tensorboard in jupyter lab but the use of the %tensorboard --logdir logs/fit line magic do not work.
Jupyterlab: '0.33.12'
ipython: '7.2.0'
python: '3.6.7'
tensorflow: '2.0.0-dev20190426'
I have this message when I try %load_ext tensorboard.
The tensorboard module is not an IPython extension.
For older versions of Tensorflow 1 and Tensorflow 2, you want to load tensorboard notebook in ipython first:
%load_ext tensorboard.notebook
Then run it like this:
%tensorboard --logdir logs/scalars

tensorboard localhost connection

I can't seem to find exact question about what I am about to ask here. I just started following a Tensorflow tutorial on YouTube and got stuck at the very beginning. I wrote in my spyder IDE the below code:
import tensorflow as tf
a = tf.constant(2)
b = tf.constant(3)
x = tf.add(a,b)
#writer = tf.summary.FileWriter('./graphs', tf.get_default_graph())
with tf.Session() as sess:
writer = tf.summary.FileWriter('./graphs', sess.graph)
print(sess.run(x))
writer.close()
And via anaconda terminal I activated my env (which I newly created, installed all packages required, spyder as well) I typed python tftuts.py and got 2018-10-05 11:50:49.431174: I T:\src\github\tensorflow\tensorflow\core\platform\cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
5
Then I typed tensorboard --logdir="./graphs" --port 6006 as suggested in tutorial I am watching.
Now, when I go to http://localhost:6006/ the page shows
I am on Win10, using python 3.6.6 in Anaconda env, tensorflow 1.10.0.
How can solve this issue?