如何使用 google colab 从 TensorFlow 代码生成图形并将其可视化?

How to generate a graph and visualize it from a TensorFlow code using google colab?

我正在学习 TensorFlow,现在当我尝试使用以下代码在 google colab 中生成图形时

import tensorflow as tf

a = tf.add(2, 2, name='add')
b = tf.multiply(a, 3, name ='mult1')
c = tf.multiply(b, a, name='mult2')

print(c.numpy())

tf.compat.v1.get_default_graph()

writer = tf.summary.create_file_writer('C:\Users\LUCINALDO\Desktop\xampp\htdocs\Deep Learning\Grafos')
a = tf.add(2, 2, name='add')
b = tf.multiply(a, 3, name ='mult1')
c = tf.multiply(b, a, name='mult2')
writer.close()

我看到以下错误消息

File "<ipython-input-20-a289120d76db>", line 11
writer = tf.summary.create_file_writer('C:\Users\LUCINALDO\Desktop\xampp\htdocs\Deep Learning\Grafos')
                                      ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

如何使用 google colab 将图形文件保存在计算机文件夹(或驱动器)中?

如你所见,我可以保存。

import tensorflow as tf

a = tf.add(2, 2, name='add')
b = tf.multiply(a, 3, name ='mult1')
c = tf.multiply(b, a, name='mult2')

print(c.numpy())

tf.compat.v1.get_default_graph()

writer = tf.summary.create_file_writer('/test')
a = tf.add(2, 2, name='add')
b = tf.multiply(a, 3, name ='mult1')
c = tf.multiply(b, a, name='mult2')
writer.close()