Tensor flow, Estimator.fit feed (batch)

Could you give an example of the use of high-level API evaluators with placeholders and batches, as for the basic use:

for step in xrange(max_steps): batch_of_inputs,batch_of_targets= get_batch_from_disk(step)# egbatches are stored as list where step is and index of the list feed_dict = {x:batch_of_inputs,y:batch_of_targets} _, loss_value = sess.run([train_op, loss], feed_dict=feed_dict) 

How to do the same with the Estimator API? The evaluator takes batch_size, steps, input_fuc or feed_fun as an argument to the matching function (see Doc https://www.tensorflow.org/versions/master/api_docs/python/contrib.learn/estimators ), but it’s not clear to me how to implement a function that will load data in the form of a package, for example a disk?

+5
source share
1 answer

I do not think that ratings are really intended for use with placeholders. They use the concept of input_fn , which is correctly described here .

If you really need to use a placeholder, you can use FeedFnHook :

 def input_fn(): # empty input_fn, returns features and labels return {}, {} feed_dict = {x:batch_of_inputs,y:batch_of_targets} def feed_fn(): # feed_fn with hardcoded feed_dict return feed_dict hooks = [tf.train.FeedFnHook(feed_fn=feed_fn)] estimator.train(input_fn=input_fn, hooks=hooks, steps=1) 
0
source

Source: https://habr.com/ru/post/1264465/


All Articles