Created
November 27, 2018 11:41
-
-
Save ispamm/6bb70371d665ca0185c3b765afe23cdc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This snippet is adapted from here: https://www.tensorflow.org/guide/datasets | |
def input_fn(dataframe, is_eval=False): | |
# Load the list of files | |
filenames = tf.constant(dataframe.iloc[:, 0].tolist()) | |
# Load the labels | |
labels = tf.constant(dataframe.iloc[:, 1:].values.astype(np.float32)) | |
# Build the dataset with image processing on top of it | |
dataset = tf.data.Dataset.from_tensor_slices((filenames, labels)) | |
dataset = dataset.map(_parse_function) | |
# Add shuffling and repeatition if training | |
if is_eval: | |
dataset = dataset.batch(64) | |
else: | |
dataset = dataset.repeat().shuffle(1000).batch(64) | |
return dataset |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment