Besides dense tasks, one might want to access the deepest layer of DynamicUnet. Ideally, the model should return it too, given a proper flag in the constructor. Given that there is currently no such functionality, how should we access the bottleneck features?
Extracting the bottleneck features is straightforward; fastai’s
hook_output can be utilized to hook the output of a
DynamicUnet’s encoder (i.e., the bottleneck features), and after a forward pass, the stored values can be accessed via the hook’s
encoder = dynamic_unet.layers encoder_hook = hook_output(encoder) bottleneck_features = encoder_hook.stored
Is that helpful?