The use of TensorBoard and the pitfalls encountered
For an introduction to TensorBoard seethis articleI'm not going to go into details about the usage and description of the dashboards, but I'm going to focus on the problems I encountered.
Attach the code first to generate the event file
import tensorflow as tf # Define a simple computational graph that implements vector addition input1=([1.0,2.0,3.0],name="input1") input2=(tf.random_uniform([3]),name="input") output=tf.add_n([input1,input2],name="add") # Generate a writer that writes a log and writes the current TensorFlow computation graph to the log. The generated file is in the current folder writer=(".\log",tf.get_default_graph()) () init = tf.global_variables_initializer() ().run(init)
If it goes well, it should generate 1 event file, the
as shown
The next step is to use TensorBoard for visualization and analysis Enter tensorboard -logdir=log in a command line window, note that it is not in python's editing environment such as spyder, and if you do so, the
You'll get an error.
SyntaxError: can’t assign to operator
Back in the command line window, execute tensorboard -logdir=log
Copy the above URL in your browser http://DESKTOP-1Q4IB10:6006
You will see the following screen
There is no data, is not very frustrating lol, because we really do not have the event file inside the program to generate scalar data, but we have the event data of the graph a, click on the graph after the results of the
Success has been followed by many failures.
I'll tell you exactly what I ran into.
Inside the graph above, there has been no data!!!!。
like the following
existthis articleI tried the Win10 path problem, but it didn't work, but I moved the log folder somewhere else and then cd'd it, so I thought I can't move it every time, so I'll keep looking for a solution.this articleSuggested to activate the Tensorflow environment before using it, tried it as it is in there.
The results are as follows
You can see that the interface of the web page has changed, is it Google's egg / nerd, but still can not display the data properly, can only continue to find a solution, in this article, it is proposed to add the path of TensorBoard's program to the system's environment variables, I did not try, if you still have problems after reading this article, why not try this.
So then again, which piece is the problem? Just when I was at a loss, I looked at the commands on the console, and suddenly realized that my folder name "TensoBoard Exercise" had Chinese in it, and wondered if that could be the problem, and changed it to TensorBoardTest.
The result is shown in the figure
What happened to the warning in the command line? Switch to a normal environment and see if it comes up again!
Still appearing, a closer look at the English says that more than one event file has been found, go back to the folder and two event files do exist.
But what is the difference between the two? And which one is loaded when loading?
A bit of research found that every time you run the python program, a new event file will be generated, but this event file is based on the previous version and then add some new content generated, run to see the details.
Sure enough just one copy of the data is made. And in the case where multiple event files exist, TensorBoard reads the most recently generated one.
summarize
Using TensorBoard is not particularly difficult, it's just a matter of path problems plus Chinese file names, pay attention to these two points will be fine.
Note: The reason I used tensorboard -logdir=log directly in that image at the beginning is because my folder is on the desktop. It's under the E drive for the demo later. Also like
#tensorboard --logdir=C:\Users\dbsdz\Desktop\TensorBoardTest\log can be #cd E://TensorBoardTest tensorboard --logdir=log can #e: cd TensorBoardTest tensorboard --logdir=log can
Commands of this type also display the data correctly.
ultimate
The above is a personal experience, I hope it can give you a reference, and I hope you can support me more.