Reputation: 1005
I am new to tensorflow and I am learning it using a book called Deep Learning with Applications Using Python Chatbots and Face, Object,and Speech Recognition With TensorFlow and Keras.
On Chapter 1 page 6, there are lines of code:
And I typed the codes showed in the book exactly,
# Tensorboard can be used. It is optionalmy_
# Output graph can be seen on tensorboard
import os
merged = tf.summary.merge_all(key='summaries')
if not os.path.exists('tensorboard_logs/'):
os.makedirs('tenosrboard_logs/')
my_writer = tf.summary.FileWriter('/home/manaswi/tenosrboard_logs/', sess.graph)
def TB(cleanup=False):
import webbrowser
webbrowser.open('http://127.0.1.1:6006')
!tensorboard --logdir='/home/manaswi/tenosrboard_logs'
if cleanup:
!rm -R tensorboard_logs/
TB(1) # Launch graph on tensorboard on your browser
But I get a syntax error when I run this code.
File "c1_demo.py", line 26
!tensorboard --logdir='/home/manaswi/tenosrboard_logs'
^
SyntaxError: invalid syntax
Am I doing something wrong or is the code problem.
Upvotes: 0
Views: 765
Reputation: 1466
The code of your book is written in a jupyter notebook and a special function of the jupyter notebook (jupyter magiv) is that the ! command executes a command in the console.
If you use another IDE use this function instead:
def TB(cleanup=False):
import webbrowser
os.system(tensorboard --logdir='/home/manaswi/tenosrboard_logs')
webbrowser.open('http://127.0.1.1:6006')
And two additional things:
Upvotes: 2