Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError in Random Forest #199

Closed
SakigamiYang opened this issue Nov 19, 2017 · 3 comments
Closed

TypeError in Random Forest #199

SakigamiYang opened this issue Nov 19, 2017 · 3 comments

Comments

@SakigamiYang
Copy link

I got an error while running the example of Random Forest.
And I don't know what causes it. Maybe the version of TensorFlow?

My environment is Python 3.6.3 + TensorFlow 1.4.0 on Mac 10.13.1

Error:
/Users/sakigami/anaconda/bin/python /Users/sakigami/programmer/Python/tf_study/02_basic_models/random_forest.py
Extracting ../MNIST_data/train-images-idx3-ubyte.gz
Extracting ../MNIST_data/train-labels-idx1-ubyte.gz
Extracting ../MNIST_data/t10k-images-idx3-ubyte.gz
Extracting ../MNIST_data/t10k-labels-idx1-ubyte.gz
Traceback (most recent call last):
File "/Users/sakigami/programmer/Python/tf_study/02_basic_models/random_forest.py", line 36, in
correct_prediction = tf.equal(tf.argmax(infer_op, 1), tf.cast(Y, tf.string))
File "/Users/sakigami/anaconda/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 316, in new_func
return func(*args, **kwargs)
File "/Users/sakigami/anaconda/lib/python3.6/site-packages/tensorflow/python/ops/math_ops.py", line 205, in argmax
return gen_math_ops.arg_max(input, axis, name=name, output_type=output_type)
File "/Users/sakigami/anaconda/lib/python3.6/site-packages/tensorflow/python/ops/gen_math_ops.py", line 441, in arg_max
name=name)
File "/Users/sakigami/anaconda/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 513, in _apply_op_helper
raise err
File "/Users/sakigami/anaconda/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 510, in _apply_op_helper
preferred_dtype=default_dtype)
File "/Users/sakigami/anaconda/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 926, in internal_convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
File "/Users/sakigami/anaconda/lib/python3.6/site-packages/tensorflow/python/ops/array_ops.py", line 970, in _autopacking_conversion_function
return _autopacking_helper(v, inferred_dtype, name or "packed")
File "/Users/sakigami/anaconda/lib/python3.6/site-packages/tensorflow/python/ops/array_ops.py", line 912, in _autopacking_helper
elem))
TypeError: Cannot convert a list containing a tensor of dtype <dtype: 'string'> to <dtype: 'float32'> (Tensor is: <tf.Tensor 'stack_2:0' shape=(?, 10) dtype=string>)

Process finished with exit code 1

@trekkingpan
Copy link

I have the same problem

@wangzhen11aaa
Copy link

By using correct_prediction = tf.equal(tf.argmax(infer_op[0], 0), tf.cast(Y, tf.int64)),
I get rid of this error.

@SakigamiYang
Copy link
Author

@wangzhen11aaa 3q for your help. It helps me a lot. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants