How to match up categorical labels in training and evaluation I am creating a CNN to categorise a sentence into one of N possible labels. 

I have used the tutorial from WildML to start the code, and I have modified it to allow multiple outputs instead of just true/false.

I am using VocabularyProcessor to convert the words into numbers and then using OneHotEncoder to transform the labels for evaluation. I am currently using the same VocabularyProcessor for converting both X and y

Where x_text is the loaded sentences and y_text is the correct labels

max_document_length = max([len(x.split(" ")) for x in x_text])
vocab_processor = learn.preprocessing.VocabularyProcessor(max_document_length)
X = np.array(list(vocab_processor.fit_transform(x_text)))

y_val = np.array(list(vocab_processor.transform(y_text)))

from sklearn.preprocessing import OneHotEncoder
onehotencoder = OneHotEncoder(categorical_features = [0])
y = onehotencoder.fit_transform(y_val).toarray()
y = y[:, 1:]


This then goes through the training.

The problem that I am finding is that during evaluation, if the labels are not exactly the same then the indexes do not match the prediction that is coming out.

Basically what my question is, is how do I match up the output of the evaluation with the text label so that I can use it after training without hard coding the labels up front
You are going about it all wrong. You shouldn't transform your labels into numerical values and match them to the output; that's not how classification is done. Instead, for each class (category) you will add a node in the output layer; the predicted class is then the argmax of the output layer.

For example, let's say you have three classes: simple, compound and complex. We'll assign an integer for each class starting from $0$.
Your output layer will have three nodes, one for each class, and for each training example $x$, the true label $y$ is a three dimensional "hot-encoded" vector. (i.e $y = (y_0, y_1, y_2)$ where $y_i = 1$ if $x$ belongs to class $i$ otherwise $y_i = 0$ for $i \in \{0,1,2\}$).

Now, let's suppose you feed your (trained) network an input value x and it outputs the following vector:
$y' = (0.4, 1.4, 2.5)$. The predicted label in this case is $\arg\max(y') = 2$. So the prediction for the sentence x is: complex.

Note: since argmax is not differentiable, we use softmax during training to convert the output vector y' into a vector of probabilities that sums up to $1$ before applying the loss function. The prediction in this case is the class with the highest probability. For example, if we apply softmax to the same y' from the example above, we get: $\text{softmax}(y') = (0.08, 0.23, 0.69)$. It's clear that the highest probability ($69\%$) belongs to the class $2$ (complex) and that these probabilities sum up to $1$.