sandeep-krishnamurthy commented on a change in pull request #13930: Add batchify transformer to help end to end models URL: https://github.com/apache/incubator-mxnet/pull/13930#discussion_r249938673
########## File path: python/mxnet/gluon/data/vision/transforms.py ########## @@ -485,3 +485,52 @@ def __init__(self, alpha): def hybrid_forward(self, F, x): return F.image.random_lighting(x, self._alpha) + + +class Batchify(HybridBlock): + """Joins a list of tensors of shape (C x H x W) into a single + tensor of shape (N x C x H x W) where N is the number of input + tensors. + + If the input is a single tensor of shape (C x H x W) it is bathchified + to a tensor of shape (1 x C x H x W). + + This transformer is useful when transformation pipeline is fused into + neural network graph resulting in single model/graph. When running + mini batch inference on such graph, raw input tensors, before transformations, + can be of different shapes, hence, cannot be batched into single tensor. Hence, + input to the graph will be list of Tensors that can be batched after Resize + transformation. + + For example, a typical graph can look like below: + + Imdecode -> Resize -> Batchify -> ToTensor -> Normalize -> Network Review comment: @szha - The way I am thinking is - this transformer is used when user is exporting a model for inference and he wants to fuse transformations as part of the network. This transformer is not applicable for training / validation which all works as existing today. So to summarize, the idea here is: 1. Training does not changing anything from what it is today - dataset and dataloader 2. When user wants to export a model transformations (Resize, Batchify, ToTensor, Normalize) is concatenated to network block and exported. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services