tensorflow / skflow

Simplified interface for TensorFlow (mimicking Scikit Learn) for Deep Learning
Apache License 2.0
3.18k stars 439 forks source link

An error following TensorFlow Tutorial — Part 3 #94

Closed Kiminaka closed 8 years ago

Kiminaka commented 8 years ago

Hi, I love the idea of skflow and am trying to learn it :) When I was running the exactly same code on the blog (https://medium.com/@ilblackdragon/tensorflow-tutorial-part-3-c5fc0662bc08#.jsxv1w8n9) in my local, I got the error below. I thought that the class variables would need to be float instead of integer and tried that but it didn't solve. Could someone help?

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-28-62de22c2cf78> in <module>()
     15 classifier = skflow.TensorFlowEstimator(model_fn=categorical_model,
     16     n_classes=2)
---> 17 classifier.fit(X_train, y_train)
     18 
     19 print("Accuracy: {0}".format(metrics.accuracy_score(classifier.predict(X_test), y_test)))

/Users/a/anaconda/lib/python2.7/site-packages/skflow/estimators/base.pyc in fit(self, X, y, logdir)
    166         if not self.continue_training or not self._initialized:
    167             # Sets up model and trainer.
--> 168             self._setup_training()
    169             # Initialize model parameters.
    170             self._trainer.initialize(self._session)

/Users/a/anaconda/lib/python2.7/site-packages/skflow/estimators/base.pyc in _setup_training(self)
    102 
    103             # Add histograms for X and y.
--> 104             tf.histogram_summary("X", self._inp)
    105             tf.histogram_summary("y", self._out)
    106 

/Users/a/anaconda/lib/python2.7/site-packages/tensorflow/python/ops/summary_ops.pyc in histogram_summary(tag, values, collections, name)
     37   with ops.op_scope([tag, values], name, "HistogramSummary") as scope:
     38     val = gen_summary_ops._histogram_summary(
---> 39         tag=tag, values=values, name=scope)
     40     _Collect(val, collections, [ops.GraphKeys.SUMMARIES])
     41   return val

/Users/a/anaconda/lib/python2.7/site-packages/tensorflow/python/ops/gen_summary_ops.pyc in _histogram_summary(tag, values, name)
     32   """
     33   return _op_def_lib.apply_op("HistogramSummary", tag=tag, values=values,
---> 34                               name=name)
     35 
     36 

/Users/a/anaconda/lib/python2.7/site-packages/tensorflow/python/ops/op_def_library.pyc in apply_op(self, op_type_name, g, name, **keywords)
    403             if input_arg.type != types_pb2.DT_INVALID:
    404               raise TypeError("%s expected type of %s." %
--> 405                               (prefix, types_lib.as_dtype(input_arg.type).name))
    406             else:
    407               raise TypeError(

TypeError: Input 'values' of 'HistogramSummary' Op has type int64 that does not match expected type of float32.
ilblackdragon commented 8 years ago

Hi @Kiminaka is there by any chance you have an old version of skflow? Currently, this code doesn't add histograms anymore for int64s. You may just need to run pip uninstall skflow && pip install skflow.

We are gonna roll out an official 0.1 version on PyPI soon so it will be easier to install / uninstall and track versions. Sorry for inconvenience.

Kiminaka commented 8 years ago

Hi Illia, yes I had the older version and it worked after upgrading it :) Thanks!