Skip to content

Commit

Permalink
fix normalizefeatures transform for negative values
Browse files Browse the repository at this point in the history
  • Loading branch information
rusty1s committed Jan 5, 2022
1 parent 696da2c commit 6008e30
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion torch_geometric/transforms/normalize_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ def __init__(self, attrs: List[str] = ["x"]):
def __call__(self, data: Union[Data, HeteroData]):
for store in data.stores:
for key, value in store.items(*self.attrs):
store[key] = value / value.sum(dim=-1, keepdim=True).clamp_(1.)
value = value - value.min()
value.div_(value.sum(dim=-1, keepdim=True).clamp_(min=1.))
store[key] = value
return data

def __repr__(self) -> str:
Expand Down

0 comments on commit 6008e30

Please sign in to comment.