theano 入门教程1.3
给一个参数设置默认值
# -*- 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给一个变量设置默认参数。