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


Python basic.Composite類代碼示例

本文整理匯總了Python中theano.scalar.basic.Composite的典型用法代碼示例。如果您正苦於以下問題:Python Composite類的具體用法?Python Composite怎麽用?Python Composite使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: test_straightforward

 def test_straightforward(self):
     x, y, z = inputs()
     e = mul(add(x, y), div_proxy(x, y))
     C = Composite([x, y], [e])
     c = C.make_node(x, y)
     # print c.c_code(['x', 'y'], ['z'], dict(id = 0))
     g = FunctionGraph([x, y], [c.out])
     fn = gof.DualLinker().accept(g).make_function()
     assert fn(1.0, 2.0) == 1.5
開發者ID:DeepLearningIndia,項目名稱:Theano,代碼行數:9,代碼來源:test_basic.py

示例2: test_with_constants

 def test_with_constants(self):
     x, y, z = inputs()
     e = mul(add(70.0, y), div_proxy(x, y))
     C = Composite([x, y], [e])
     c = C.make_node(x, y)
     assert "70.0" in c.op.c_code(c, 'dummy', ['x', 'y'], ['z'], dict(id = 0))
     # print c.c_code(['x', 'y'], ['z'], dict(id = 0))
     g = FunctionGraph([x, y], [c.out])
     fn = gof.DualLinker().accept(g).make_function()
     assert fn(1.0, 2.0) == 36.0
開發者ID:DeepLearningIndia,項目名稱:Theano,代碼行數:10,代碼來源:test_basic.py

示例3: test_many_outputs

 def test_many_outputs(self):
     x, y, z = inputs()
     e0 = x + y + z
     e1 = x + y * z
     e2 = x / y
     C = Composite([x, y, z], [e0, e1, e2])
     c = C.make_node(x, y, z)
     # print c.c_code(['x', 'y', 'z'], ['out0', 'out1', 'out2'], dict(id = 0))
     g = FunctionGraph([x, y, z], c.outputs)
     fn = gof.DualLinker().accept(g).make_function()
     assert fn(1.0, 2.0, 3.0) == [6.0, 7.0, 0.5]
開發者ID:DeepLearningIndia,項目名稱:Theano,代碼行數:11,代碼來源:test_basic.py

示例4: test_composite_clone_float32

 def test_composite_clone_float32(self):
     w = int8()
     x = float16()
     y = float32()
     cz = Composite([x, y], [tanh(x + cast(y, 'float16'))])
     c = Composite([w, x, y], [cz(x, y) - cz(x, y)**2 +
                               cast(x, 'int16') + cast(x, 'float32') +
                               cast(w, 'float16') -
                               constant(np.float16(1.0))])
     assert has_f16(c)
     nc = c.clone_float32()
     assert not has_f16(nc)
開發者ID:mohammadpz,項目名稱:Theano,代碼行數:12,代碼來源:test_basic.py

示例5: test_composite_printing

    def test_composite_printing(self):
        x, y, z = floats('xyz')
        e0 = x + y + z
        e1 = x + y * z
        e2 = x / y
        e3 = x // 5
        e4 = -x
        e5 = x - y
        e6 = x ** y + (-z)
        e7 = x % 3
        C = Composite([x, y, z], [e0, e1, e2, e3, e4, e5, e6, e7])
        c = C.make_node(x, y, z)
        g = FunctionGraph([x, y, z], c.outputs)
        fn = gof.DualLinker().accept(g).make_function()

        assert str(g) == ('[*1 -> Composite{((i0 + i1) + i2),'
                          ' (i0 + (i1 * i2)), (i0 / i1), '
                          '(i0 // Constant{5}), '
                          '(-i0), (i0 - i1), ((i0 ** i1) + (-i2)),'
                          ' (i0 % Constant{3})}(x, y, z), '
                          '*1::1, *1::2, *1::3, *1::4, *1::5, *1::6, *1::7]')
開發者ID:Abioy,項目名稱:Theano,代碼行數:21,代碼來源:test_basic.py


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