skflow 示例抛出错误

skflow example throws errors

我对 python 和 skflow 很陌生,但我遇到了一个非常基本的问题,希望有人能帮助我。

我已经安装了 skflow 并下载了示例中使用的 dbpedia_csv。然而,在 运行 宁 'text_classification_character_rnn.py' 示例时,我遇到了一个错误:

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.

对我做错了什么有什么想法吗?此外,text_classification_cnn.py 正在运行,但 print('Accuracy: {0:f}'.format(score)) 未打印准确度。我正在使用 PyCharm Edu 2.0.3 来 运行 代码。

这看起来像是 skflow 和 TensorFlow 之间的版本不匹配。从错误消息来看,您使用的似乎是旧版本(0.5 或 0.6)的 TensorFlow。但是,skflow recently updated 在 TensorFlow 中使用了一个新接口,看起来你正在使用这个最新版本的 skflow。

最简单的解决方案是 upgrade TensorFlow 版本 0.7.1