I followed the Tensorflow Read Data instruction to retrieve my application data in the form of TFRecords, and use TFRecordReader in my input pipelines to read this data.
Now I am reading manuals on using skflow / tf.learn to create a simple regressor, but I donβt see how to use my input with these tools.
In the following code, the application does not work when calling regressor.fit(..) with ValueError: setting an array element with a sequence. .
Mistake:
Traceback (most recent call last): File ".../tf.py", line 138, in <module> run() File ".../tf.py", line 86, in run regressor.fit(x, labels) File ".../site-packages/tensorflow/contrib/learn/python/learn/estimators/base.py", line 218, in fit self.batch_size) File ".../site-packages/tensorflow/contrib/learn/python/learn/io/data_feeder.py", line 99, in setup_train_data_feeder return data_feeder_cls(X, y, n_classes, batch_size) File ".../site-packages/tensorflow/contrib/learn/python/learn/io/data_feeder.py", line 191, in __init__ self.X = check_array(X, dtype=x_dtype) File ".../site-packages/tensorflow/contrib/learn/python/learn/io/data_feeder.py", line 161, in check_array array = np.array(array, dtype=dtype, order=None, copy=False) ValueError: setting an array element with a sequence.
the code:
import tensorflow as tf import tensorflow.contrib.learn as learn def inputs(): with tf.name_scope('input'): filename_queue = tf.train.string_input_producer([filename]) reader = tf.TFRecordReader() _, serialized_example = reader.read(filename_queue) features = tf.parse_single_example(serialized_example, feature_spec) labels = features.pop('actual') some_feature = features['some_feature'] features_batch, labels_batch = tf.train.shuffle_batch( [some_feature, labels], batch_size=batch_size, capacity=capacity, min_after_dequeue=min_after_dequeue) return features_batch, labels_batch def run(): with tf.Graph().as_default(): x, labels = inputs()
It appears that calling check_array expecting a real array, not a tensor. Is there anything I can do to massage my data into the right form?