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


Python type_check.expect方法代碼示例

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


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

示例1: check_type_forward

# 需要導入模塊: from chainer.utils import type_check [as 別名]
# 或者: from chainer.utils.type_check import expect [as 別名]
def check_type_forward(self, in_types):
        type_check.expect(in_types.size() == 2)
        c_type, x_type = in_types

        type_check.expect(
            c_type.dtype.kind == 'f',
            x_type.dtype == c_type.dtype,

            c_type.ndim >= 2,
            x_type.ndim >= 2,
            c_type.ndim == x_type.ndim,

            x_type.shape[0] <= c_type.shape[0],
            x_type.shape[1] == 4 * c_type.shape[1],
        )
        for i in six.moves.range(2, c_type.ndim.eval()):
            type_check.expect(x_type.shape[i] == c_type.shape[i]) 
開發者ID:fabiencro,項目名稱:knmt,代碼行數:19,代碼來源:ln_lstm.py

示例2: check_type_forward

# 需要導入模塊: from chainer.utils import type_check [as 別名]
# 或者: from chainer.utils.type_check import expect [as 別名]
def check_type_forward(self, in_types):
        type_check.expect(in_types.size() > 0)
        type_check.expect(in_types[0].ndim >
                          type_check.make_variable(self.axis, 'axis'))

        type_check.expect(
            -in_types[0].ndim <= self.axis,
            self.axis < in_types[0].ndim
        )
        ndim = type_check.eval(in_types[0].ndim)
        axis = self.axis % ndim
        for i in range(1, type_check.eval(in_types.size())):
            type_check.expect(
                in_types[0].dtype == in_types[i].dtype,
                in_types[0].ndim == in_types[i].ndim,
            )
            for d in range(0, ndim):
                if d == axis:
                    continue
                type_check.expect(in_types[0].shape[d] == in_types[i].shape[d]) 
開發者ID:pfnet-research,項目名稱:chainer-compiler,代碼行數:22,代碼來源:chainer_functions.py

示例3: check_type_forward

# 需要導入模塊: from chainer.utils import type_check [as 別名]
# 或者: from chainer.utils.type_check import expect [as 別名]
def check_type_forward(self, in_types):
        type_check._argname(in_types, ('x', 't'))
        x_type, t_type = in_types

        type_check.expect(
            x_type.dtype.kind == 'f',
            t_type.dtype.kind == 'i'
        )

        t_ndim = type_check.eval(t_type.ndim)
        type_check.expect(
            x_type.ndim >= t_type.ndim,
            x_type.shape[0] == t_type.shape[0],
            x_type.shape[2: t_ndim + 1] == t_type.shape[1:]
        )
        for i in six.moves.range(t_ndim + 1, type_check.eval(x_type.ndim)):
            type_check.expect(x_type.shape[i] == 1) 
開發者ID:osmr,項目名稱:imgclsmob,代碼行數:19,代碼來源:top_k_accuracy1.py

示例4: check_type_forward

# 需要導入模塊: from chainer.utils import type_check [as 別名]
# 或者: from chainer.utils.type_check import expect [as 別名]
def check_type_forward(self, in_types):
        type_check._argname(in_types, ('c', 'x'))
        c_type, x_type = in_types

        type_check.expect(
            c_type.dtype.kind == 'f',
            x_type.dtype == c_type.dtype,

            c_type.ndim >= 2,
            x_type.ndim >= 2,
            c_type.ndim == x_type.ndim,

            x_type.shape[0] <= c_type.shape[0],
            x_type.shape[1] == 4 * c_type.shape[1],
        )
        for i in six.moves.range(2, type_check.eval(c_type.ndim)):
            type_check.expect(x_type.shape[i] == c_type.shape[i]) 
開發者ID:chainer,項目名稱:chainer,代碼行數:19,代碼來源:lstm.py

示例5: check_type_forward

# 需要導入模塊: from chainer.utils import type_check [as 別名]
# 或者: from chainer.utils.type_check import expect [as 別名]
def check_type_forward(self, in_types):
        type_check.expect(in_types.size() >= 2)
        c_types = in_types[:-1]
        x_type = in_types[-1]
        n_ary = len(c_types)

        type_check.expect(x_type.ndim >= 2)
        for i in six.moves.range(len(c_types)):
            type_check.expect(
                c_types[i].dtype.kind == 'f',
                x_type.dtype == c_types[i].dtype,
                c_types[i].ndim >= 2,
                c_types[i].ndim == x_type.ndim,
                x_type.shape[0] == c_types[i].shape[0],
                x_type.shape[1] == (3 + n_ary) * c_types[i].shape[1],
            )
            for j in six.moves.range(2, type_check.eval(c_types[i].ndim)):
                type_check.expect(x_type.shape[i] == c_types[i].shape[j]) 
開發者ID:chainer,項目名稱:chainer,代碼行數:20,代碼來源:tree_lstm.py

示例6: check_type_forward

# 需要導入模塊: from chainer.utils import type_check [as 別名]
# 或者: from chainer.utils.type_check import expect [as 別名]
def check_type_forward(self, in_types):
        type_check.expect(in_types.size() > 0)
        type_check._argname((in_types[0],), ('x0',))

        ndim = type_check.eval(in_types[0].ndim)
        for i in six.moves.range(1, type_check.eval(in_types.size())):
            type_check._argname((in_types[i],), ('x{}'.format(i),))
            type_check.expect(
                in_types[0].dtype == in_types[i].dtype,
                in_types[0].ndim == in_types[i].ndim,
            )
            if ndim <= 1:
                continue
            for d in six.moves.range(0, ndim):
                if d == 1:
                    continue
                type_check.expect(in_types[0].shape[d] == in_types[i].shape[d]) 
開發者ID:chainer,項目名稱:chainer,代碼行數:19,代碼來源:hstack.py

示例7: check_type_forward

# 需要導入模塊: from chainer.utils import type_check [as 別名]
# 或者: from chainer.utils.type_check import expect [as 別名]
def check_type_forward(self, in_types):
        type_check.expect(in_types.size() > 0)
        type_check._argname((in_types[0],), ('x0',))

        ndim = type_check.eval(in_types[0].ndim)
        for i in six.moves.range(1, type_check.eval(in_types.size())):
            type_check._argname((in_types[i],), ('x{}'.format(i),))
            type_check.expect(
                in_types[0].dtype == in_types[i].dtype,
                in_types[0].ndim == in_types[i].ndim,
            )
            if ndim <= 2:
                type_check.expect(in_types[0].shape == in_types[i].shape)
                continue
            for d in six.moves.range(0, ndim):
                if d == 2:
                    continue
                type_check.expect(in_types[0].shape[d] == in_types[i].shape[d]) 
開發者ID:chainer,項目名稱:chainer,代碼行數:20,代碼來源:dstack.py

示例8: check_type_forward

# 需要導入模塊: from chainer.utils import type_check [as 別名]
# 或者: from chainer.utils.type_check import expect [as 別名]
def check_type_forward(self, in_types):
        type_check.expect(
            in_types.size() == 1,
            in_types[0].dtype == numpy.float32
        ) 
開發者ID:chainer,項目名稱:chainerrl,代碼行數:7,代碼來源:scale_grad.py

示例9: check_type_forward

# 需要導入模塊: from chainer.utils import type_check [as 別名]
# 或者: from chainer.utils.type_check import expect [as 別名]
def check_type_forward(self, in_types):
        type_check.expect(
            in_types[0].dtype.kind == 'f',
        ) 
開發者ID:chainer,項目名稱:chainerrl,代碼行數:6,代碼來源:weighted_sum_arrays.py

示例10: check_type_forward

# 需要導入模塊: from chainer.utils import type_check [as 別名]
# 或者: from chainer.utils.type_check import expect [as 別名]
def check_type_forward(self, in_types):
        type_check.expect(in_types.size() == 1,) 
開發者ID:chainer,項目名稱:chainerrl,代碼行數:4,代碼來源:invert_gradients.py

示例11: check_type_forward

# 需要導入模塊: from chainer.utils import type_check [as 別名]
# 或者: from chainer.utils.type_check import expect [as 別名]
def check_type_forward(self, in_types):
        type_check.expect(in_types.size() == 2,) 
開發者ID:chainer,項目名稱:chainerrl,代碼行數:4,代碼來源:lower_triangular_matrix.py

示例12: check_type_forward

# 需要導入模塊: from chainer.utils import type_check [as 別名]
# 或者: from chainer.utils.type_check import expect [as 別名]
def check_type_forward(self, in_types):
        type_check.expect(in_types.size() == 3)
        x_type, gamma_type, beta_type = in_types

        type_check.expect(
            x_type.dtype.kind == 'f',
            x_type.ndim == 2,
            gamma_type.ndim == 2,
            beta_type.ndim == 2,
            gamma_type.dtype == x_type.dtype,
            beta_type.dtype == x_type.dtype,
            gamma_type.shape == beta_type.shape,
            gamma_type.shape[0] == 1
        ) 
開發者ID:fabiencro,項目名稱:knmt,代碼行數:16,代碼來源:layer_normalization.py

示例13: check_type_forward

# 需要導入模塊: from chainer.utils import type_check [as 別名]
# 或者: from chainer.utils.type_check import expect [as 別名]
def check_type_forward(self, in_types):
        type_check.expect(in_types.size() == 1)
        a_type, = in_types

        type_check.expect(
            a_type.dtype.kind == 'f',
        )

        _check_ndim(a_type)

        a_idx = _get_check_index(self.transa, False)
        a_size = _get_size(a_type, a_idx, 1) 
開發者ID:fabiencro,項目名稱:knmt,代碼行數:14,代碼來源:constant_batch_mul.py

示例14: check_type_forward

# 需要導入模塊: from chainer.utils import type_check [as 別名]
# 或者: from chainer.utils.type_check import expect [as 別名]
def check_type_forward(self, in_types):
        type_check.expect(in_types.size() == 5)
        type_check.expect(in_types[0].dtype == numpy.float32)
        type_check.expect(in_types[1].dtype == numpy.float32)
        type_check.expect(in_types[2].dtype == numpy.float32)
        type_check.expect(in_types[3].dtype == numpy.float32)
        type_check.expect(in_types[4].dtype == numpy.float32) 
開發者ID:fabiencro,項目名稱:knmt,代碼行數:9,代碼來源:faster_gru.py

示例15: check_type_forward

# 需要導入模塊: from chainer.utils import type_check [as 別名]
# 或者: from chainer.utils.type_check import expect [as 別名]
def check_type_forward(self, in_types):
        x_type, t_type = in_types

        type_check.expect(
                x_type.dtype.kind == 'f',
                t_type.dtype.kind == 'i',
                t_type.ndim == x_type.ndim - 1,
                x_type.shape[0] == t_type.shape[0],
                x_type.shape[2:] == t_type.shape[1:]
                ) 
開發者ID:pfnet-research,項目名稱:chainer-compiler,代碼行數:12,代碼來源:nn.py


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