When I output size of the feature extractor output I get after passing a 300x300 image I get 1x2208x9x9 and then I pass this to inplace RelU and avg_pool with kernel_size=7 (as per source code of densenet), the error disappears when I change this kernel size to 9.