Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. def pandas_input_fn(x, y=None, batch_size=128, num_epochs=None):
  2. def input_fn():
  3. if y is not None:
  4. x.loc[:,'y'] = y
  5. queue = learn.dataframe.queues.feeding_functions.enqueue_data(
  6. x, 1000, shuffle=num_epochs is None, num_epochs=num_epochs)
  7. if num_epochs is None:
  8. features = queue.dequeue_many(batch_size)
  9. else:
  10. features = queue.dequeue_up_to(batch_size)
  11. features = dict(zip(['index'] + list(x.columns), features))
  12. if y is not None:
  13. target = features.pop('y')
  14. return features, target
  15. return features
  16. return input_fn
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement