Every time I define a new Anchor Generator, I get a CUDA OOM problem. I suspect it’s nothing to do with memory, there’s a weight mismatch somewhere. Here’s the code:
mrcnn_args = {'num_classes':63}
icdar_anchor_generator = AnchorGenerator(
      sizes=tuple([(4, 8, 16, 32, 64, 128, 256, 512) for r in range(5)]), 
      aspect_ratios = tuple([(0.25, 0.5, 1, 1.5, 2) for rh in range(5)]))
mrcnn_args['rpn_anchor_generator'] = icdar_anchor_generator
maskrcnn_model = torchvision.models.detection.maskrcnn_resnet50_fpn(pretrained=False, **mrcnn_args)

I followed the suggestion here:

https://github.com/pytorch/vision/issues/978 27

If I simply defined one tuple for sizes of aspect views, I got a size mismatch:
icdar_anchor_generator = AnchorGenerator(
      sizes=(4, 8, 16, 32, 64), 
      aspect_ratios = (0.5, 1, 1.5))

RuntimeError: shape '[840000, -1]' is invalid for input of size 4476540

So what else should I define?