首页 > 代码库 > 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
  1. 给一个参数设置默认值

    <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)