Skip to content

U-NET architecture: Get a feature map a few layers before the final classification layer. #2329

Answered by Nic-Ma
muneebafzal asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @muneebafzal ,

Thanks for your interest here.
I think you can try to write a simple PartialUNet class which inherits from MONAI BasicUNet:
https://github.com/Project-MONAI/MONAI/blob/dev/monai/networks/nets/basic_unet.py#L228

from monai.networks.nets import BasicUNet


class PartialUNet(BasicUNet):
    def forward(self, x: torch.Tensor):
        x0 = self.conv_0(x)

        x1 = self.down_1(x0)
        x2 = self.down_2(x1)
        x3 = self.down_3(x2)
        x4 = self.down_4(x3)

        u4 = self.upcat_4(x4, x3)
        u3 = self.upcat_3(u4, x2)
        u2 = self.upcat_2(u3, x1)
        u1 = self.upcat_1(u2, x0)
        return u1

Thanks.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by muneebafzal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants