Python mxnet.io.DataDesc() Examples
The following are 30
code examples of mxnet.io.DataDesc().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
mxnet.io
, or try the search function
.
Example #1
Source File: iterators.py From dynamic-training-with-apache-mxnet-on-aws with Apache License 2.0 | 6 votes |
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)])
Example #2
Source File: iterators.py From training_results_v0.6 with Apache License 2.0 | 6 votes |
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)])
Example #3
Source File: PrefetchingIter.py From Deformable-ConvNets with MIT License | 5 votes |
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)], [])
Example #4
Source File: PrefetchingIter.py From Decoupled-Classification-Refinement with MIT License | 5 votes |
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)], [])
Example #5
Source File: PrefetchingIter.py From RoITransformer_DOTA with MIT License | 5 votes |
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)], [])
Example #6
Source File: PrefetchingIter.py From RoITransformer_DOTA with MIT License | 5 votes |
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)], [])
Example #7
Source File: PrefetchingIter.py From Relation-Networks-for-Object-Detection with MIT License | 5 votes |
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)], [])
Example #8
Source File: PrefetchingIter.py From Relation-Networks-for-Object-Detection with MIT License | 5 votes |
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)], [])
Example #9
Source File: PrefetchingIter.py From Accel with MIT License | 5 votes |
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)], [])
Example #10
Source File: PrefetchingIter.py From Accel with MIT License | 5 votes |
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)], [])
Example #11
Source File: PrefetchingIter.py From mx-DeepIM with Apache License 2.0 | 5 votes |
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) ], [], )
Example #12
Source File: PrefetchingIter.py From mx-DeepIM with Apache License 2.0 | 5 votes |
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) ], [], )
Example #13
Source File: PrefetchingIter.py From Faster_RCNN_for_DOTA with Apache License 2.0 | 5 votes |
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)], [])
Example #14
Source File: PrefetchingIter.py From Faster_RCNN_for_DOTA with Apache License 2.0 | 5 votes |
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)], [])
Example #15
Source File: PrefetchingIter.py From Sequence-Level-Semantics-Aggregation with Apache License 2.0 | 5 votes |
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)], [])
Example #16
Source File: PrefetchingIter.py From Sequence-Level-Semantics-Aggregation with Apache License 2.0 | 5 votes |
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)], [])
Example #17
Source File: PrefetchingIter.py From Decoupled-Classification-Refinement with MIT License | 5 votes |
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)], [])
Example #18
Source File: detector.py From dynamic-training-with-apache-mxnet-on-aws with Apache License 2.0 | 5 votes |
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
Example #19
Source File: PrefetchingIter.py From kaggle-rsna18 with MIT License | 5 votes |
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)], [])
Example #20
Source File: PrefetchingIter.py From Deep-Feature-Flow-Segmentation with MIT License | 5 votes |
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)], [])
Example #21
Source File: PrefetchingIter.py From Deep-Feature-Flow-Segmentation with MIT License | 5 votes |
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)], [])
Example #22
Source File: mnist_hosting_with_custom_handlers.py From sagemaker-python-sdk with Apache License 2.0 | 5 votes |
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
Example #23
Source File: detector.py From training_results_v0.6 with Apache License 2.0 | 5 votes |
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
Example #24
Source File: PrefetchingIter.py From kaggle-rsna18 with MIT License | 5 votes |
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)], [])
Example #25
Source File: PrefetchingIter.py From kaggle-rsna18 with MIT License | 5 votes |
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)], [])
Example #26
Source File: PrefetchingIter.py From Deformable-ConvNets with MIT License | 5 votes |
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)], [])
Example #27
Source File: PrefetchingIter.py From kaggle-rsna18 with MIT License | 5 votes |
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)], [])
Example #28
Source File: PrefetchingIter.py From MANet_for_Video_Object_Detection with Apache License 2.0 | 5 votes |
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)], [])
Example #29
Source File: PrefetchingIter.py From MANet_for_Video_Object_Detection with Apache License 2.0 | 5 votes |
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)], [])
Example #30
Source File: PrefetchingIter.py From Deep-Feature-Flow with MIT License | 5 votes |
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)], [])