tensorflow tensorboard summaries example - python

I'm trying to open a tensorboard using the example code. I ran the example locally and then tried to open in tensorboard using the following command tensorboard --logdir=F:\mnist_tmp\tensorflow\mnist\logs\mnist_with_summaries\.
Tensorboard starts, however I am not able to see any data ie, scalars, graphs,
or histograms.
Below is a picture of what I see when I open tensorflow. If I click on the other tabs I get a similar text dialog.

Don't use '' to brace the dir , just use the
tensorboard --logdir=dir
if you use the win10 System Operation

My issue was that I my log logdir contained the F: but tensorflow uses colon as an seperator which is a known bug.

Related

How to get files under Code tab in a job using AzureML python SDK

I'm trying to access the files/artifacts located in the code tab under an AzureML job. When using the azureml.core.run.Run class, the only methods suitable could be get_file_names() and download_files but they only list files under the Outputs + logs tab.
Is there a workaround to do this?
From Designer we can export the code. For Automl we could see the image as show below. you can use the run.download_files.

Save jupyter cell computation work and load from where I left

I am currently reading the book "Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow: Concepts, Tools, and Techniques to Build Intelligent Systems" and I am experimenting with some housing analysis example.
My question is: every time I open Jupyter Notebook I have to run all the cells from the beginning one by one in order to continue with my work. I am new to Jupyter and I didn't find any solution to this.
I have imported packages like pandas, a function that downloads tar files and extracts them, also another one loading the data and many others.
Is there any way to safe and load everything (packages, functions, etc) so I can continue my work from the last checkpoint?
I have tried the kernel-restart & run all but is not working
Also, I have tried the cell-Run all but is not working either
I am using Jupyter 6.1.4 installed through anaconda latest version
Any help would be appreciated. Thank you
You can pickle and store the variables in the computer (disk). Next time you can just unpickle that and get going.
I am assuming you do not want to perform operations repeatedly on some data each time you work on a notebook
# For storing
import pickle
with open('pickle_file_name.pkl','w') as file_object:
pickle.dump(<your_data_variable>, file_object)
# For loading
with open('pickle_file_name.pkl','r') as file_object:
your_data_variable= pickle.load(file_object)
`

Running SyntaxNet with designated instance (in Python-level)

Could you please let me know how I designate which instance to use when training/testing SyntaxNet?
In other tensorflow models we can easily change configurations by editing Python code:
ex) tf.device('/cpu:0') => tf.device('/gpu:0').
I could run parsey mcparseface model via running demo.sh and I followed back symbolic links to find device configurations.
Maybe I misedBut I cannot find gpu configuration python codes in demo.sh, parser_eval.py and context.proto.
When I search with query 'device' in tensorflow/models, I could see several C files such as syntaxnet/syntaxnet/unpack_sparse_features.cc contain line using tensorflow::DEVICE_CPU;
So.. is to change C codes in these files the only way to change device configuration for SyntaxNet?
I hope there is a simpler way to change the setting in Python level.
Thanks in advance.
You can refer to this page for instructions on running syntax net on GPU: https://github.com/tensorflow/models/issues/248
Tensorflow would automatically assign devices including GPU to the ops: https://www.tensorflow.org/versions/r0.11/how_tos/using_gpu/index.html. You can also manually specify the device when building the graph.

Creating log directory in tensorboard

I am trying to learn how to use tensorboard and I would like to have it run in my program. I do not understand how to create a log directory. These are the lines I have for running tensorboard.
summary_writer = tf.train.SummaryWriter('/tensorflow/logdir', sess.graph_def)
tensorboard --logdir=tensorflow/logdir
The error message that I got was
Cannot assign to operator
This line needs to be in your code (the python script), as it seems you put it:
summary_writer = tf.train.SummaryWriter('/tensorflow/logdir',
sess.graph_def)
This line, however, you have to call from linux (and not from within the script):
tensorboard --logdir=tensorflow/logdir
However, there is a lot more you need to do, before tensorboard really runs:
How to create a Tensorflow Tensorboard Empty Graph
The tutorial might disclose not very clear on the TensorFlow official website
I have stuck in the same issue before
But in order not to confuse you, i still use it as a guide here
First Part (lines of codes in .py file)
Just skip to class tf.train.SummaryWriter in official guide
First, you need this lines of code in your .py file to create a dataflow graph
In tensorflow, a session is where the graph been created
#...create a graph...
# Launch the graph in a session.
sess = tf.Session()
Then, you also need to type in these lines into your code
# Create a summary writer, add the 'graph' to the event file.
writer = tf.train.SummaryWriter(< directory name you create>, sess.graph)
The logs folder will be generated in the directory you assigned after the .py file you created is executed
Here is the sample code you can use
Second Part (lines of code in your linux terminal)
In your Linux terminal window, type in
tensorboard --logdir="path of your log file"
It will link to your log file automatically
Last step (key in link into your browser)
After key in
tensorboard --logdir="path of your log file"
It will generate a http link ,ex http://666.6.6.6:6006
Copy the http link into your web browser
Enjoy it!
Be careful
Do not go to the directory where the log file is before key in the line of code above
It might miss the log file
This youtube video will explain more explicitly about this at 9:40
You also can take a look of how to launch tensorboard on official guide
Hope you can show your data graph ASAP~
for --colab
%tensorflow_version 2.x
from torch.utils.tensorboard import SummaryWriter
tensorboard_logdir = '/content/tensorboard/'
writer = SummaryWriter(tensorboard_logdir)

Multiple Event files on Tensorboard

I am using Tensorboard to show the training results of the code using Tensorflow (0.7). The previous Tensorflow version had issue for multiple event files: when I run my local server using $ tensorboard --logdir=./tmp/, it shows up error if there are more than 1 event files. It seems that the latest version (0.7) does not show up the same error for multiple event files, but it still shows the overlapped curves for multiple event files on Tensorboard. I wonder how to solve this problem. Thanks!
Training my own networks, I am writing summaries in different subfolders like /tmp/project/train and /tmp/project/eval. If you start TensorBoard using
tensorboard --logdir=/tmp/project/
you will still receive multiple graphs from each event file in the subfolders at once, as you mentioned. To see seperate graphs you can start TensorBoard from the desired subfolder:
tensorboard --logdir=/tmp/project/train/
I second ArnoXf's answer. You should use different subfolders for each experiment and assuming the logging root is /tmp start tensorboard using:
tensorboard --logdir=/tmp/
If you want to display just a single graph you can either pass that directory to your tensorboard call as described in ArnoXf's answer.
However, with the above call you can also select your graph directly in tensorboard, i.e., deactivate all others. The same way you can also compare individual runs as shown in the following screenshot. In my opinion, this is usually the preferred option, as it gives you more flexibility.
A detailed example can be found here.

Categories