Well, this is my code:
def train_model(model, linear, input_CNN, learning_rate, nsamples, load_train_dataset):
epoch = 0
print_loss = 0
criterion = nn.CrossEntropyLoss()
optimizer_module = optim.SGD(model.parameters(), lr=learning_rate)
optimizer_linear = optim.SGD(linear.parameters(), lr=learning_rate)
optimizer_input_CNN = optim.SGD(input_CNN.parameters(), lr=learning_rate)
for i, (data, target) in enumerate(load_train_dataset()):
    if i > nsamples:
        break
    else:
        # train network

the parameter nsamples is 100 which means train 100 epoch. I don’t know if this code is right or not. I loaded all the data set into the data loadeer but use this nsamples to control the size of training data set.