當前位置: 首頁>>代碼示例>>Python>>正文


Python CLinker.make_function方法代碼示例

本文整理匯總了Python中theano.gof.cc.CLinker.make_function方法的典型用法代碼示例。如果您正苦於以下問題:Python CLinker.make_function方法的具體用法?Python CLinker.make_function怎麽用?Python CLinker.make_function使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在theano.gof.cc.CLinker的用法示例。


在下文中一共展示了CLinker.make_function方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_clinker_single_node

# 需要導入模塊: from theano.gof.cc import CLinker [as 別名]
# 或者: from theano.gof.cc.CLinker import make_function [as 別名]
def test_clinker_single_node():
    if not theano.config.cxx:
        raise SkipTest("G++ not available, so we need to skip this test.")
    x, y, z = inputs()
    node = add.make_node(x, y)
    lnk = CLinker().accept(Env(node.inputs, node.outputs))
    fn = lnk.make_function()
    assert fn(2.0, 7.0) == 9
開發者ID:317070,項目名稱:Theano,代碼行數:10,代碼來源:test_cc.py

示例2: test_clinker_straightforward

# 需要導入模塊: from theano.gof.cc import CLinker [as 別名]
# 或者: from theano.gof.cc.CLinker import make_function [as 別名]
def test_clinker_straightforward():
    if not theano.config.cxx:
        raise SkipTest("G++ not available, so we need to skip this test.")
    x, y, z = inputs()
    e = add(mul(add(x, y), div(x, y)), bad_sub(bad_sub(x, y), z))
    lnk = CLinker().accept(Env([x, y, z], [e]))
    fn = lnk.make_function()
    assert fn(2.0, 2.0, 2.0) == 2.0
開發者ID:317070,項目名稱:Theano,代碼行數:10,代碼來源:test_cc.py

示例3: test_clinker_dups_inner

# 需要導入模塊: from theano.gof.cc import CLinker [as 別名]
# 或者: from theano.gof.cc.CLinker import make_function [as 別名]
def test_clinker_dups_inner():
    if not theano.config.cxx:
        raise SkipTest("G++ not available, so we need to skip this test.")
    # Testing that duplicates are allowed inside the graph
    x, y, z = inputs()
    e = add(mul(y, y), add(x, z))
    lnk = CLinker().accept(Env([x, y, z], [e]))
    fn = lnk.make_function()
    assert fn(1.0, 2.0, 3.0) == 8.0
開發者ID:317070,項目名稱:Theano,代碼行數:11,代碼來源:test_cc.py

示例4: test_clinker_not_used_inputs

# 需要導入模塊: from theano.gof.cc import CLinker [as 別名]
# 或者: from theano.gof.cc.CLinker import make_function [as 別名]
def test_clinker_not_used_inputs():
    if not theano.config.cxx:
        raise SkipTest("G++ not available, so we need to skip this test.")
    # Testing that unused inputs are allowed.
    x, y, z = inputs()
    e = add(x, y)
    lnk = CLinker().accept(Env([x, y, z], [e]))
    fn = lnk.make_function()
    assert fn(2.0, 1.5, 1.0) == 3.5
開發者ID:317070,項目名稱:Theano,代碼行數:11,代碼來源:test_cc.py

示例5: test_clinker_dups

# 需要導入模塊: from theano.gof.cc import CLinker [as 別名]
# 或者: from theano.gof.cc.CLinker import make_function [as 別名]
def test_clinker_dups():
    if not theano.config.cxx:
        raise SkipTest("G++ not available, so we need to skip this test.")
    # Testing that duplicate inputs are allowed.
    x, y, z = inputs()
    e = add(x, x)
    lnk = CLinker().accept(Env([x, x], [e]))
    fn = lnk.make_function()
    assert fn(2.0, 2.0) == 4
開發者ID:317070,項目名稱:Theano,代碼行數:11,代碼來源:test_cc.py

示例6: test_clinker_literal_inlining

# 需要導入模塊: from theano.gof.cc import CLinker [as 別名]
# 或者: from theano.gof.cc.CLinker import make_function [as 別名]
def test_clinker_literal_inlining():
    if not theano.config.cxx:
        raise SkipTest("G++ not available, so we need to skip this test.")
    x, y, z = inputs()
    z = Constant(tdouble, 4.12345678)
    e = add(mul(add(x, y), div(x, y)), bad_sub(bad_sub(x, y), z))
    lnk = CLinker().accept(Env([x, y], [e]))
    fn = lnk.make_function()
    assert abs(fn(2.0, 2.0) + 0.12345678) < 1e-9
    code = lnk.code_gen()
    #print "=== Code generated ==="
    #print code
    assert "4.12345678" in code  # we expect the number to be inlined
開發者ID:317070,項目名稱:Theano,代碼行數:15,代碼來源:test_cc.py


注:本文中的theano.gof.cc.CLinker.make_function方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。