MONAI Transforms inherit torch.nn.Module
#2935
Replies: 4 comments
-
torchvision only supports torchscript for some of the transforms, and the current version of torchscript has its limitations, so I think "deriving all transforms" from torch.nn.Module needs more motivations at the moment. We can add new extension class of |
Beta Was this translation helpful? Give feedback.
-
My 2 cents for this discussion. One of the goals for torchvision.transforms is to support Torchvision's transformations not derived from |
Beta Was this translation helpful? Give feedback.
-
Interesting. Would be fine if all transforms natively support |
Beta Was this translation helpful? Give feedback.
-
I think torch tensor support for transforms can be dissociated from a need to inherit from Technically, there is no major blockers to make a transform class to inherit from Main blocker for torchvision to rewrite
I think torchscript wont work with numpy datatype for these transformations even if inherited from |
Beta Was this translation helpful? Give feedback.
-
Is your feature request related to a problem? Please describe.
MONAI array transforms are all derived from
Transform
base class by implementing__call__
method, and similar to torchvision transform can be chained usingCompose
. However, in torchvision transforms without losing any backward compatibility are inherited fromnn.Module
(since v0.8.0). This has some obvious benefits:torch.jit.script
nn.Sequential
. This will allow the transforms be chained with the model as well and let them run on the same device that model is being run.Describe the solution you'd like
torch.nn.Module
instead ofTransform
forward
for all transforms instead of__call__
torch.Tensors
(Default to using Pytorch APIs formonai.transforms
(ETA TBD) #2231)Beta Was this translation helpful? Give feedback.
All reactions