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


Python type_check.eval方法代碼示例

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


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

示例1: check_type_forward

# 需要導入模塊: from chainer.utils import type_check [as 別名]
# 或者: from chainer.utils.type_check import eval [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

示例2: check_type_forward

# 需要導入模塊: from chainer.utils import type_check [as 別名]
# 或者: from chainer.utils.type_check import eval [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

示例3: check_type_forward

# 需要導入模塊: from chainer.utils import type_check [as 別名]
# 或者: from chainer.utils.type_check import eval [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

示例4: check_type_forward

# 需要導入模塊: from chainer.utils import type_check [as 別名]
# 或者: from chainer.utils.type_check import eval [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

示例5: check_type_forward

# 需要導入模塊: from chainer.utils import type_check [as 別名]
# 或者: from chainer.utils.type_check import eval [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 six.moves.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 six.moves.range(0, ndim):
                if d == axis:
                    continue
                type_check.expect(in_types[0].shape[d] == in_types[i].shape[d]) 
開發者ID:chainer,項目名稱:chainer,代碼行數:22,代碼來源:concat.py

示例6: check_type_forward

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

        ndim = type_check.make_variable(len(self._shape), 'len(shape)')
        type_check.expect(in_types[0].ndim <= ndim)

        shape = type_check.eval(in_types[0].shape)
        # check the shape in inverse order
        for i in six.moves.range(-1, -len(shape) - 1, -1):
            if shape[i] == self._shape[i] or shape[i] == 1:
                continue
            expect = 'in_type[0].shape[%d] == %d' % (i, self._shape[i])
            if self._shape[i] != 1:
                expect += ' or in_type[0].shape[%d] == 1' % i
            actual = 'in_type[0].shape: %s' % str(shape)
            raise type_check.InvalidType(expect, actual) 
開發者ID:chainer,項目名稱:chainer,代碼行數:18,代碼來源:broadcast.py

示例7: check_type_forward

# 需要導入模塊: from chainer.utils import type_check [as 別名]
# 或者: from chainer.utils.type_check import eval [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 eval [as 別名]
def check_type_forward(self, in_types):
        n_in = in_types.size()
        type_check.expect(2 <= n_in, n_in <= 3)
        x_type, w_type = in_types[:2]
        type_check._argname((x_type, w_type), ('x', 'W'))

        type_check.expect(
            x_type.dtype.kind == 'f',
            w_type.dtype.kind == 'f',
            x_type.ndim == 2,
            w_type.ndim == 2,
            x_type.shape[1] == w_type.shape[1],
        )
        if type_check.eval(n_in) == 3:
            b_type = in_types[2]
            type_check._argname((b_type,), ('b',))
            type_check.expect(
                b_type.dtype == x_type.dtype,
                b_type.ndim == 1,
                b_type.shape[0] == w_type.shape[0],
            ) 
開發者ID:chainer,項目名稱:chainer,代碼行數:23,代碼來源:linear.py

示例9: check_type_forward

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

        x_type = in_types[0]
        w_type = in_types[1]
        type_check.expect(
            x_type.dtype.kind == 'f',
            w_type.dtype.kind == 'f',
            x_type.ndim == 4,
            w_type.ndim == 4,
            x_type.shape[1] == w_type.shape[1] * self.groups,
        )

        if type_check.eval(n_in) == 3:
            b_type = in_types[2]
            type_check.expect(
                b_type.dtype == x_type.dtype,
                b_type.ndim == 1,
                b_type.shape[0] == w_type.shape[0],
            ) 
開發者ID:chainer,項目名稱:chainer,代碼行數:23,代碼來源:convolution_2d.py

示例10: check_type_forward

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

        x_type = in_types[0]
        w_type = in_types[1]
        type_check.expect(
            x_type.dtype.kind == 'f',
            w_type.dtype.kind == 'f',
            x_type.ndim == self.ndim + 2,
            w_type.ndim == self.ndim + 2,
            # Need to consider the case that group count > 1.
            # x_type.shape[1] == w_type.shape[1],
        )

        if type_check.eval(n_in) == 3:
            b_type = in_types[2]
            type_check.expect(
                b_type.dtype.kind == 'f',
                b_type.ndim == 1,
                b_type.shape[0] == w_type.shape[0],
            ) 
開發者ID:chainer,項目名稱:chainer,代碼行數:24,代碼來源:convolution_nd.py

示例11: check_type_forward

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

        type_check.expect(
            x_type.dtype.kind == 'f',
            w_type.dtype.kind == 'f',
            x_type.ndim == 4,
            w_type.ndim == 6,
            x_type.shape[1] == w_type.shape[3],
        )
        if type_check.eval(n_in) == 3:
            b_type = in_types[2]
            type_check.expect(
                b_type.dtype == x_type.dtype,
                b_type.ndim == 3,
                b_type.shape == w_type.shape[:3]
            ) 
開發者ID:chainer,項目名稱:chainer,代碼行數:21,代碼來源:local_convolution_2d.py

示例12: check_type_forward

# 需要導入模塊: from chainer.utils import type_check [as 別名]
# 或者: from chainer.utils.type_check import eval [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',
            gamma_type.dtype.kind == 'f',
            gamma_type.dtype == beta_type.dtype,
            gamma_type.shape == beta_type.shape,
        )
        _x_ndim = type_check.eval(x_type.ndim)
        _gamma_ndim = type_check.eval(gamma_type.ndim)
        _axis = _compute_axis(_x_ndim, _gamma_ndim, self.axis)
        type_check.expect(
            x_type.ndim >= len(_axis),
        )
        _key_axis = _compute_key_axis(_x_ndim, _gamma_ndim, _axis)
        type_check.expect(
            gamma_type.ndim == len(_key_axis),
        )
        for i in range(len(_key_axis)):
            type_check.expect(
                x_type.shape[_key_axis[i]] == gamma_type.shape[i],
            ) 
開發者ID:chainer,項目名稱:chainer,代碼行數:25,代碼來源:batch_normalization.py

示例13: check_type_forward

# 需要導入模塊: from chainer.utils import type_check [as 別名]
# 或者: from chainer.utils.type_check import eval [as 別名]
def check_type_forward(self, in_types):
        type_check.expect(in_types.size() == 5)
        x_type, gamma_type, beta_type, mean_type, var_type = in_types
        M = type_check.eval(gamma_type.ndim)
        type_check.expect(
            x_type.dtype.kind == 'f',
            x_type.ndim >= gamma_type.ndim + 1,
            x_type.shape[1:1 + M] == gamma_type.shape,
            # TODO(beam2d): Check shape
            gamma_type.dtype == x_type.dtype,
            beta_type.dtype == x_type.dtype,
            gamma_type.shape == beta_type.shape,
            mean_type.dtype == x_type.dtype,
            mean_type.shape == gamma_type.shape,
            var_type.dtype == x_type.dtype,
            var_type.shape == gamma_type.shape,
        ) 
開發者ID:yukitsuji,項目名稱:voxelnet_chainer,代碼行數:19,代碼來源:active_batchnorm.py

示例14: check_type_forward

# 需要導入模塊: from chainer.utils import type_check [as 別名]
# 或者: from chainer.utils.type_check import eval [as 別名]
def check_type_forward(self, in_types):
        type_check.expect(in_types.size() == 5)
        x_type, gamma_type, beta_type, mean_type, var_type = in_types
        M = type_check.eval(gamma_type.ndim)
        type_check.expect(
            x_type.dtype.kind == 'f',
            x_type.ndim >= gamma_type.ndim + 1,
            x_type.shape[1:1 + M] == gamma_type.shape,
            gamma_type.dtype == x_type.dtype,
            beta_type.dtype == x_type.dtype,
            gamma_type.shape == beta_type.shape,
            mean_type.dtype == x_type.dtype,
            mean_type.shape == gamma_type.shape,
            var_type.dtype == x_type.dtype,
            var_type.shape == gamma_type.shape,
        ) 
開發者ID:yukitsuji,項目名稱:voxelnet_chainer,代碼行數:18,代碼來源:func_active_bn.py

示例15: _get_size

# 需要導入模塊: from chainer.utils import type_check [as 別名]
# 或者: from chainer.utils.type_check import eval [as 別名]
def _get_size(typ, index, vector_ndim):
    if type_check.eval(typ.ndim) == vector_ndim and \
       type_check.eval(index) == vector_ndim:
        return 1
    else:
        return typ.shape[index] 
開發者ID:fabiencro,項目名稱:knmt,代碼行數:8,代碼來源:constant_batch_mul.py


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