0
votes

Code :

import numpy as np
import tensorflow as tf
from tensorflow.contrib.learn.python.learn.dataframe import tensorflow_dataframe as df                               
tf.logging.set_verbosity(tf.logging.INFO)

# Data sets                                                                                                                                                            
IRIS_TRAINING = "/home/huaxing.jinhx/data/iris/iris_training.csv"                                                 
IRIS_TEST = "/home/huaxing.jinhx/data/iris/iris_test.csv"                                                               
filepatterns = "/home/huaxing.jinhx/data/iris/iris*"                                                                       

# Load datasets.                                                                                                                                                       
default_values = [0,0,0,0,0]
column_names = "x1 x2 x3 x4 y".split()
data_df = df.TensorFlowDataFrame()
data_df.from_csv(filepatterns,
             default_values,
             has_header=False,
             column_names=column_names,
             num_threads=1,
             enqueue_size=None,
             batch_size=10,
             queue_capacity=None,
             min_after_dequeue=None,
             shuffle=False,
             seed=None)
batch = data_df.run_one_epoch()

Error :

I tensorflow/core/common_runtime/gpu/gpu_device.cc:1041] Creating TensorFlow device (/gpu:0) -> (device: 0, name: Tesla K40m, pci bus id: 0000:81:00.0) Traceback (most recent call last): File "/home/huaxing.jinhx/proj/tf_samples/read_csv.py", line 32, in batch = data_df.run_one_batch() File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/dataframe/tensorflow_dataframe.py", line 263, in run_one_batch return list(self.run(num_batches=1))[0] File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/dataframe/tensorflow_dataframe.py", line 128, in run values = session.run(cols) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 717, in run run_metadata_ptr) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 855, in _run raise RuntimeError('The Session graph is empty. Add operations to the ' RuntimeError: The Session graph is empty. Add operations to the graph before calling run().

1
Please post your full code here instead to pointing to a picture.olibiaz

1 Answers

0
votes

from_csv() is a class method on TensorFlowDataFrame that gives you a new dataframe. Here, you're doing run_one_epoch() on an empty dataframe, which explains the error. Instead please try this:

data_df = df.TensorFlowDataFrame.from_csv(...)
batch = data_df.run_one_epoch()