You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/01/22 19:51:23 UTC

[GitHub] sandeep-krishnamurthy commented on a change in pull request #13930: Add batchify transformer to help end to end models

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_r249935599
 
 

 ##########
 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:
   @zhreshold - Thanks for pointing it out. Functionally, input can be either HWC or CHW it gets converted to NHWC or NCHW respectively. Will update the code comment.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services