transforms = torch.nn.Sequential(
transforms.RandomCrop(224),
transforms.Normalize((0.25516997,0.25296235,0.24626788), (0.28230251,0.23966205,0.24667897))
)
scripted_transforms = torch.jit.script(transforms)
338 if not isinstance(module, Module) and module is not None:
339 raise TypeError("{} is not a Module subclass".format(
–> 340 torch.typename(module)))
341 elif not isinstance(name, torch._six.string_classes):
342 raise TypeError(“module name should be a string. Got {}”.format(
TypeError: torchvision.transforms.transforms.RandomCrop is not a Module subclass
报错原因,pytorch1.6版本不能使用Sequential连接transforms,改为使用compose或者升级到1.9就好了。