python - How to generate a graph and visualize it from a TensorFlow code using google colab?
问题描述
I'm learning TensorFlow, and now when I tried to generate graphs in google colab with the following code
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()
I am shown the following error message
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
How to save graph files in a computer folder(or in drive) using 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()
推荐阅读
- c++ - 模板元:函数参数类型特征检测
- python - ElementTree XML-Parser,附加超链接写入标签
- r - ggplot2 geom_polygon 没有绘制任何东西
- java - 图像元数据未从 jpeg 复制到 tif 文件,使用 Java ImageIO 和十二猴子
- wordpress - 将备份的 Wordpress 从子目录移动到根目录
- swift - “返回函数”和“回调函数”的主要区别是什么?
- python - pyspark中嵌套for循环的实现
- c# - 将服务器端 Blazor 添加到现有 MVC Core 应用程序
- android - 如何自动调整宽度和高度?
- spring-boot - thymeleaf 中列表内列表的聚合