Understanding Cross Validation I have a few gaps in my understanding of K fold CV. 
What I understand: K fold CV is meant to be a model validation technique, the idea is that you subset your data into K subsets, train your data on K-1 of those subsets and test on the Kth subset, repeating this process K times. The final result is the average error over each trial, the CV error.
K fold CV is NOT meant to compare different instances of the same model. For example, if the model to be fit is linear, then you cannot compare linear model 1 with 4 coefficients to linear model 2 with 5 coefficients. You can however compare a linear model CV error with a glm CV error.
If that is the case, then I am confused about fitting a model. Lets say I want to fit a poisson GLM. I use 5 fold CV. On each fold the result of training the model gives me differing choices of parameters and differing numbers of parameters.
For example, on the first fold, the GLM chooses $X_1, X_2$, on the second fold, it chooses $X_2,X_3,X_4$. So at the end of the process, which model do i actually choose?
 A: Cross validation is often used to tune complexity. In your example, some kind of regularisation is (presumably) driving the selection of a different parameter set. Two popular algorithms where CV is used in this way very often is glmnet, which tunes over its regularisation penalty $\lambda$, and boosted decision trees, which tune over the number of trees. In principle, though, CV can be used to tune for a lot of different things like model hyperparameters or model structure.
Once the model structure or complexity parameter is determined, one generally trains a model on the entire training data and selects the optimal parameters as chosen by cross validation. 
Tune with CV, then refit across the full dataset. The models that are trained on the $k$ reduced-size datasets are generally not used for anything post-tuning.
A: You could use K-fold CV in this manner:


*

*Create K-folds of your dataset.

*Identify different candidate algorithms you want to evaluate to build your model. Lets assume you have 2 algorithms to evaluate - linear regression, logistic regression.

*For each one, run parameter selection training runs for each of K-folds and evaluate their accuracy on the held-out Kth fold. Also tune the hyper-parameters for these models in the same training runs - e.g. L1 or L2 regularization parameters. Lets assume you have identified 2 sets of parameters for each algorithm - 2 for linear regression and 2 for logistic regression.

*For each of these 4 candidate models, evaluate their performance on the K-folds. Assume you prefer selecting the one with lowest variance of True Positive accuracy - let this be model #3. Other selection criteria could be to select the model with highest average TP accuracy, etc.

*Fit model #3 on the entire training data with the selected hyper-parameters to get the final model.


Its not recommended to tune the model on the entire training data (Step #5 , e.g. selecting the parameters, hyper-parameters, etc.) because if you do so, you won't be able to check if you made a robust model which will perform as expected with new data. The Kth held out fold lets you do that and fix any mistakes during model building.

Edited to explain queries in comments:
Parameter imply all the input features used by the model and Hyper-praameters mean all the other configuration settings of the algorithm used to produce the optimal fit. For example, if we're fitting a neural network , selecting the variables x1, x2, x3 as the best inputs to produce an estimate y implies we're selecting these 3 parameters for the model. Hyper-parameters would be the no. of units, no. of hidden layers and the learning rate of the neural network.
When we reach step #5, we will have the final list of input parameters which had achieved the best results in cross-validation, and the hyper-parameters which had given the best results. The K-folds and the coefficients learned for each fold are discarded. Then, we use the entire training data, pick our final list of parameters and run a final training using the selected hyper-parameters to get the model fit, or, coefficients that collectively represent the completed "model".
