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


Python gof.Constant類代碼示例

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


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

示例1: test_none_Constant

def test_none_Constant():
    """ Tests equals

    We had an error in the past with unpickling
    """
    o1 = Constant(NoneTypeT(), None, name='NoneConst')
    o2 = Constant(NoneTypeT(), None, name='NoneConst')
    assert o1.equals(o2)
    assert NoneConst.equals(o1)
    assert o1.equals(NoneConst)
    assert NoneConst.equals(o2)
    assert o2.equals(NoneConst)

    # This trigger equals that returned the wrong answer in the past.
    import six.moves.cPickle as pickle
    import theano
    from theano import tensor

    x = tensor.vector('x')
    y = tensor.argmax(x)
    kwargs = {}
    # We can't pickle DebugMode
    if theano.config.mode in ["DebugMode", "DEBUG_MODE"]:
        kwargs = {'mode': 'FAST_RUN'}
    f = theano.function([x], [y], **kwargs)
    pickle.loads(pickle.dumps(f))
開發者ID:ALISCIFP,項目名稱:Segmentation,代碼行數:26,代碼來源:test_type_other.py

示例2: __init__

 def __init__(self, type, data, name=None):
     Constant.__init__(self, type, data, name)
     if (isinstance(data, numpy.ndarray) and
         data.ndim > 0 and
         len(numpy.unique(data)) == 1):
         self.tag.unique_value = numpy.unique(data)[0]
     else:
         self.tag.unique_value = None
開發者ID:AI-Cdrone,項目名稱:Theano,代碼行數:8,代碼來源:var.py

示例3: __init__

 def __init__(self, type, data, name=None):
     Constant.__init__(self, type, data, name)
     self.tag.unique_value = None
     if isinstance(data, numpy.ndarray) and data.ndim > 0:
         flat_data = data.ravel()
         if flat_data.shape[0]:
             if (flat_data == flat_data[0]).all():
                 self.tag.unique_value = flat_data[0]
開發者ID:Britefury,項目名稱:Theano,代碼行數:8,代碼來源:var.py

示例4: __init__

 def __init__(self, type, data, name=None):
     assert isinstance(data, slice)
     # Numpy ndarray aren't hashable, so get rid of them.
     if isinstance(data.start, numpy.ndarray):
         assert data.start.ndim == 0
         assert "int" in str(data.start.dtype)
         data = slice(int(data.start), data.stop, data.step)
     elif isinstance(data.stop, numpy.ndarray):
         assert data.stop.ndim == 0
         assert "int" in str(data.stop.dtype)
         data = slice(data.start, int(data.stop), data.step)
     elif isinstance(data.step, numpy.ndarray):
         assert data.step.ndim == 0
         assert "int" in str(data.step.dtype)
         data = slice(data.start, int(data.stop), data.step)
     Constant.__init__(self, type, data, name)
開發者ID:ChienliMa,項目名稱:Theano,代碼行數:16,代碼來源:type_other.py

示例5: test_none_Constant

def test_none_Constant():
    """ Tests equals

    We had an error in the past with unpickling
    """
    o1 = Constant(NoneTypeT(), None, name='NoneConst')
    o2 = Constant(NoneTypeT(), None, name='NoneConst')
    assert o1.equals(o2)
    assert NoneConst.equals(o1)
    assert o1.equals(NoneConst)
    assert NoneConst.equals(o2)
    assert o2.equals(NoneConst)

    # This trigger equals that returned the wrong answer in the past.
    import cPickle
    import theano
    from theano import tensor

    x = tensor.vector('x')
    y = tensor.argmax(x)
    f = theano.function([x], [y])
    cPickle.loads(cPickle.dumps(f))
開發者ID:Jackwangyang,項目名稱:Theano,代碼行數:22,代碼來源:test_type_other.py


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