Calculate attribute gradient.
(tensor, reduce='sum')
| 53 | raise NotImplementedError() |
| 54 | |
| 55 | def attr_grad(tensor, reduce='sum'): |
| 56 | """Calculate attribute gradient.""" |
| 57 | h_x = tensor.size()[2] |
| 58 | w_x = tensor.size()[3] |
| 59 | h_grad = torch.pow(tensor[:, :, :h_x - 1, :] - tensor[:, :, 1:, :], 2) |
| 60 | w_grad = torch.pow(tensor[:, :, :, :w_x - 1] - tensor[:, :, :, 1:], 2) |
| 61 | grad = torch.pow(h_grad[:, :, :, :-1] + w_grad[:, :, :-1, :], 1 / 2) |
| 62 | return reduce_func(reduce)(grad) |
| 63 | |
| 64 | def attr_gabor_generator(gabor_filter): |
| 65 | """Generate attribute gabor function.""" |
no test coverage detected