使用输入功能将训练数据提供给tf.learn tf 1.0中最好的方法是什么?
我在tf0.12中使用了learn.dataframe.queues.feeding_functions.enqueue_data但是已经探索了tf.train.batch,tf.train.slice_input_producer和tf.FIFOQueue我不知道如何为tf1.0重写这个。
我使用的代码是
def pandas_input_fn(x, y=None, batch_size=128, num_epochs=None):
def input_fn():
if y is not None:
x.loc[:,'y'] = y
queue = learn.dataframe.queues.feeding_functions.enqueue_data(
x, 1000, shuffle=num_epochs is None, num_epochs=num_epochs)
if num_epochs is None:
features = queue.dequeue_many(batch_size)
else:
features = queue.dequeue_up_to(batch_size)
features = dict(zip(['index'] + list(x.columns), features))
if y is not None:
target = features.pop('y')
return features, target
return features
return input_fn
来自https://medium.com/@ilblackdragon/tensorflow-tutorial-part-4-958c29c717a0#.4vwo2ato7