首页 > 代码库 > theano 入门教程1.3
theano 入门教程1.3
<style id="wiz_custom_css" type="text/css">body{ font-family: "Microsoft YaHei UI","Microsoft YaHei",SimSun,"Segoe UI",Tahoma,Helvetica,Sans-Serif,"Microsoft YaHei", Georgia,Helvetica,Arial,sans-serif,宋体, PMingLiU,serif; font-size: 10.5pt; line-height: 1.5;}html, body{ }h1 { font-size:1.5em; font-weight:bold;}h2 { font-size:1.4em; font-weight:bold;}h3 { font-size:1.3em; font-weight:bold;}h4 { font-size:1.2em; font-weight:bold;}h5 { font-size:1.1em; font-weight:bold;}h6 { font-size:1.0em; font-weight:bold;}img { border:0; max-width: 100%;}blockquote { margin-top:0px; margin-bottom:0px;}table { border-collapse:collapse; border:1px solid #bbbbbb;}td { border-collapse:collapse; border:1px solid #bbbbbb;}</style>theano 入门教程1.3
-
给一个参数设置默认值
<style type="text/css">p%2C%20li%20%7B%20white-space%3A%20pre-wrap%3B%20%7D</style># -*- coding: utf-8 -*-
"""
Created on Wed Jun 4 23:22:17 2014
@author: wencc
"""
import theano.tensor as T
from theano import function
from theano import Param
from theano import pp
if __name__ == "__main__":
x, y , w= T.dscalars(‘x‘, ‘y‘, ‘w‘)
z = x + y + w
f = function([x, Param(y, default=1), Param(w, default=2, name=‘w_by_name‘)], z)
print f(33, 2, w_by_name=4)
print pp(z)
这里用Param给一个变量设置默认参数。
来自为知笔记(Wiz)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。