【思维导图】 Theano graphs 代码流程可视化的三种方法

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
Printing/Drawing Theano graphs

pprint()更紧凑,更像数学
o theano.printing.pprint(prediction)
’gt((TensorConstant{1} / (TensorConstant{1} + exp(
TensorConstant{0.5})’
debugprint()更冗长。
o theano.printing.debugprint(prediction)
预编译图:
后编译图:
pydotprint(),用于创建函数的图像。
o预编译图:
 theano.printing.pydotprint(prediction, outfile
考虑逻辑回归示例:
o>>> import numpy
o>>> import theano
o>>> import theano.tensor as T
o>>> rng = numpy.random
o>>> # Training data
>>> N = 400
>>> feats = 784
>>> D = (rng.randn(N, feats).astype(theano.config.
>>> training_steps = 10000
o>>> # Declare Theano symbolic variables
>>> x = T.matrix(“x”)
>>> x.tag.test_value = D[0]
o.tag.test_value 作用?
 那在调试过程中,要如何查看TensorVariable值呢?可以通过tag.test_value,即定义theano变量x时,赋值给x.tag.test_value。
o>>> y = T.vector(“y”)
>>> y.tag.test_value = D[1]
o>>> w = theano.shared(rng.randn(feats).astype(thea
o>>> b = theano.shared(numpy.asarray(0., dtype=thea
>>> # Construct Theano expression graph
o>>> p_1 = 1 / (1 + T.exp(-T.dot(x, w)-b)) # Probab
o>>> prediction = p_1 > 0.5 # The prediction that i
>>> # Compute gradients
o>>> xent = -y*T.log(p_1) - (1-y)T.log(1-p_1) # Cr
o>>> cost = xent.mean() + 0.01
(w**2).sum() # The c
o>>> gw,gb = T.grad(cost, [w,b])
>>> # Training and prediction function
o>>> train = theano.function(inputs=[x,y], outputs=
o>>> predict = theano.function(inputs=[x], outputs=
后编译图:
o theano.printing.pydotprint(predict, outfile="p
优化的训练图:
o theano.printing.pydotprint(train, outfile="pic
Interactive Graph Visualization
o新的d3viz模块
pip install pydot-ng
predict_profiled = th.function([x], y, profile=True)
x_val = rng.normal(0, 1, (ninputs, nfeatures))
y_val = predict_profiled(x_val)
d3v.d3viz(predict_profiled, ‘examples/mlp2.html’)
它不是创建静态图像,而是生成一个HTML文件

预编译图:

theano.printing.pydotprint(predict, outfile="p

theano.printing.pydotprint(train, outfile="pic

后编译图:

theano.printing.pydotprint(prediction, outfile

它不是创建静态图像,而是生成一个HTML文件

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
《算法赏析》课程介绍 “软件 = 算法 + 数据结构”,算法是软件的灵魂。在信息时代,计算思维是分析复杂工程问题的重要思维方式,计算机则是求解问题的重要工具。本课程以计算机经典问题求解为导向,通用算法思维和自动编程流程图培养为目标,引入经典算法,精心安排课程的理论教学和编程实践。本课程学习将有助于学员提高计算思维能力及算法思维的能力。 本课程主要讲授计算机问题求解的经典算法设计方法和算法复杂度分析方法,主要内容包括计算机概述、计算机系统的组成、信息化及指标体系、操作系统、程序设计语言、算法简介、数的表示及存储、数据结构简介及顺序结构和选择结构、循环结构、循环的嵌套、算法复杂度分析,枚举算法,递归与分治策略,递归与迭代的思想、求最大值最小值、线性查找、二分查找与冒泡排序以及选择与交换排序、插入和希尔排序。本课程除了强调经典的算法理论和模型,亦兼顾编程实践能力。力图使得学员面对复杂问题时,既能“想到”还能“做到”。 授课目标 培养算法思维,掌握枚举算法、分治策略、递归与迭代、选择与交换排序等经典算法模型; 培养实践能力,掌握在存储空间和时间开销受限情况下的程序设计方法; 培养理论思维,掌握复杂问题的算法设计与分析方法

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

神经美学_茂森

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值