Skip to content

Instantly share code, notes, and snippets.

@dayyass
dayyass / pytorch_onnx_global_pooling.py
Created November 25, 2020 16:49
ONNX doesn't support PyTorch Adaptive Pooling (and Global Pooling as a special case with output_size=1). There is an implementation of Global Pooling compatible with ONNX.
import numpy as np
import torch
import torch.nn as nn
import onnx
import onnxruntime
##### INIT 1d, 2d, 3d GLOBAL POOLING MODULES #####