当前位置: 首页>>代码示例>>Python>>正文


Python chainer.is_debug方法代码示例

本文整理汇总了Python中chainer.is_debug方法的典型用法代码示例。如果您正苦于以下问题:Python chainer.is_debug方法的具体用法?Python chainer.is_debug怎么用?Python chainer.is_debug使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在chainer的用法示例。


在下文中一共展示了chainer.is_debug方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: forward

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import is_debug [as 别名]
def forward(self, *xs):
        """Applies broadcasted elementwise summation.

        Args:
            xs (list of Variables): Input variables whose length should
                be one if the link has a learnable bias parameter, otherwise
                should be two.
        """
        axis = self.axis

        # Case of only one argument where b is a learnt parameter.
        if hasattr(self, 'b'):
            if chainer.is_debug():
                assert len(xs) == 1
            x, = xs
            b = self.b
            return bias.bias(x, b, axis)
        # Case of two arguments where b is given as an argument.
        else:
            if chainer.is_debug():
                assert len(xs) == 2
            x, y = xs
            return bias.bias(x, y, axis) 
开发者ID:pfnet-research,项目名称:chainer-stylegan,代码行数:25,代码来源:bias.py

示例2: forward

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import is_debug [as 别名]
def forward(self, inputs):
        self.retain_inputs((1,))
        x, t = inputs
        self._in_shape = x.shape
        self._in_dtype = x.dtype
        if chainer.is_debug():
            if not ((0 <= t).all() and
                    (t < x.shape[1]).all()):
                msg = 'Each label `t` need to satisfty `0 <= t < x.shape[1]`'
                raise ValueError(msg)

        xp = backend.get_array_module(x)
        if xp is numpy:
            # This code is equivalent to `t.choose(x.T)`, but `numpy.choose`
            # does not work when `x.shape[1] > 32`.
            return x[six.moves.range(t.size), t],
        else:
            y = cuda.elementwise(
                'S t, raw T x',
                'T y',
                'int ind[] = {i, t}; y = x[ind];',
                'getitem_fwd'
            )(t, x)
            return y, 
开发者ID:chainer,项目名称:chainer,代码行数:26,代码来源:select_item.py

示例3: __init__

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import is_debug [as 别名]
def __init__(self, slices):
        if isinstance(slices, list):
            if all([isinstance(s, int) for s in slices]):
                slices = slices,
            slices = tuple(slices)
        elif not isinstance(slices, tuple):
            slices = slices,

        if chainer.is_debug():
            n_ellipses = 0
            for s in slices:
                if s is Ellipsis:
                    n_ellipses += 1
            if n_ellipses > 1:
                raise ValueError('Only one Ellipsis is allowed')

        self.slices = slices 
开发者ID:chainer,项目名称:chainer,代码行数:19,代码来源:get_item.py

示例4: forward

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import is_debug [as 别名]
def forward(self, inputs):
        self.retain_inputs((0,))
        x, W = inputs
        self._w_shape = W.shape

        xp = backend.get_array_module(*inputs)
        if chainer.is_debug():
            valid_x = xp.logical_and(0 <= x, x < len(W))
            if self.ignore_label is not None:
                valid_x = xp.logical_or(valid_x, x == self.ignore_label)
            if not valid_x.all():
                raise ValueError('Each not ignored `x` value need to satisfy '
                                 '`0 <= x < len(W)`')

        if self.ignore_label is not None:
            mask = (x == self.ignore_label)
            return xp.where(mask[..., None], 0, W[xp.where(mask, 0, x)]),

        return W[x], 
开发者ID:chainer,项目名称:chainer,代码行数:21,代码来源:embed_id.py

示例5: forward

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import is_debug [as 别名]
def forward(self, axis, gamma, x, x_layout, xp, expander,
                beta, eps, decay, running_mean, running_var):
        if running_mean is not None:
            mean = running_mean
            var = running_var
        else:
            # Create dummies.
            mean = xp.zeros_like(gamma, dtype=x.dtype)
            var = xp.zeros_like(gamma, dtype=x.dtype)

        # mean and inv_std are used as buffers to save
        # intermediate results computed during forward pass. These buffers
        # are used to speed-up backward pass.
        cudnn_x_layout = cuda._get_cudnn_tensor_layout_x(x_layout)
        reserve_space, y, mean, inv_std = (
            cudnn.batch_normalization_forward_training_ex(
                x, gamma, beta, mean, var, None, None,
                eps, decay, self.is_for_conv2d,
                self.cudnn_mode, chainer.is_debug(),
                d_layout=cudnn_x_layout))

        y_layout = x_layout
        return (
            y, y_layout, running_mean, running_var, mean, var, inv_std,
            reserve_space) 
开发者ID:chainer,项目名称:chainer,代码行数:27,代码来源:batch_normalization.py

示例6: _scan_directory

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import is_debug [as 别名]
def _scan_directory(fs, directory):
    local_files = []
    try:
        local_files = fs.list(directory)
    except Exception as e:
        if chainer.is_debug():
            print("Cannot list directory {}: {}".format(directory, e))

    local_files = filter(lambda s: not s.startswith('tmp'), local_files)
    files = filter(None, [(_parse_filename(f), f) for f in local_files])
    files = list(files)
    files.sort()

    if len(files) > 0:
        _i, filename = max(files)
        return filename
    else:
        return None 
开发者ID:pfnet,项目名称:pfio,代码行数:20,代码来源:snapshot.py

示例7: forward

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import is_debug [as 别名]
def forward(self, *xs):
        """Applies broadcasted elementwise product.

        Args:
            xs (list of Variables): Input variables whose length should
                be one if the link has a learnable weight parameter, otherwise
                should be two.
        """
        axis = self.axis

        # Case of only one argument where W is a learnt parameter.
        if hasattr(self, 'W'):
            if chainer.is_debug():
                assert len(xs) == 1
            x, = xs
            W = self.W
            z = scale.scale(x, W, axis)
        # Case of two arguments where W is given as an argument.
        else:
            if chainer.is_debug():
                assert len(xs) == 2
            x, y = xs
            z = scale.scale(x, y, axis)

        # Forward propagate bias term if given.
        if hasattr(self, 'bias'):
            return self.bias(z)
        else:
            return z 
开发者ID:pfnet-research,项目名称:chainer-stylegan,代码行数:31,代码来源:scale.py

示例8: setUp

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import is_debug [as 别名]
def setUp(self):
        self.original_debug = chainer.is_debug()
        chainer.set_debug(True)
        self.one = numpy.array([1], numpy.float32)
        self.f = chainer.FunctionNode() 
开发者ID:chainer,项目名称:chainer,代码行数:7,代码来源:test_function_node.py

示例9: setUp

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import is_debug [as 别名]
def setUp(self):
        self.original_debug = chainer.is_debug()
        chainer.set_debug(True)
        self.one = numpy.array([1], numpy.float32)
        self.f = chainer.Function() 
开发者ID:chainer,项目名称:chainer,代码行数:7,代码来源:test_function.py

示例10: setUp

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import is_debug [as 别名]
def setUp(self):
        self.link = links.EmbedID(2, 2, ignore_label=self.ignore_label)
        self.t = numpy.array([self.t_value], dtype=numpy.int32)
        self.original_debug = chainer.is_debug()
        chainer.set_debug(True) 
开发者ID:chainer,项目名称:chainer,代码行数:7,代码来源:test_embed_id.py

示例11: setUp

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import is_debug [as 别名]
def setUp(self):
        self.x = numpy.arange(10).reshape((2, 5)).astype('f')
        self.ind = numpy.array(self.indices, 'i')
        self.debug = chainer.is_debug()
        chainer.set_debug(True) 
开发者ID:chainer,项目名称:chainer,代码行数:7,代码来源:test_permutate.py

示例12: setUp

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import is_debug [as 别名]
def setUp(self):
        self.default_debug = chainer.is_debug()
        chainer.set_debug(True) 
开发者ID:chainer,项目名称:chainer,代码行数:5,代码来源:test_split_axis.py

示例13: setUp

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import is_debug [as 别名]
def setUp(self):
        self.x = numpy.random.uniform(-1, 1, (1, 2)).astype(numpy.float32)
        self.t = numpy.array([self.t_value], dtype=numpy.int32)
        self.original_debug = chainer.is_debug()
        chainer.set_debug(True) 
开发者ID:chainer,项目名称:chainer,代码行数:7,代码来源:test_select_item.py

示例14: setUp

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import is_debug [as 别名]
def setUp(self):
        self.default_debug = chainer.is_debug()
        chainer.set_debug(True)

        self.a_data = numpy.random.uniform(-1, 1, (4, 3, 2))
        self.b_data = numpy.random.uniform(-1, 1, (2, 2)) 
开发者ID:chainer,项目名称:chainer,代码行数:8,代码来源:test_scatter_add.py

示例15: setUp

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import is_debug [as 别名]
def setUp(self):
        self.x = numpy.random.uniform(-1, 1, (2, 2)).astype(numpy.float32)
        # `0` is required to avoid NaN
        self.t = numpy.array([self.t_value, 0], dtype=numpy.int32)
        self.original_debug = chainer.is_debug()
        chainer.set_debug(True) 
开发者ID:chainer,项目名称:chainer,代码行数:8,代码来源:test_softmax_cross_entropy.py


注:本文中的chainer.is_debug方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。