def __get_label__(args, params): with tf.Session() as sess: # Obtain the test labels dataset = mnist_dataset.train(args.data_dir) dataset = dataset.map(lambda img, lab: lab) dataset = dataset.batch(params.train_size) labels_tensor = dataset.make_one_shot_iterator().get_next() labels = sess.run(labels_tensor) return labels
def train_embedding_fn(data_dir, params): """Compute embedding of the training set,remember:No shuffle!!! Need to keep order with labels Args: data_dir: (string) path to the data directory params: (Params) contains hyperparameters of the model (ex: `params.num_epochs`) """ dataset = mnist_dataset.train(data_dir) dataset = dataset.batch(params.batch_size) dataset = dataset.prefetch( 1) # make sure you always have one batch ready to serve return dataset
def train_input_fn(data_dir, params): """Train input function for the MNIST dataset. Args: data_dir: (string) path to the data directory params: (Params) contains hyperparameters of the model (ex: `params.num_epochs`) """ dataset = mnist_dataset.train(data_dir) dataset = dataset.shuffle(params.train_size) dataset = dataset.repeat(params.num_epochs) # repeat for multiple epochs dataset = dataset.batch(params.batch_size) dataset = dataset.prefetch( 1) # make sure you always have one batch ready to serve return dataset