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 2020/01/07 21:10:35 UTC

[GitHub] [incubator-mxnet] guanxinq commented on a change in pull request #17242: add RandomApply in gluon's transforms

guanxinq commented on a change in pull request #17242: add RandomApply in gluon's transforms
URL: https://github.com/apache/incubator-mxnet/pull/17242#discussion_r363952366
 
 

 ##########
 File path: tests/python/unittest/test_gluon_data_vision.py
 ##########
 @@ -229,6 +229,21 @@ def test_transformer():
     transform(mx.nd.ones((245, 480, 3), dtype='uint8')).wait_to_read()
 
 
+@with_seed()
+def test_randomtransforms():
+    from mxnet.gluon.data.vision import transforms
+
+    transform = transforms.Compose([transforms.RandomApply(transforms.Compose([transforms.Resize(300), transforms.RandomResizedCrop(224)]), 0.5)])
+    
+    img = mx.nd.ones((245, 480, 3), dtype='uint8')
+    iteration = 1000
+    num_apply = 0
+    for i in range(iteration):
+        out = transform(img)
+        if out.shape[0] == 224:
+            num_apply += 1
+    assert(abs(num_apply/float(iteration)-0.5) < 1e-1)
 
 Review comment:
   Sure. Did not notice that threshold could be passed into assert_almost_equal().

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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