piiswrong commented on a change in pull request #7356: decouple record/train 
and add state readers
URL: https://github.com/apache/incubator-mxnet/pull/7356#discussion_r131980722
 
 

 ##########
 File path: tests/python/unittest/test_autograd.py
 ##########
 @@ -251,18 +251,49 @@ def test_attach_grad():
 def test_is_train():
     x = mx.nd.ones((10, 10))
     x.attach_grad()
-    with record(True):
+    with record(train_mode=True):
+        assert is_recording()
+        assert is_training()
         y = mx.nd.Dropout(x, p=0.5)
         assert y.asnumpy().max() == 2 and y.asnumpy().min() == 0
         y.backward()
         assert (x.grad.asnumpy() == y.asnumpy()).all()
 
-    with record(False):
+        with predict_mode():
+            assert is_recording()
+            assert not is_training()
+            y = mx.nd.Dropout(x, p=0.5)
+            assert (y.asnumpy() == x.asnumpy()).all()
+            y.backward(is_train=False)
+            assert (x.grad.asnumpy() == x.asnumpy()).all()
+
+    with record(train_mode=False):
+        assert is_recording()
+        assert not is_training()
         y = mx.nd.Dropout(x, p=0.5)
         assert (y.asnumpy() == x.asnumpy()).all()
         y.backward(is_train=False)
 
 Review comment:
   change this to train_mode too
 
----------------------------------------------------------------
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

Reply via email to