本文整理汇总了Python中chainer.utils.type_check._argname方法的典型用法代码示例。如果您正苦于以下问题:Python type_check._argname方法的具体用法?Python type_check._argname怎么用?Python type_check._argname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chainer.utils.type_check
的用法示例。
在下文中一共展示了type_check._argname方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check_type_forward
# 需要导入模块: from chainer.utils import type_check [as 别名]
# 或者: from chainer.utils.type_check import _argname [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 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 range(0, ndim):
if d == 1:
continue
type_check.expect(in_types[0].shape[d] == in_types[i].shape[d])
示例2: check_type_forward
# 需要导入模块: from chainer.utils import type_check [as 别名]
# 或者: from chainer.utils.type_check import _argname [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)
示例3: check_type_forward
# 需要导入模块: from chainer.utils import type_check [as 别名]
# 或者: from chainer.utils.type_check import _argname [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])
示例4: check_type_forward
# 需要导入模块: from chainer.utils import type_check [as 别名]
# 或者: from chainer.utils.type_check import _argname [as 别名]
def check_type_forward(self, in_types):
type_check._argname(in_types, ('x',))
x_type, = in_types
if self._cnt == 0:
type_check.expect(
type_check.prod(x_type.shape) == type_check.prod(self.shape))
else:
known_size = 1
for s in self.shape:
if s > 0:
known_size *= s
size_var = type_check.make_variable(
known_size, 'known_size(=%d)' % known_size)
type_check.expect(
type_check.prod(x_type.shape) % size_var == 0)
示例5: check_type_forward
# 需要导入模块: from chainer.utils import type_check [as 别名]
# 或者: from chainer.utils.type_check import _argname [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])
示例6: check_type_forward
# 需要导入模块: from chainer.utils import type_check [as 别名]
# 或者: from chainer.utils.type_check import _argname [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)
示例7: check_type_forward
# 需要导入模块: from chainer.utils import type_check [as 别名]
# 或者: from chainer.utils.type_check import _argname [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])
示例8: check_type_forward
# 需要导入模块: from chainer.utils import type_check [as 别名]
# 或者: from chainer.utils.type_check import _argname [as 别名]
def check_type_forward(self, in_types):
type_check._argname(in_types, ('a', 'b'))
a_type, b_type = in_types
type_check.expect(
a_type.dtype == numpy.float32,
b_type.dtype == numpy.float32
)
_check_ndim(a_type, lower=2, upper=3)
_check_ndim(b_type, lower=2, upper=3)
a_idx = _get_check_index(self.transa, False, row_idx=1, col_idx=2)
b_idx = _get_check_index(self.transb, True, row_idx=1, col_idx=2)
a_size = _get_size(a_type, a_idx)
b_size = _get_size(b_type, b_idx)
type_check.expect(
a_size == b_size
)
示例9: check_type_forward
# 需要导入模块: from chainer.utils import type_check [as 别名]
# 或者: from chainer.utils.type_check import _argname [as 别名]
def check_type_forward(self, in_types):
type_check._argname(in_types, ('x',))
type_check.expect(in_types[0].dtype.kind == 'f')
if self.axis is not None:
for axis in self.axis:
if axis >= 0:
type_check.expect(
axis < in_types[0].ndim,
)
else:
type_check.expect(
-axis - 1 < in_types[0].ndim,
)
# TODO(kataoka): override `forward_chainerx` if `chainerx.mean` does not
# overflow for large float16 inputs
示例10: check_type_forward
# 需要导入模块: from chainer.utils import type_check [as 别名]
# 或者: from chainer.utils.type_check import _argname [as 别名]
def check_type_forward(self, in_types):
if hasattr(type_check, '_argname'):
# typecheck._argname is introduced by Chainer v6
type_check._argname(in_types, ('x',))
x_type, = in_types
type_check.expect(x_type.dtype.kind == 'f')
示例11: check_type_forward
# 需要导入模块: from chainer.utils import type_check [as 别名]
# 或者: from chainer.utils.type_check import _argname [as 别名]
def check_type_forward(self, in_types):
type_check._argname(in_types, ('c_prev1', 'c_prev2', 'x1', 'x2'))
c1_type, c2_type, x1_type, x2_type = in_types
type_check.expect(
c1_type.dtype.kind == 'f',
c2_type.dtype == c1_type.dtype,
x1_type.dtype == c1_type.dtype,
x2_type.dtype == c1_type.dtype,
c1_type.ndim >= 2,
c2_type.ndim >= 2,
x1_type.ndim >= 2,
x2_type.ndim >= 2,
c1_type.ndim == x1_type.ndim,
c1_type.ndim == c2_type.ndim,
c1_type.ndim == x2_type.ndim,
c1_type.shape[0] == x1_type.shape[0],
c1_type.shape[0] == c2_type.shape[0],
c1_type.shape[0] == x2_type.shape[0],
x1_type.shape[1] == 4 * c1_type.shape[1],
x2_type.shape[1] == 4 * c2_type.shape[1],
)
for i in range(2, type_check.eval(c1_type.ndim)):
type_check.expect(x1_type.shape[i] == c1_type.shape[i])
type_check.expect(x2_type.shape[i] == c2_type.shape[i])
type_check.expect(x1_type.shape[i] == x2_type.shape[i])
示例12: check_type_forward
# 需要导入模块: from chainer.utils import type_check [as 别名]
# 或者: from chainer.utils.type_check import _argname [as 别名]
def check_type_forward(self, in_types):
type_check._argname(in_types, ('x', 't'))
x_type, t_type = in_types
type_check.expect(
t_type.dtype.kind == 'i',
x_type.ndim == 2,
t_type.ndim == 1,
x_type.shape[0] == t_type.shape[0],
)
示例13: check_type_forward
# 需要导入模块: from chainer.utils import type_check [as 别名]
# 或者: from chainer.utils.type_check import _argname [as 别名]
def check_type_forward(self, in_types):
type_check._argname(in_types, ('x',))
x_type, = in_types
if self.axis >= 0:
type_check.expect(x_type.ndim >= self.axis)
else:
type_check.expect(x_type.ndim >= -self.axis - 1)
示例14: check_type_forward
# 需要导入模块: from chainer.utils import type_check [as 别名]
# 或者: from chainer.utils.type_check import _argname [as 别名]
def check_type_forward(self, in_types):
type_check._argname(in_types, ('x',))
示例15: check_type_forward
# 需要导入模块: from chainer.utils import type_check [as 别名]
# 或者: from chainer.utils.type_check import _argname [as 别名]
def check_type_forward(self, in_types):
type_check._argname(in_types, ('x',))
x_type = in_types[0]
type_check.expect(
x_type.dtype == numpy.float32,
x_type.ndim == 4
)