url: https://arxiv.org/abs/1506.02025
year:2015
blog:
https://kevinzakka.github.io/2017/01/10/stn-part1/
https://kevinzakka.github.io/2017/01/18/stn-part2/
code:
https://github.com/kevinzakka/spatial-transformer-network
Introduce
卷積神經網絡定義了一類特別強大的模型,但仍然缺乏對輸入數據進行空間不變的能力。在這項工作中,引入了一個新的可學習模塊,即空間變換器(Spatial Transformer),它允許對網絡內的數據進行明確的空間操作。 這種可微分模塊可以插入到現有的卷積體系結構中,使神經網絡能夠主動進行特征圖的空間變換,無需對優化過程進行任何額外的監督或修改。文中展示了STN 的使用可以使模型學習到對平移,縮放,旋轉和更通用的變形的不變性,從而在幾個基准測試和包含許多變換的任務中產生了SOTA 的性能。
Architecture

Localisation Network: 用於生成仿射變換的參數
Grid Generator: 輸出 Feature Map 的網格坐標是固定的, 但是每個坐標上的值是多少呢? 為了解決這個問題, 首先, 我們需要找到輸出 Feature Map 與輸入 Feature Map 坐標之間的映射關系, 找到映射關系后, 那么輸出Feature Map某個坐標的值由對應輸入Feature Map的坐標上的值來填充, 如下圖所示(看圖即可, 不用管文字)

Sampler: 由於從輸出 Feature Map 網格坐標映射到輸入 Feature Map上的坐標值可能是小數, 如下圖. 那么輸出 Feature Map 在該坐標點上的值由對應輸入 Feature Map 上坐標周圍的四個點決定, 一般采用雙線性差值的方式


雙線性差值公式如下

Experiments
Distorted MNIST

Details
Street View House Numbers Details

All networks are trained from scratch with SGD and dropout, with randomly initialized weights, except for the regression layers of spatial transformers which are initialized to predict the identity transform.
(STCNN Single): a spatial transformer immediately following the input
(ST-CNN Multi): where the localization networks are all two layer fully connected networks with 32 units per layer
key | value |
---|---|
base learning rate | 1e-2 |
learning rate for localization network | a tenth of the base learning rate |
weight decay | 5e-4 |
dropout | 0.5 |
conv[N, w, s, p] | conv[batch_size, window, stride, padding] |
max[s] | a s × s max-pooling layer with stride s |
fc[N] | a fully connected layer with N units |
CNN-baseline
conv[48,5,1,2]-max[2]-
conv[64,5,1,2]-conv[128,5,1,2]-max[2]-
conv[160,5,1,2]-conv[192,5,1,2]-max[2]-
conv[192,5,1,2]-conv[192,5,1,2]-max[2]-
conv[192,5,1,2]-fc[3072]-fc[3074]-fc[3074]
localizaton network
conv[32,5,1,2]-max[2]-conv[32,5,1,2]-fc[32]-fc[32]
Fine-Grained Classification Details

Thought
當前動作識別中, 有些檢測框框的並不准, 而且一些動作不需要關注全局信息就可以判斷, 將 STN 當做特征檢測器使用.
就是使用來說,
- Localisation Network 的學習率設置很重要, 太大容易不收斂, 推薦為主網絡的學習率 1e-3到 1e-5之間.
- Localisation Network不要用 imagenet pretrain 的參數初始化, 沒有隨機初始化的容易收斂而且性能也差些, 猜測原因是 pretrain 的參數關注的是抽象的語義特征, 而仿射變換參數的預測關注的幾何位置特征, 二者不匹配
- 文中 Localisation Network 的卷積核設置都比較大