mxnet icon indicating copy to clipboard operation
mxnet copied to clipboard

how can i do a image mean substraction operation in symbol?

Open dyzhou2015 opened this issue 9 years ago • 4 comments

hi, new to mxnet, i wonder how can i do a image mean substraction operation in symbol using existing layer? any suggestions would be greatly apprecitate. thanks ahead

dyzhou2015 avatar Sep 08 '17 01:09 dyzhou2015

It's probably easier if you do the subtraction in the data iterator. There are a number of solutions readily available: https://mxnet.apache.org/api/python/io.html#mxnet.io.ImageRecordIter https://mxnet.apache.org/api/python/image.html#overview

szha avatar Sep 08 '17 02:09 szha

@szha thanks for your reply, I have to test my model using raw data(without mean substraction) for some reasons.Is it convenient to put the mean substraction operation as a existing layer?

dyzhou2015 avatar Sep 08 '17 02:09 dyzhou2015

@dyzhou2015 yes, it's doable, though it may become verbose in symbol. Mean subtraction can be regarded as a broadcast subtraction operation. You can use sym.ones and sym.concat to create the vector for image mean, and then sym.broadcast_sub for the mean subtraction. There may be better solutions out there, and this is one solution that I can think of.

szha avatar Sep 08 '17 03:09 szha

thanks a lot @szha

dyzhou2015 avatar Sep 08 '17 03:09 dyzhou2015