落水人员检测
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

22 lines
601B

  1. import torch.nn as nn
  2. import torch
  3. import torch.distributed as dist
  4. class GlobalAvgPool2d(nn.Module):
  5. def __init__(self):
  6. """Global average pooling over the input's spatial dimensions"""
  7. super(GlobalAvgPool2d, self).__init__()
  8. def forward(self, inputs):
  9. in_size = inputs.size()
  10. return inputs.view((in_size[0], in_size[1], -1)).mean(dim=2)
  11. class SingleGPU(nn.Module):
  12. def __init__(self, module):
  13. super(SingleGPU, self).__init__()
  14. self.module=module
  15. def forward(self, input):
  16. return self.module(input.cuda(non_blocking=True))