mxnet icon indicating copy to clipboard operation
mxnet copied to clipboard

SoftmaxTransform Operator

Open Kublai-Jing opened this issue 11 years ago • 11 comments

For some reason, I wanna use Softmax as a transformation and use my own loss function for backprop. However, I cannot find a place to change this setting and currently, it seems that even if I explicitly send grad to executor.backward([grad]). It still uses the Softmax default gradient...

I've seen that there is this "need_top_grad" in Naive_ops, but where can I find such thing for Softmax?

Thanks

Kublai-Jing avatar Nov 03 '15 04:11 Kublai-Jing

Softmax (recently renamed to SoftmaxOutput) is a loss layer. It's not intended to be used as internal layers. There was a discussion on this: https://github.com/dmlc/mxnet/issues/426

However there is an easy patch for your need you can do. Cudnn provide softmax implementation for internal layers. You can modify the cudnn_activation-inl.h file under src/operator and add a new activation with cudnn API.

If you figured out a solution, your are welcome to contribute to mxnet by submitting PR.

piiswrong avatar Nov 03 '15 05:11 piiswrong

This is discussed to be added as SoftmaxTransform Operator. cc @antinucleon Please let us know if you are interested in contributing

tqchen avatar Nov 04 '15 06:11 tqchen

See if I have time tomorrow

antinucleon avatar Nov 04 '15 07:11 antinucleon

will try to do it

Kublai-Jing avatar Nov 04 '15 13:11 Kublai-Jing

Should that be a stand-alone operator or should it be included in the activation operator ?

Kublai-Jing avatar Nov 06 '15 15:11 Kublai-Jing

I think we can do it in a standalone one, as this is quite different from elementwise activations

tqchen avatar Nov 06 '15 17:11 tqchen

Then we need both softmaxtransform and cudnn softmax transform On Nov 6, 2015 9:52 AM, "Tianqi Chen" [email protected] wrote:

I think we can do it in a standalone one, as this is quite different from elementwise activations

— Reply to this email directly or view it on GitHub https://github.com/dmlc/mxnet/issues/472#issuecomment-154484363.

piiswrong avatar Nov 06 '15 17:11 piiswrong

These two can be done in one ops, like currently Convolution

tqchen avatar Nov 06 '15 18:11 tqchen

Agree to @piiswrong

antinucleon avatar Nov 06 '15 18:11 antinucleon

Let us see if there is any updates on this

tqchen avatar Nov 21 '15 01:11 tqchen

Softmax transform is now supported via layer SoftmaxActivation.

piiswrong avatar Jan 11 '16 18:01 piiswrong