Hi, I want to implement cross-validation efficiently. Therefore, I want to build one model(/neural network) and then reset the variables randomly for each fold in the cross-validation.
Is there a way to reset variables’ values just the same as creating a new model?
Some example codes are
class Toy(torch.nn.Module):
	def __init__(self):
		super(Toy,self).__init__()
		self.fc = torch.nn.Linear(3,4)
	def forward(self,x):
		return self.fc(x)
		
toy = Toy()
cross_validation_acc = []
for fold_num in range(5):
	train(toy)
	cross_validation_acc.append(test(toy))
	reset_variables(toy)
print(np.mean(cross_validation_acc))

Thank you very much!