Skip to content

Commit

Permalink
fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanghang1989 committed Oct 6, 2017
1 parent b0d6ae4 commit a4d71e7
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
4 changes: 4 additions & 0 deletions docs/source/encoding.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@ Functions
:members:


:hidden:`assign`
~~~~~~~~~~~~~~~~~~~

.. autofunction:: assign
10 changes: 10 additions & 0 deletions docs/source/notes/compile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,13 @@ Install PyTorch-Encoding

MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py install

- Reference:
Hang Zhang, Jia Xue, and Kristin Dana. "Deep TEN: Texture Encoding Network." *The IEEE Conference on Computer Vision and Pattern Recognition (CVPR) 2017*::

@InProceedings{Zhang_2017_CVPR,
author = {Zhang, Hang and Xue, Jia and Dana, Kristin},
title = {Deep TEN: Texture Encoding Network},
booktitle = {The IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
month = {July},
year = {2017}
}
11 changes: 11 additions & 0 deletions encoding/functions/aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,17 @@ def backward(self, gradL):


def assign(R, S):
r"""
Calculate assignment weights for given residuals (:math:`R`) and scale (:math:`S`)
.. math::
a_{ik} = \frac{exp(-s_k\|x_{i}-c_k\|^2)}{\sum_{j=1}^K exp(-s_j\|x_{i}-c_j\|^2)}
Shape:
- Input: :math:`R\in\mathcal{R}^{B\times N\times K\times D}` :math:`S\in \mathcal{R}^K` (where :math:`B` is batch, :math:`N` is total number of features, :math:`K` is number is codewords, :math:`D` is feature dimensions.)
- Output :math:`A\in\mathcal{R}^{B\times N\times K}`
"""
L = square_squeeze()(R)
K = S.size(0)
SL = L * S.view(1,1,K)
Expand Down
4 changes: 2 additions & 2 deletions encoding/modules/encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Encoding(nn.Module):
.. math::
a_{ik} = \frac{exp(-\beta\|x_{i}-c_k\|^2)}{\sum_{j=1}^K exp(-\beta\|x_{i}-c_j\|^2)}
e_{ik} = \frac{exp(-s_k\|x_{i}-c_k\|^2)}{\sum_{j=1}^K exp(-s_j\|x_{i}-c_j\|^2)} (x_i - c_k)
Args:
D: dimention of the features or feature channels
Expand Down Expand Up @@ -95,7 +95,7 @@ class Aggregate(nn.Module):
Aggregate operation, aggregate the residuals (:math:`R`) with assignment weights (:math:`A`).
.. math::
e_{k} = \sum_{i=1}^{N} a_{ik} (r_{ik})
e_{k} = \sum_{i=1}^{N} a_{ik} r_{ik}
Shape:
- Input: :math:`A\in\mathcal{R}^{B\times N\times K}` :math:`R\in\mathcal{R}^{B\times N\times K\times D}` (where :math:`B` is batch, :math:`N` is total number of features, :math:`K` is number is codewords, :math:`D` is feature dimensions.)
Expand Down

0 comments on commit a4d71e7

Please sign in to comment.