當前位置: 首頁>>代碼示例>>Python>>正文


Python io.DataDesc方法代碼示例

本文整理匯總了Python中mxnet.io.DataDesc方法的典型用法代碼示例。如果您正苦於以下問題:Python io.DataDesc方法的具體用法?Python io.DataDesc怎麽用?Python io.DataDesc使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mxnet.io的用法示例。


在下文中一共展示了io.DataDesc方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: next

# 需要導入模塊: from mxnet import io [as 別名]
# 或者: from mxnet.io import DataDesc [as 別名]
def next(self):
        """Returns the next batch of data."""
        if self.curr_idx == len(self.idx):
            raise StopIteration
        #i = batches index, j = starting record
        i, j = self.idx[self.curr_idx] 
        self.curr_idx += 1

        indices = self.ndindex[i][j:j + self.batch_size]
        sentences = self.ndsent[i][j:j + self.batch_size]
        characters = self.ndchar[i][j:j + self.batch_size]
        label = self.ndlabel[i][j:j + self.batch_size]

        return DataBatch([sentences, characters], [label], pad=0, index = indices, bucket_key=self.buckets[i],
                         provide_data=[DataDesc(name=self.data_names[0], shape=sentences.shape, layout=self.layout),
                                       DataDesc(name=self.data_names[1], shape=characters.shape, layout=self.layout)],
                         provide_label=[DataDesc(name=self.label_name, shape=label.shape, layout=self.layout)]) 
開發者ID:awslabs,項目名稱:dynamic-training-with-apache-mxnet-on-aws,代碼行數:19,代碼來源:iterators.py

示例2: create_batch

# 需要導入模塊: from mxnet import io [as 別名]
# 或者: from mxnet.io import DataDesc [as 別名]
def create_batch(self, frame):
        """
        :param frame: an (w,h,channels) numpy array (image)
        :return: DataBatch of (1,channels,data_shape,data_shape)
        """
        frame_resize = mx.nd.array(cv2.resize(frame, (self.data_shape[0], self.data_shape[1])))
        #frame_resize = mx.img.imresize(frame, self.data_shape[0], self.data_shape[1], cv2.INTER_LINEAR)
        # Change dimensions from (w,h,channels) to (channels, w, h)
        frame_t = mx.nd.transpose(frame_resize, axes=(2,0,1))
        frame_norm = frame_t - self.mean_pixels_nd
        # Add dimension for batch, results in (1,channels,w,h)
        batch_frame = [mx.nd.expand_dims(frame_norm, axis=0)]
        batch_shape = [DataDesc('data', batch_frame[0].shape)]
        batch = DataBatch(data=batch_frame, provide_data=batch_shape)
        return batch 
開發者ID:awslabs,項目名稱:dynamic-training-with-apache-mxnet-on-aws,代碼行數:17,代碼來源:detector.py

示例3: provide_data

# 需要導入模塊: from mxnet import io [as 別名]
# 或者: from mxnet.io import DataDesc [as 別名]
def provide_data(self):
        """The name and shape of data provided by this iterator"""
        if self.rename_data is None:
            return sum([i.provide_data for i in self.iters], [])
        else:
            return sum([[
                DataDesc(r[x.name], x.shape, x.dtype)
                if isinstance(x, DataDesc) else DataDesc(*x)
                for x in i.provide_data
            ] for r, i in zip(self.rename_data, self.iters)], []) 
開發者ID:tonysy,項目名稱:Deep-Feature-Flow-Segmentation,代碼行數:12,代碼來源:PrefetchingIter.py

示例4: provide_label

# 需要導入模塊: from mxnet import io [as 別名]
# 或者: from mxnet.io import DataDesc [as 別名]
def provide_label(self):
        """The name and shape of label provided by this iterator"""
        if self.rename_label is None:
            return sum([i.provide_label for i in self.iters], [])
        else:
            return sum([[
                DataDesc(r[x.name], x.shape, x.dtype)
                if isinstance(x, DataDesc) else DataDesc(*x)
                for x in i.provide_label
            ] for r, i in zip(self.rename_label, self.iters)], []) 
開發者ID:tonysy,項目名稱:Deep-Feature-Flow-Segmentation,代碼行數:12,代碼來源:PrefetchingIter.py

示例5: model_fn

# 需要導入模塊: from mxnet import io [as 別名]
# 或者: from mxnet.io import DataDesc [as 別名]
def model_fn(path_to_model_files):
    from mxnet.io import DataDesc

    loaded_symbol = mx.symbol.load(os.path.join(path_to_model_files, "symbol"))
    created_module = mx.mod.Module(symbol=loaded_symbol)
    created_module.bind([DataDesc("data", (1, 1, 28, 28))])
    created_module.load_params(os.path.join(path_to_model_files, "params"))
    return created_module


# --- Option 1 - provide just 1 entry point for end2end prediction ---
# if this function is specified, no other overwriting described in Option 2 will have effect
# returns serialized data and content type it has used 
開發者ID:aws,項目名稱:sagemaker-python-sdk,代碼行數:15,代碼來源:mnist_hosting_with_custom_handlers.py

示例6: provide_data

# 需要導入模塊: from mxnet import io [as 別名]
# 或者: from mxnet.io import DataDesc [as 別名]
def provide_data(self):
        """The name and shape of data provided by this iterator"""
        if self.rename_data is None:
            return sum([i.provide_data for i in self.iters], [])
        else:
            return sum(
                [
                    [
                        DataDesc(r[x.name], x.shape, x.dtype) if isinstance(x, DataDesc) else DataDesc(*x)
                        for x in i.provide_data
                    ]
                    for r, i in zip(self.rename_data, self.iters)
                ],
                [],
            ) 
開發者ID:liyi14,項目名稱:mx-DeepIM,代碼行數:17,代碼來源:PrefetchingIter.py

示例7: provide_label

# 需要導入模塊: from mxnet import io [as 別名]
# 或者: from mxnet.io import DataDesc [as 別名]
def provide_label(self):
        """The name and shape of label provided by this iterator"""
        if self.rename_label is None:
            return sum([i.provide_label for i in self.iters], [])
        else:
            return sum(
                [
                    [
                        DataDesc(r[x.name], x.shape, x.dtype) if isinstance(x, DataDesc) else DataDesc(*x)
                        for x in i.provide_label
                    ]
                    for r, i in zip(self.rename_label, self.iters)
                ],
                [],
            ) 
開發者ID:liyi14,項目名稱:mx-DeepIM,代碼行數:17,代碼來源:PrefetchingIter.py


注:本文中的mxnet.io.DataDesc方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。