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