0

I'm quite new to python and skflow, but I am experiencing a really basic problem and hope someone could help me.

I've installed skflow and downloaded the dbpedia_csv which is used in the examples. However upon running the 'text_classification_character_rnn.py' example, I am hit with an error:

Traceback (most recent call last):
File "/home/me/Projects/skflow/examples/text_classification_character_rnn.py", line 70, in <module>
classifier.fit(X_train, y_train)
 File "/home/me/Projects/skflow/skflow/estimators/base.py", line 217, in fit
self._setup_training()
File "/home/me/Projects/skflow/skflow/estimators/base.py", line 148, in _setup_training
self._inp, self._out)
File "/home/me/Projects/skflow/examples/text_classification_character_rnn.py", line 63, in char_rnn_model
return skflow.models.logistic_regression(encoding, y)
File "/home/me/Projects/skflow/skflow/models.py", line 65, in logistic_regression
tf.histogram_summary('logistic_regression.X', X)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/summary_ops.py", line 39, in histogram_summary
tag=tag, values=values, name=scope)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_summary_ops.py", line 34, in _histogram_summary
name=name)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/op_def_library.py", line 397, in apply_op
values, name=input_arg.name, dtype=dtype)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 468, in convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/constant_op.py", line 143, in constant
tensor_util.make_tensor_proto(value, dtype=dtype, shape=shape))
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/tensor_util.py", line 287, in make_tensor_proto
_AssertCompatible(values, dtype)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/tensor_util.py", line 227, in _AssertCompatible
(dtype.name, mismatch))
TypeError: Expected float32, got <tensorflow.python.framework.ops.Tensor object at 0x7f415dfcc290> instead.

Any ideas on what I am doing wrong? Also, the text_classification_cnn.py is working, but the print('Accuracy: {0:f}'.format(score)) no accuracy is printed. I'm using PyCharm Edu 2.0.3 to run the code.

GameOfThrows
  • 4,510
  • 2
  • 27
  • 44

1 Answers1

2

This looks like a version mismatch between skflow and TensorFlow. From the error message, it looks like you have an old version (0.5 or 0.6) of TensorFlow. However, skflow was recently updated to use a new interface in TensorFlow, and it looks like you are using this latest version of skflow.

The simplest solution would be to upgrade TensorFlow to version 0.7.1

mrry
  • 125,488
  • 26
  • 399
  • 400
  • Awesome! this fixed it. Can I ask apart from printing the Accuracy or `classifier.save('./path')` can I dump out the result of the classifier? I imagine it would be an index Array of 0 or 1 that point to the classification result? – GameOfThrows Mar 04 '16 at 16:17
  • Do you mean "dump of the result of the classifier *for a particular example (or batch of examples)"? In that case, I think you would use `classifer.predict(...)` to get a prediction (or batch of predictions). (I'm not an skflow user though, so there may be a better answer.) – mrry Mar 04 '16 at 16:30
  • I guess for a batch of examples, so the `classifer.predict` actually is the output? What is the best way to output/save this? – GameOfThrows Mar 04 '16 at 16:36
  • I think it's just a NumPy array, so you can use [`numpy.savetxt()`](http://docs.scipy.org/doc/numpy-1.10.0/reference/generated/numpy.savetxt.html) or something like that to write it out to a file. Or you could convert it to a pandas `DataFrame` and use one of that library's many methods for writing out to [different formats](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.to_csv.html). – mrry Mar 04 '16 at 16:43