The code seems to work:
nc = 3
ndf = 3
model = Discriminator128(0)
model.main[14].register_forward_hook(get_activation('main[14]'))
output = model(torch.randn(1, 3, 128, 128))
act = activation['main[14]']

Note that act will have the shape [1, 1, 1, 1], so that imshow won’t make much sense (plotting a single pixel).