keras-onnx icon indicating copy to clipboard operation
keras-onnx copied to clipboard

Query: How to reverse map bias from ONNX to Keras?

Open buddhapuneeth opened this issue 5 years ago • 2 comments
trafficstars

During the conversion, LSTM bias is of dim [8] will be converted to [1, 16]. In this case wb [1,8] and rb[1,8] are initialized to zeros (if B is not passed) else B is assigned to wb.

Say, if I am doing some custom training on the ONNX model and generating the gradients for variables. I can map gradients back to Keras model with minor conversions (iofc to ifco etc). But how can I map the B's gradients? As they will split over the training and averaging the gradients of rb and wb is not same as the TF bias gradient for seq_len > 1.

I know it is a special case, just want to hear your thoughts here.

buddhapuneeth avatar Oct 12 '20 07:10 buddhapuneeth

Are you suggestion ONNX should also something similar to keras's use_bias flag so that they could be converted into each other in your case?

wenbingl avatar Oct 22 '20 17:10 wenbingl

@wenbingl yes. But I think we might need two flags:

  • a flag for 'wb' which points to 'use_bias' in Keras
  • another flag for 'rb' Correct me if I am wrong.

buddhapuneeth avatar Oct 23 '20 00:10 buddhapuneeth