Skip to content
This repository was archived by the owner on Jul 21, 2021. It is now read-only.

Commit b2076dc

Browse files
authored
use clamp instead of F.hardtanh
1 parent 43add18 commit b2076dc

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

torch_deform_conv/deform_conv.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import absolute_import, division
22

33
import torch
4-
import torch.nn.functional as F
54
from torch.autograd import Variable
65

76
import numpy as np
@@ -45,8 +44,8 @@ def th_map_coordinates(input, coords, order=1):
4544

4645
assert order == 1
4746
input_size = input.size(0)
48-
coords = F.hardtanh(coords, min_val=0, max_val= input_size - 1)
49-
47+
48+
coords = torch.clamp(coords, 0, input_size - 1)
5049
coords_lt = coords.floor().long()
5150
coords_rb = coords.ceil().long()
5251
coords_lb = torch.stack([coords_lt[:, 0], coords_rb[:, 1]], 1)
@@ -91,7 +90,7 @@ def th_batch_map_coordinates(input, coords, order=1):
9190
input_size = input.size(1)
9291
n_coords = coords.size(1)
9392

94-
coords = F.hardtanh(coords, min_val=0, max_val= input_size - 1)
93+
coords = torch.clamp(coords, 0, input_size - 1)
9594
coords_lt = coords.floor().long()
9695
coords_rb = coords.ceil().long()
9796
coords_lb = torch.stack([coords_lt[..., 0], coords_rb[..., 1]], 2)

0 commit comments

Comments
 (0)