Skip to content

Instantly share code, notes, and snippets.

@piiswrong
Last active October 24, 2015 22:52
Show Gist options
  • Save piiswrong/62fb35b9da8a9ce7ff17 to your computer and use it in GitHub Desktop.
Save piiswrong/62fb35b9da8a9ce7ff17 to your computer and use it in GitHub Desktop.
Engine Crashes if asnumpy() is not called on result
import os
import mxnet as mx
from common import models
import pickle as pkl
def test_softmax_with_shape(shape, xpu):
X = mx.symbol.Variable('X')
L = mx.symbol.Variable('L')
Y = mx.symbol.Softmax(data=X, label=L)
x = mx.random.uniform(-1, 1, shape, ctx = xpu)
l = mx.nd.empty((shape[0],), ctx = xpu)
l[:] = np.random.randint(0, shape[0]-1, (shape[0],))
grad = mx.nd.empty(shape, ctx = xpu)
exec1 = Y.bind(xpu, args = [x, l], args_grad = {'X': grad})
print 'foward'
exec1.forward()
#print exec1.outputs[0].asnumpy() include this line and it works fine
test_softmax_with_shape((3,4), mx.cpu())
@piiswrong
Copy link
Author

Crash happens randomly. Somewhere around 50%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment