Skip to content

Instantly share code, notes, and snippets.

@BryanCutler
Last active February 25, 2020 18:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BryanCutler/bc9cbb707f33d59413a23789431866ff to your computer and use it in GitHub Desktop.
Save BryanCutler/bc9cbb707f33d59413a23789431866ff to your computer and use it in GitHub Desktop.
TensorFlow Arrow Blog Part 11 - Model Training Remote Dataset
def make_remote_dataset(endpoint):
"""Make a TensorFlow Arrow Dataset that reads from a remote Arrow stream."""
# Create the Arrow Dataset from a remote host serving a stream
ds = arrow_io.ArrowStreamDataset(
[endpoint],
columns=(0, 1, 2),
output_types=(tf.int64, tf.float64, tf.float64),
output_shapes=(tf.TensorShape([]), tf.TensorShape([]), tf.TensorShape([])),
batch_mode='auto')
# Map the dataset to combine feature columns to single tensor
ds = ds.map(lambda l, x0, x1: (tf.stack([x0, x1], axis=1), l))
return ds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment