DataLoader独立于模型。这是你可以做的一个例子。
import torch import torch.nn as nn class Model(nn.Module): # Model definition #Two models with different hyper-parameters model1 = Model(args) model2 = Model(args) dataloader = torch.utils.data.DataLoader(args) for data in dataloader: # Train model1 for data in dataloader: # Train model2