[x] I checked to make sure that this is not a duplicate issue
[x] I'm submitting the request to the correct repository (for model requests, see here)
Is your feature request related to a problem? Please describe.
DynamicPoolingLayer is implemented by dpool_index, and dpool_index should be feed manually by python code, which is quite inconvenient.
Describe the solution you'd like
Indeed, DynamicPoolingLayer is similar to ROI Pooling in object detection in CV. tf.image.crop_and_resize works well on this scenario (stable and fast). The boxes coordinates can be easily calculated by q_len, d_len from masking out [PAD]s. Thus, we are not required to feed additional dpool_index any more.
Describe alternatives you've considered
# q_len, d_len: the actual length of query and doc, normalized
# q_max_len, d_max_len: the max length of query and doc, given by model definition
output = tf.image.crop_and_resize(
image = input_similarity_matrix,
boxes = tf.stack([tf.zeros((N,)), tf.zeros((N,)), q_len, d_len], axis = -1),
box_ind = tf.range(0, limit=N),
crop_size = (q_max_len, d_max_len)
)
Is your feature request related to a problem? Please describe.
DynamicPoolingLayer is implemented by dpool_index, and dpool_index should be feed manually by python code, which is quite inconvenient.
Describe the solution you'd like
Indeed, DynamicPoolingLayer is similar to ROI Pooling in object detection in CV. tf.image.crop_and_resize works well on this scenario (stable and fast). The boxes coordinates can be easily calculated by q_len, d_len from masking out [PAD]s. Thus, we are not required to feed additional dpool_index any more.
Describe alternatives you've considered
Additional Information
https://www.tensorflow.org/api_docs/python/tf/image/crop_and_resize