文章标题
来源:互联网 发布:今日头条淘宝推广 编辑:程序博客网 时间:2024/06/01 07:32
使用 Shared 变量
from theano import shared# 定义一个shared的变量state = shared(0)inc = T.iscalar('inc')accumulator = function([inc], state, updates = [(state,state+inc)])
另外,shared变量的值可以通过:
# accessedstate.get_value()# modifiedstate.set_value()
来获得和更改。另外还有一点需要注意的是updates,它的参数必须是一对列表(shared_variable , new_expression)或者字典。表示的意思是用new_expression来更新shared变量的值。
也可以定义多个函数共享同一个shared变量。比如
import theanoimport theano.tensor as Tfrom theano import functionfrom theano import shared#定义一个shared变量state = shared(0)#定义一个初始状态变量inc = T.iscalar('inc')#定义一个累加函数accumulator = function([inc],state,updates = [(state,state+inc)])#定义一个累减函数decrementor = function([inc],state,updates = [(state,state-inc)])
0 0
- 文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题 文章标题 文章标题 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- iOS加载本地Json文件,b并转为模型数据
- eclipse中的插件安装(svn、maven、jetty等)
- jvm 类初始化过程代码实战分析
- Cracer 2015 最新 价值1500元web渗透脚本入侵百集教程分享(无key)
- C语言自加问题
- 文章标题
- 程序员必须知道的10大基础实用算法及其讲解
- The type org.springframework.core.io.support.ResourcePatternResolver cannot be resolved. It is ind
- 测试
- 黑马程序员——ObjectiveC基础——NSString对象
- zooKeeper的两种使用模式
- NSNotification 多次调用的情况
- 软件测试需求分析步骤
- 循环队列