There are several ways to initialize the parameters of a model in deep learning : torch.nn.init — PyTorch 1.8.1 documentation 2
So based on the code you proposed above, I suggest something like :
class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.linears = nn.ModuleList([
	        nn.Linear(D, M)
	        nn.Linear(M, M)
	        nn.Linear(M, M)
	        nn.Linear(M, K)
        ])  

        # ...
    # forward
    # ...

def init_linear(linear):
    with torch.no_grad():
        # Choose your approach here, I just suggest some
        nn.init.normal_(linear.weight, mean=0, std=1) 
        #nn.init.xavier_uniform_(linear.weight)
        nn.init.constant_(linear.bias, 0.)

# Or when you want to initialize the whole model
def init_model(model):
    with torch.no_grad():
        for name, param in model.named_parameters():
            # Choose your approach here, I just suggest some
            if 'weight' in name:
                torch.nn.init.xavier_uniform_(param.data)
            elif 'bias' in name:
                param.data.fill_(0)
            # elif :
            # ...

And during training:
for _ in range(MAX_EPOCH) :
	to_init = you choose randomly the indices of the layers you want to reinitialize
	for i in to_init :
		init_linear(model.linears[i])
	# ...
	# training