sxjscience commented on issue #16705: Dropout inconsistency bug URL: https://github.com/apache/incubator-mxnet/issues/16705#issuecomment-549533626 @DickJC123 The answer should be different because these two dropouts should share the same internal random number generator and the random state will be updated accordingly. For the inconsistency bug mentioned in this issue, it's not exactly related to the seeding problem. For example, consider the following script: ```python import mxnet as mx mx.random.seed(123) x = mx.nd.ones((10, 10)) y = mx.nd.Dropout(x, cudnn_off=True) with mx.autograd.record(): y = mx.nd.Dropout(x, cudnn_off=True) ``` The first `y = mx.nd.Dropout(x, cudnn_off=True)` is not surrounded by `autograd`, and should not update the random state. However, in the current implementation (https://github.com/apache/incubator-mxnet/blob/bb6305d11d4383af2022e53ad94d6a1d5d93cb00/src/operator/nn/dropout-inl.h#L495), the `rand()` function will still be called when the node is constructed.. Thus, running `y = mx.nd.Dropout(x, cudnn_off=True)` outside the `train` loop will still interfere the random state. This means, the following two code snippets will obtain different results: - Case 1 ```python import mxnet as mx mx.random.seed(123) x = mx.nd.ones((3, 3), ctx=mx.gpu()) y = mx.nd.Dropout(x, cudnn_off=True) with mx.autograd.record(): y = mx.nd.Dropout(x, cudnn_off=True) print(y) ``` ``` [[0. 2. 0.] [0. 0. 2.] [0. 2. 0.]] <NDArray 3x3 @gpu(0)> ``` - Case 2 ```python import mxnet as mx mx.random.seed(123) x = mx.nd.ones((3, 3), ctx=mx.gpu()) with mx.autograd.record(): y = mx.nd.Dropout(x, cudnn_off=True) print(y) ``` ``` [[0. 0. 2.] [0. 0. 2.] [0. 2. 0.]] <NDArray 3x3 @gpu(0)> ```
---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services