Skip to main content
Overview

Confusing Training Methods

August 29, 2021
1 min read

I organized things I had been confused about or only vaguely understood.

Training, validation ordering

def train():
for epoch in range(epcoh):
training()
validate()

This ordering is correct. The version below also trains the model on input data:

def train():
for epoch in range(epcohs):
training()
for epoch in range(epcohs):
validate()

The problem is that validation happens only after all training is complete. It just validates the final trained model repeatedly for each epoch. A waste of resources.

With the proper ordering, you can validate the learning result of each step and reflect it in the evaluation.

K fold cross validation

As the name says, it is a validation technique. So it should not be used for training like this:

def train():
for epoch in range(epcohs):
training()
for epoch in range(epcohs):
validate()
def kfoldvalidate()
# do something...
train()
kfoldvalidatie()

I think it could be used in training, but if so, it would probably look something like this with ensemble learning (just my speculation…):

def train():
model_list = MakeManyModel()
for idx, train_set, validate_set in enumerate(kfold(dataset)):
for epoch in range(epcohs):
training(mode_list[idx])
for epoch in range(epcohs):
validate(model_list[idx])
return model_list
def kfoldvalidate(model_list)
SelectBestModel(model_list)
train()
for i in range(k):
kfoldvalidatie()

One model exists per fold, and the best model among k models is selected. You could also use voting like actual ensemble learning instead of picking the single best model. I did not try it because it would consume too many resources..

Loading comments...