| 271 | return inv_delta_C # F+3 x F+3 |
| 272 | |
| 273 | def build_P_hat_paddle(self, C, P): |
| 274 | F = self.F |
| 275 | eps = self.eps |
| 276 | n = P.shape[0] # n (= self.I_r_width x self.I_r_height) |
| 277 | # P_tile: n x 2 -> n x 1 x 2 -> n x F x 2 |
| 278 | P_tile = paddle.tile(paddle.unsqueeze(P, axis=1), (1, F, 1)) |
| 279 | C_tile = paddle.unsqueeze(C, axis=0) # 1 x F x 2 |
| 280 | P_diff = P_tile - C_tile # n x F x 2 |
| 281 | # rbf_norm: n x F |
| 282 | rbf_norm = paddle.norm(P_diff, p=2, axis=2, keepdim=False) |
| 283 | |
| 284 | # rbf: n x F |
| 285 | rbf = paddle.multiply(paddle.square(rbf_norm), paddle.log(rbf_norm + eps)) |
| 286 | P_hat = paddle.concat([paddle.ones((n, 1), dtype="float64"), P, rbf], axis=1) |
| 287 | return P_hat # n x F+3 |
| 288 | |
| 289 | def get_expand_tensor(self, batch_C_prime): |
| 290 | B, H, C = batch_C_prime.shape |