## 2 Triplet Ordinal Cross Entropy Hashing
### Triplet Ordinal Cross Entropy Loss  
In this section, we define \(\hat{G}\) as RS images' triplet ordinal relation in the Hamming space. As discussed in Section 2.2, an ideal hashing algorithm should minimize the inconsistency between \(\hat{G}\) and \(G\). In this paper, the above requirement is achieved by minimizing the cross entropy value, as defined in Equation (6).  
\[\text{min}CEH(G,\widehat{G})=\text{min}-P(G)\log P(\widehat{G}) \tag{6}\]  
\(P(G)\) defined in Equation (7) computes the probability distribution of RS images' triplet ordinal relation in the Euclidean space.  
\[\begin{cases}w_{ijk}=\frac{T_{1}}{T}&g_{ijk}=1\\ w_{ijk}=\frac{T_{0}}{T}&g_{ijk}=0\end{cases} \tag{7}\]  
The definitions of \(T_{1}\), \(T_{0}\) and \(T\) are shown in Equation (8). \(T_{1}\) is the number of samples with a value of 1 in the matrix \(G\) and \(T_{0}\) is the number of samples with a value of 0 in the matrix \(G\). \(T\) is the total number of the elements in the matrix \(G\).  
\[\begin{split} T_{1}=\sum\limits_{i,j,k=1}^{N}g_{i,j,k}\\ T_{0}=\sum\limits_{i,j,k=1}^{N}(1-g_{i,j,k})\\ T=\sum\limits_{i,j,k=1}^{N}\left|2\cdot g_{i,j,k}-1\right|\end{split} \tag{8}\]  
\(P(\hat{G})\) is a conditional probability of the triplet ordinal relation with given binary codes. As the samples are independent from each other, we calculate \(P(\hat{G})\) by Equation (9).  
\[P(\widehat{G})=\Pi_{i,j,k=1}^{N}P(g_{ijk}\left|B_{i},B_{j},B_{k}\right.) \tag{9}\]  
\(P(g_{ijk}\left|B_{i},B_{j},B_{k}\right.)\) is the probability of the triplet images satisfying the ordinal relation \(g_{ijk}\), and the samples' are assigned the binary codes (\(B_{i}\), \(B_{j}\), \(B_{k}\)). The definition is shown in Equation (10).  
\[P(g_{ijk}\left|B_{i},B_{j},B_{k}\right.)=\begin{cases}\phi(d_{h}(B_{k},B_{j})- d_{h}(B_{i},B_{j})),&g_{ijk}=1\\ 1-\phi(d_{h}(B_{k},B_{j})-d_{h}(B_{i},B_{j})),&g_{ijk}=0\end{cases} \tag{10}\]  
We further rewrite the definition of \(P(g_{ijk}\left|B_{i},B_{j},B_{k}\right.)\) as in Equation (11).  
\[P(g_{ijk}\left|B_{i},B_{j},B_{k}\right.)=\phi(d_{h}(B_{k},B_{j})-d_{h}(B_{i},B _{j}))^{g_{ijk}}(1-\phi(d_{h}(B_{k},B_{j})-d_{h}(B_{i},B_{j})))^{1-g_{ijk}} \tag{11}\]  
\(d_{h}(\cdot,\cdot)\) returns the Hamming distance and \(\phi(\cdot)\) computes the probability value. If \(g_{ijk}=1\), the probability value should be close to 1 as \(d_{h}(B_{k},B_{j})\)-\(d_{h}(B_{i},B_{j})\) gets larger and the probability value should be close to 0 as \(d_{h}(B_{k},B_{j})\)-\(d_{h}(B_{i},B_{j})\) gets smaller. The characteristic of the function (\(\cdot\)) is shown in Figure 3.  
In this paper, the sigmoid function is considered as the function \((\cdot)\) as in Equation (12).  
\[\phi(d_{h}(B_{k},B_{j})-d_{h}(B_{i},B_{j}))=\frac{1}{1+e^{-\alpha(d_{h}(B_{k},B_{ j})-d_{h}(B_{i},B_{j}))}} \tag{12}\]  
By merging Equations (7), (9), (11) and (12) into Equation (6), we reach the final triplet ordinal relation preserving objective function, as shown in Equation (13).  
\[\begin{array}{ll}L&=-w_{ijk}\log\Pi_{i,j,k=1}^{N}P(g_{ijk}|B_{i},B_{j},B_{k}) \\ &=\sum\limits_{i,j,k=1}^{N}-w_{ijk}\log P(s_{ijk}|B_{i},B_{j},B_{k})\\ &=\sum\limits_{i,j,k=1}^{N}-w_{ijk}\log\left(\frac{1}{1+e^{-\alpha(d_{h}(B_{k},B_{i})-d_{h}(B_{i},B_{j}))}}\right)^{\delta_{h}}(1-\frac{1}{1+e^{-\delta(d_{h}( B_{k})-d_{h}(B_{i},B_{j}))}})^{1-\delta_{h}})\\ &=\sum\limits_{i,j,k=1}^{N}w_{ijk}(S_{ijk}\log(1+e^{-\alpha(d_{h}(B_{k},B_{i}) -d_{h}(B_{i},B_{j}))})+(1-g_{ijk})\log(1+\frac{1}{e^{-\alpha(d_{h}(B_{k},B_{j}) -d_{h}(B_{i},B_{j}))}}))\\ &=\sum\limits_{i,j,k=1}^{N}w_{ijk}(S_{ijk}\log(e^{-\alpha(d_{h}(B_{k},B_{i}) -d_{h}(B_{i},B_{j}))})+\log(1+\frac{1}{e^{-\alpha(d_{h}(B_{k},B_{i})-d_{h}(B_{ i},B_{j}))}}))\end{array} \tag{13}\]