I am getting accuracy of each fold better than before. so I think my model is not resetting to initial state after a fold.
Here is my code
class Model(nn.Module):
    def__init__(self,...)
    super().__init()
    self.net=nn.Sequential(...)
def forward(self,x):
    return self.net(x)

def kfoldcv(model,data,...):
    
    kf = KFold(n_splits)
    fold=0
    train_cv=[]

    for train_index, test_index in kf.split(data.img):
        opt=torch.optim.Adam(params=model.parameters(),lr=lr)
        
        train=data.iloc[train_index,:].values
        test=data.iloc[test_index,:].values
        
        trainloader=dataloader(....)
        
        for batch in trainloader():
            out=model(batch[0])


kfoldcv(Model())

i tried this code from here 2
        
for name, module in model.named_children():
     print('resetting ', name)
     module.reset_parameters()

But it errors as follow
ModuleAttributeError: 'Sequential' object has no attribute 'reset_parameters'