Theano Graph Structure

Graph Structure

Graph Definition

theano's symbolic mathematical computation, which is composed of:

  • Apply node: the application of an operator to some variable.
  • Variable node: symbolic varibles.
  • Op node: mathematical operation like: +,-,*,\,sqrt,sum,tanh.
  • Types: describe data type.

Example

Code

>>> import theano.tensor as T

>>> x = T.matrix('x')
>>> y = T.matrix('y')
>>> z = x + y
>>> print z.owner
    Elemwise{add,no_inplace}(Elemwise{pow,no_inplace}.0, y)

../_images/apply.png

  1. python object references: Arrow.
  2. Apply node: blue box. is composed of inputs,op and output fields.
  3. Variable Node: Red Box. the owner of x and y point to None, as they are not the results of another computation. If one of them is the result of another computation, it's owner field would point to another Apply Node.
  4. Op Node: Green circle.
  5. Types: Purple boxes.

Note: Apply Node points to z, so z.owner points back to the Apply instance.

Graph Structures

Apply

internal node represent of computation graph in theano, which can be accessed by variable_name.owner.

the Apply Node has three fields, and can be created by gof.Apply(op,inputs,outputs):

  1. Op: the function to be applied.
  2. inputs:the arguments of the functions.
  3. outputs: the return value of the function.

Op

certain computation on some inputs and producing some types of outputs.

Type

it helps to tailor C code to handle and optimize the computation graph.

Variable

  1. type:
  2. owner: None or Apply Node
  3. index
  4. name: string for debugging

Constant

a constant is a variable. it assume the Op Node will not modify the inputs.

Graph Structures Extension

转载于:https://www.cnblogs.com/ZJUT-jiangnan/p/6240085.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值