mxnet icon indicating copy to clipboard operation
mxnet copied to clipboard

bug about sum in loss

Open CircleXing001 opened this issue 8 years ago • 6 comments

i make a loss of 'mx.sym.sum(xxx)',and use mx.sym.MakeLoss(). but it always can't work and kill the kernel

CircleXing001 avatar May 20 '18 17:05 CircleXing001

@CircleXing001 Could you please give more context of the issue and minimum reproducible code to reproduce it alongwith environment details

@sandeep-krishnamurthy Could you please tag this as Pending requester info

ankkhedia avatar May 21 '18 05:05 ankkhedia

`data = mx.symbol.Variable('data')

label = mx.symbol.Variable('softmax_label')

conv1=mx.symbol.Convolution(data,kernel=(5,5),stride=(1,1),pad=(2,2),num_filter=32)

fc1=mx.symbol.Activation(conv1,act_type='relu')

pool1=mx.symbol.Pooling(fc1,kernel=(2,2),pool_type='max',stride=(2,2))

conv2=mx.symbol.Convolution(pool1,kernel=(5,5),stride=(1,1),pad=(2,2),num_filter=64)

fc2=mx.symbol.Activation(conv2,act_type='relu')

pool2=mx.symbol.Pooling(fc2,kernel=(2,2),pool_type='max',stride=(2,2))

fc3=mx.sym.Reshape(pool2,shape=(-1,7764))

fc4=mx.symbol.FullyConnected(fc3,num_hidden=1024)

fc5=mx.symbol.Activation(fc4,act_type='relu')

drop1=mx.symbol.Dropout(fc5,p=0.5)

fc6=mx.symbol.FullyConnected(drop1,num_hidden=10)

fc7=mx.symbol.softmax(fc6)

out=mx.symbol.MakeLoss(-mx.symbol.sum(label*mx.symbol.log(fc7)))` i use the mnist dataset with data-shape (-1,1,28,28) and label-shape(-1,10). after i use the MakeLoss,when i run it,the python doesnt work and kill the kernel. in ubantu and windows it did the same thing.and the version is mxnet 1.1.0 and only in CPU. thanks for your reply. @ankkhedia

CircleXing001 avatar May 21 '18 05:05 CircleXing001

@CircleXing001 The code shared by you create the symbols. The symbol creation works fine for me. I suppose that the forward pass/ training might be killing your kernel. Could you please share the exact code which you are trying when the kernel fails?

ankkhedia avatar May 23 '18 17:05 ankkhedia

@ankkhedia Firstly,thanks for ur reply. Here is the exact code that i tried.

CircleXing001 avatar May 24 '18 03:05 CircleXing001

There are some bugs in the code, like shape mismatch, when you calculate accuracy, or trying to use sum on boolean. I also think that you can easily remove the dependency from Tensorflow to load MNIST data.

Take a look into this example. The model is almost the same and can be easily adjusted to match your own: https://github.com/zackchase/mxnet-the-straight-dope/blob/f65cde976f1e3138931db2af3b5be0903ae31c80/chapter04_convolutional-neural-networks/cnn-gluon.ipynb

Ishitori avatar Jul 14 '18 18:07 Ishitori

@sandeep-krishnamurthy looks like we can close this issue due to some other bugs elsewhere in script, as found by @Ishitori. MakeLoss issues look to have been a red herring.

@CircleXing001 if you're still having issues with this feel free to reopen.

thomelane avatar Aug 17 '18 21:08 thomelane