I am following the IRIS example of tensorflow.
My case now is I have all data in a single CSV file, not separated, and I want to apply k-fold cross validation on that data.
I have
data_set = tf.contrib.learn.datasets.base.load_csv(filename="mydata.csv",
target_dtype=np.int)
How can I perform k-fold cross validation on this dataset with multi-layer neural network as same as IRIS example?
I know this question is old but in case someone is looking to do something similar, expanding on ahmedhosny's answer:
The new tensorflow datasets API has the ability to create dataset objects using python generators, so along with scikit-learn's KFold one option can be to create a dataset from the KFold.split() generator:
Then one can iterate through the dataset either in the graph based tensorflow or using eager execution. Using eager execution:
NN's are usually used with large datasets where CV is not used - and very expensive. In the case of IRIS (50 samples for each species), you probably need it.. why not use scikit-learn with different random seeds to split your training and testing?
for k in kfold:
If you dont like the random seed and want a more structured k-fold split, you can use this taken from here.