File tree Expand file tree Collapse file tree
examples/tutorials/input_fn Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717from __future__ import division
1818from __future__ import print_function
1919
20+ import itertools
21+
2022import pandas as pd
2123import tensorflow as tf
2224
@@ -64,7 +66,9 @@ def main(unused_argv):
6466
6567 # Print out predictions
6668 y = regressor .predict (input_fn = lambda : input_fn (prediction_set ))
67- print ("Predictions: {}" .format (str (y )))
69+ # .predict() returns an iterator; convert to a list and print predictions
70+ predictions = list (itertools .islice (y , 6 ))
71+ print ("Predictions: {}" .format (str (predictions )))
6872
6973if __name__ == "__main__" :
7074 tf .app .run ()
Original file line number Diff line number Diff line change @@ -222,6 +222,9 @@ logging verbosity](../monitors/index.md#enabling-logging-with-tensorflow) to
222222from __future__ import absolute_import
223223from __future__ import division
224224from __future__ import print_function
225+
226+ import itertools
227+
225228import pandas as pd
226229import tensorflow as tf
227230
@@ -301,8 +304,6 @@ which means the function can process any of the `DataFrame`s you've imported:
301304To train the neural network regressor, run `fit` with the `training_set` passed
302305to the `input_fn` as follows:
303306
304- < !-- TODO(skleinfeld): Decide on the best step value to use here for pedagogical purposes -- >
305-
306307```python
307308regressor.fit(input_fn = lambda : input_fn(training_set), steps = 5000 )
308309```
@@ -355,7 +356,9 @@ Finally, you can use the model to predict median house values for the
355356
356357```python
357358y = regressor.predict(input_fn = lambda : input_fn(prediction_set))
358- print (" Predictions: {} " .format(str (y)))
359+ # .predict() returns an iterator; convert to a list and print predictions
360+ predictions = list (itertools.islice(y, 6 ))
361+ print (" Predictions: {} " .format(str (predictions)))
359362```
360363
361364Your results should contain six house- value predictions in thousands of dollars,
You can’t perform that action at this time.
0 commit comments