Source code for lecture2notes.models.slide_classifier.custom_nnmodules
import torch
import torch.nn as nn
[docs]class AdaptiveConcatPool2d(nn.Module):
"""
Layer that concats AdaptiveAvgPool2d and AdaptiveMaxPool2d
https://docs.fast.ai/layers.html#AdaptiveConcatPool2d
"""
def __init__(self, sz=None):
super().__init__()
sz = sz or (1, 1)
self.ap = nn.AdaptiveAvgPool2d(sz)
self.mp = nn.AdaptiveMaxPool2d(sz)