simpledet
simpledet copied to clipboard
Access to intermediate layer TridentNet
I want to access to an intermediate layer of TridentNet to get a feature vector, in particular feature vector after doing the roi pool operation, how can i perform this?
Thanks
Our wrapper library mxnext provides a mxnext.foward_debug
operator that accepts a callback with signature callback(gpu_id, num_iter, *data)
.
You can add the following to your Head
def save_roi_feat(gpu_id, num_iter, roi_feat):
if gpu_id == 0 and num_iter + 1 % 100 == 0:
np.save("trident_roi_feature_%d" % int(num_iter), roi_feat)
roi_feat = X.forward_debug(roi_feat, callback=save_roi_feat)
Thanks for reply! Sorry about the dumb question but is RpnHead
the Head
intridentnet_r50v2c4_c5_1x.py
? or may I have to save roi_extractor = RoiExtractor(RoiParam)
?
Thanks in advance
I think that inserting the hook at the input of BboxC5Head
may be a good idea.
https://github.com/TuSimple/simpledet/blob/f67fca08b33d957b43eb1db5e3745a3a9e3803b5/symbol/builder.py#L558-L579
You can put the following snippet in just before L564
def save_roi_feat(gpu_id, num_iter, roi_feat):
if gpu_id == 0 and num_iter + 1 % 100 == 0:
import numpy as np
np.save("trident_roi_feature_%d" % int(num_iter), roi_feat)
conv_feat = X.forward_debug(conv_feat, callback=save_roi_feat)
And you can find trident_roi_feat_XXX.npy
in your directory.
I have an error:
RuntimeError: num_iter_b5f728d4-dac5-4563-be3a-0a3f8a5c690a is not presented
Maybe the code you posted ir just for training? How can i get the roi feats in inference?
Thanks!
A known issue of the debug utility. I will look into it. In the meantime, you may set your network for training and lr and wd to 0 as a workaround.
On Thu, Jan 2, 2020 at 1:26 AM Simón Sepúlveda Osses < [email protected]> wrote:
I have an error:
RuntimeError: num_iter_b5f728d4-dac5-4563-be3a-0a3f8a5c690a is not presented
Maybe the code you posted ir just for training? How can i get the roi feats in inference?
Thanks!
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/TuSimple/simpledet/issues/285?email_source=notifications&email_token=ABGODH6ZGJZUFNUYFF7L6FTQ3TG4TA5CNFSM4KASMTU2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEH5JDBI#issuecomment-570069381, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABGODH7LLEGZ5KJZEIINKJLQ3TG4TANCNFSM4KASMTUQ .
Thanks @RogerChern , I'll give a try