keras-onnx
keras-onnx copied to clipboard
Query: How to reverse map bias from ONNX to Keras?
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.
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 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.