Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename RandomTranslate to RandomJitter #4828

Merged
merged 5 commits into from
Jun 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Added support for graph-level outputs in `to_hetero` ([#4582](https://github.com/pyg-team/pytorch_geometric/pull/4582))
- Added `CHANGELOG.md` ([#4581](https://github.com/pyg-team/pytorch_geometric/pull/4581))
### Changed
- Renamed `RandomTranslate` to `RandomJitter` - the usage of `RandomTranslate` is now deprecated ([#4828](https://github.com/pyg-team/pytorch_geometric/pull/4828))
- Do not allow accessing edge types in `HeteroData` with two node types when there exists multiple relations between these types ([#4782](https://github.com/pyg-team/pytorch_geometric/pull/4782))
- Allow `edge_type == rev_edge_type` argument in `RandomLinkSplit` ([#4757](https://github.com/pyg-team/pytorch_geometric/pull/4757))
- Fixed a numerical instability in the `GeneralConv` and `neighbor_sample` tests ([#4754](https://github.com/pyg-team/pytorch_geometric/pull/4754))
Expand Down
2 changes: 1 addition & 1 deletion docs/source/notes/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ In addition, we can use the :obj:`transform` argument to randomly augment a :cla
dataset = ShapeNet(root='/tmp/ShapeNet', categories=['Airplane'],
pre_transform=T.KNNGraph(k=6),
transform=T.RandomTranslate(0.01))
transform=T.RandomJitter(0.01))
dataset[0]
>>> Data(edge_index=[2, 15108], pos=[2518, 3], y=[2518])
Expand Down
2 changes: 1 addition & 1 deletion examples/dgcnn_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
category = 'Airplane' # Pass in `None` to train on all categories.
path = osp.join(osp.dirname(osp.realpath(__file__)), '..', 'data', 'ShapeNet')
transform = T.Compose([
T.RandomTranslate(0.01),
T.RandomJitter(0.01),
T.RandomRotate(15, axis=0),
T.RandomRotate(15, axis=1),
T.RandomRotate(15, axis=2)
Expand Down
2 changes: 1 addition & 1 deletion examples/point_transformer_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
category = 'Airplane' # Pass in `None` to train on all categories.
path = osp.join(osp.dirname(osp.realpath(__file__)), '..', 'data', 'ShapeNet')
transform = T.Compose([
T.RandomTranslate(0.01),
T.RandomJitter(0.01),
T.RandomRotate(15, axis=0),
T.RandomRotate(15, axis=1),
T.RandomRotate(15, axis=2),
Expand Down
2 changes: 1 addition & 1 deletion examples/pointnet2_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
category = 'Airplane' # Pass in `None` to train on all categories.
path = osp.join(osp.dirname(osp.realpath(__file__)), '..', 'data', 'ShapeNet')
transform = T.Compose([
T.RandomTranslate(0.01),
T.RandomJitter(0.01),
T.RandomRotate(15, axis=0),
T.RandomRotate(15, axis=1),
T.RandomRotate(15, axis=2)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import torch

from torch_geometric.data import Data
from torch_geometric.transforms import RandomTranslate
from torch_geometric.transforms import RandomJitter


def test_random_translate():
assert RandomTranslate(0.1).__repr__() == 'RandomTranslate(0.1)'
def test_random_jitter():
assert RandomJitter(0.1).__repr__() == 'RandomJitter(0.1)'

pos = torch.Tensor([[0, 0], [0, 0], [0, 0], [0, 0]])

data = Data(pos=pos)
data = RandomTranslate(0)(data)
data = RandomJitter(0)(data)
assert len(data) == 1
assert data.pos.tolist() == pos.tolist()

data = Data(pos=pos)
data = RandomTranslate(0.1)(data)
data = RandomJitter(0.1)(data)
assert len(data) == 1
assert data.pos.min().item() >= -0.1
assert data.pos.max().item() <= 0.1

data = Data(pos=pos)
data = RandomTranslate([0.1, 1])(data)
data = RandomJitter([0.1, 1])(data)
assert len(data) == 1
assert data.pos[:, 0].min().item() >= -0.1
assert data.pos[:, 0].max().item() <= 0.1
Expand Down
9 changes: 7 additions & 2 deletions torch_geometric/transforms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from .center import Center
from .normalize_rotation import NormalizeRotation
from .normalize_scale import NormalizeScale
from .random_translate import RandomTranslate
from .random_jitter import RandomJitter
from .random_flip import RandomFlip
from .linear_transformation import LinearTransformation
from .random_scale import RandomScale
Expand Down Expand Up @@ -70,7 +70,7 @@
'Center',
'NormalizeRotation',
'NormalizeScale',
'RandomTranslate',
'RandomJitter',
'RandomFlip',
'LinearTransformation',
'RandomScale',
Expand Down Expand Up @@ -109,3 +109,8 @@
]

classes = __all__

from torch_geometric.deprecation import deprecated # noqa

RandomTranslate = deprecated("use 'transforms.RandomJitter' instead",
'transforms.RandomTranslate')(RandomJitter)
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
from torch_geometric.transforms import BaseTransform


@functional_transform('random_translate')
class RandomTranslate(BaseTransform):
@functional_transform('random_jitter')
class RandomJitter(BaseTransform):
r"""Translates node positions by randomly sampled translation values
within a given interval (functional name: :obj:`random_translate`).
within a given interval (functional name: :obj:`random_jitter`).
In contrast to other random transformations,
translation is applied separately at each position
Expand Down