weightnorm icon indicating copy to clipboard operation
weightnorm copied to clipboard

Hope release a weightnorm code that can be used for keras using theano backend

Open jf003320018 opened this issue 7 years ago • 3 comments

It seems that the weight norm code for keras uses tensorflow backend. I try to modify it as a theano backend based code, but failed. So hope to release a weightnorm code that can be used for keras using theano backend. Thank you.

jf003320018 avatar Dec 09 '16 07:12 jf003320018

just changing the existing tf.XYZ() calls into the corresponding keras.backend. calls doesnt work?

redst4r avatar Dec 11 '16 19:12 redst4r

Do you try it? I have change the tf.XXX function to K.XXX function in theano backend by looking their meanings, but tf.get_variable_shape() and K.get_variable_shape() using theano backend is different. So It pop up an error.

jf003320018 avatar Dec 12 '16 00:12 jf003320018

I'm trying to modify the code for theano backend as you, but I encounter several obstacles. jf003320018 did you manage to convert the code? It is not ( or not only) a matter of different function meanings, as keras implement a set of function both for tensorflow and for theano. I think the problem stays in the function: def get_weightnorm_params_and_grads(p, g): The first fix to be done is: V_scaler_shape = (ps[-1],) to V_scaler_shape = (ps[0],) as there is the problem of tensor ordering convention. Still, the fix isn't enough because of some tesnor manipulation in the rest of the function. I tried putting [0] instead of [-1] in the other lines of code, but it is not working and I'm not understanding into detail how these lines of code are working.

engharat avatar Feb 06 '17 15:02 engharat