本文整理汇总了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])
示例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])
示例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)
示例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])
示例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])
示例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])
示例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])
示例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
)
示例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',
)
示例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,)
示例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,)
示例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
)
示例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)
示例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)
示例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:]
)