當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。