All the official google tutorials use the one shot iterator for all the estimator api implementation, i couldnt find any documentation on how to use tf.data's initializable iterator and reinitializable interator instead of one shot iterator.
Can someone kindly show me how to switch between train_data and test_data using tf.data's initializable iterator and reinitializable interator. We need to run a session to use feed dict and switch the dataset in the initializable iterator, its a low level api and its confusing how to use it part of estimator api architecture
PS : I did find that google mentions "Note: Currently, one-shot iterators are the only type that is easily usable with an Estimator."
But is there any work around within the community? or should we just stick with one shot iterator for some good reason
To use either initializable or reinitializable iterators, you must create a class that inherits from tf.train.SessionRunHook. This class then have access to the session used by the tf.estimator functions.
Here is quick example that you can adapt to your needs :
This is a modified version from a code I found in a blogpost by Sebastian Pölsterl. Have a look under the "Feeding data to an Estimator via the Dataset API" section.
Or you can simply use
tf.estimator.train_and_evaluate
https://www.tensorflow.org/api_docs/python/tf/estimator/train_and_evaluate It allows you to use validation during training without needing to care about iterator at all.