当前位置: 首页>>代码示例>>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;未经允许,请勿转载。