Skip to content

Instantly share code, notes, and snippets.

@hj0921
hj0921 / compact_bilinear_pooling.py
Created March 19, 2021 02:17 — forked from vadimkantorov/compact_bilinear_pooling.py
Compact Bilinear Pooling in PyTorch using the new FFT support
# References:
# [1] Multimodal Compact Bilinear Pooling for Visual Question Answering and Visual Grounding, Fukui et al., https://arxiv.org/abs/1606.01847
# [2] Compact Bilinear Pooling, Gao et al., https://arxiv.org/abs/1511.06062
# [3] Fast and Scalable Polynomial Kernels via Explicit Feature Maps, Pham and Pagh, https://chbrown.github.io/kdd-2013-usb/kdd/p239.pdf
# [4] Fastfood — Approximating Kernel Expansions in Loglinear Time, Le et al., https://arxiv.org/abs/1408.3060
# Original implementation in Caffe: https://github.com/gy20073/compact_bilinear_pooling
import torch
class CompactBilinearPooling(torch.nn.Module):