Skip to content

Commit

Permalink
fix p in exchange
Browse files Browse the repository at this point in the history
  • Loading branch information
likyoo committed Nov 15, 2022
1 parent fb86fd5 commit 67ac0d8
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions opencd/models/utils/interaction_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ class ChannelExchange(BaseModule):
"""
channel exchange
Args:
p (int, optional): 1/p of the features will be exchanged.
Defaults to 2.
p (float, optional): p of the features will be exchanged.
Defaults to 1/2.
"""
def __init__(self, p=2):
def __init__(self, p=1/2):
super(ChannelExchange, self).__init__()
self.p = p
assert p >= 0 and p <= 1
self.p = int(1/p)

def forward(self, x1, x2):
N, c, h, w = x1.shape
Expand All @@ -38,12 +39,13 @@ class SpatialExchange(BaseModule):
"""
spatial exchange
Args:
p (int, optional): 1/p of the features will be exchanged.
Defaults to 2.
p (float, optional): p of the features will be exchanged.
Defaults to 1/2.
"""
def __init__(self, p=2):
def __init__(self, p=1/2):
super(SpatialExchange, self).__init__()
self.p = p
assert p >= 0 and p <= 1
self.p = int(1/p)

def forward(self, x1, x2):
N, c, h, w = x1.shape
Expand Down

0 comments on commit 67ac0d8

Please sign in to comment.