It sounds like you are not returning model
and passing it on.
Did you mean:
model = set_train_validation_function(i, k, j)
trainFunction(model)
This will mean that def set_train_validation_function(...):
will need to return model
and then you will need def trainFunction(model):
CLICK HERE to find out more related problems solutions.