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


Python DataDesc.get_batch_axis方法代码示例

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


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

示例1: decide_slices

# 需要导入模块: from mxnet.io import DataDesc [as 别名]
# 或者: from mxnet.io.DataDesc import get_batch_axis [as 别名]
def decide_slices(self, data_shapes):
        """Decide the slices for each context according to the workload.

        Parameters
        ----------
        data_shapes : list
            list of (name, shape) specifying the shapes for the input data or label.
        """
        assert len(data_shapes) > 0
        major_axis = [DataDesc.get_batch_axis(x.layout) for x in data_shapes]

        for (name, shape), axis in zip(data_shapes, major_axis):
            if axis == -1:
                continue

            batch_size = shape[axis]
            if self.batch_size is not None:
                assert batch_size == self.batch_size, ("all data must have the same batch size: "
                                                       + ("batch_size = %d, but " % self.batch_size)
                                                       + ("%s has shape %s" % (name, shape)))
            else:
                self.batch_size = batch_size
                self.slices = _split_input_slice(self.batch_size, self.workload)

        return major_axis 
开发者ID:tonysy,项目名称:Deep-Feature-Flow-Segmentation,代码行数:27,代码来源:DataParallelExecutorGroup.py

示例2: decide_slices

# 需要导入模块: from mxnet.io import DataDesc [as 别名]
# 或者: from mxnet.io.DataDesc import get_batch_axis [as 别名]
def decide_slices(self, data_shapes):
        """Decide the slices for each context according to the workload.

        Parameters
        ----------
        data_shapes : list
            list of (name, shape) specifying the shapes for the input data or label.
        """
        assert len(data_shapes) > 0
        major_axis = [DataDesc.get_batch_axis(x.layout) for x in data_shapes]

        for (name, shape), axis in zip(data_shapes, major_axis):
            if axis == -1:
                continue

            batch_size = shape[axis]
            if self.batch_size is not None:
                assert batch_size == self.batch_size, (
                    "all data must have the same batch size: "
                    + ("batch_size = %d, but " % self.batch_size)
                    + ("%s has shape %s" % (name, shape))
                )
            else:
                self.batch_size = batch_size
                self.slices = _split_input_slice(self.batch_size, self.workload)

        return major_axis 
开发者ID:liyi14,项目名称:mx-DeepIM,代码行数:29,代码来源:DataParallelExecutorGroup.py


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