I wonder if there are any disadvantages of rewriting the default Compose
as shown below?
class Compose:
"Similar to torchvision.transforms.Compose but digest additional kwargs"
def __init__(self, transforms):
self.transforms = transforms
def __call__(self, x, **kwargs):
for t in self.transforms:
out = t(x, **kwargs)
if isinstance(out, Tuple):
x, kwargs = out
else:
x = out
if isinstance(out, Tuple):
return x, kwargs
return x
def __repr__(self):
format_string = self.__class__.__name__ + '('
for t in self.transforms:
format_string += '\n'
format_string += ' {0}'.format(t)
format_string += '\n)'
return format_string
For something more specialized, review albumination Compose .