TensorFlow 1.6中的随机森林

时间:2018-07-16 01:27:33

标签: python tensorflow random-forest

想尝试在TensorFlow中使用随机森林分类进行一些实验,到目前为止,在Google上排名最高的示例代码是https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/2_BasicModels/random_forest.py,但是当我尝试按原样运行它时,出现此错误:

C:\tf>random_forest.py
Successfully downloaded train-images-idx3-ubyte.gz 9912422 bytes.
Extracting /tmp/data/train-images-idx3-ubyte.gz
Successfully downloaded train-labels-idx1-ubyte.gz 28881 bytes.
Extracting /tmp/data/train-labels-idx1-ubyte.gz
Successfully downloaded t10k-images-idx3-ubyte.gz 1648877 bytes.
Extracting /tmp/data/t10k-images-idx3-ubyte.gz
Successfully downloaded t10k-labels-idx1-ubyte.gz 4542 bytes.
Extracting /tmp/data/t10k-labels-idx1-ubyte.gz
Traceback (most recent call last):
  File "C:\tf\random_forest.py", line 45, in <module>
    forest_graph = tensor_forest.RandomForestGraphs(hparams)
  File "C:\Users\w\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\contrib\tensor_forest\python\tensor_forest.py", line 376, in __init__
    tree_variables_class=tree_variables_class)
  File "C:\Users\w\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\contrib\tensor_forest\python\tensor_forest.py", line 350, in __init__
    self.variables.append(tree_variables_class(params, i, training))
  File "C:\Users\w\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\contrib\tensor_forest\python\tensor_forest.py", line 318, in __init__
    params, '', self.get_tree_name('stats', tree_num))
  File "C:\Users\w\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\contrib\tensor_forest\python\ops\stats_ops.py", line 102, in fertile_stats_variable
    container, shared_name=name, name=name)
  File "C:\Users\w\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\contrib\tensor_forest\python\ops\gen_stats_ops.py", line 141, in fertile_stats_resource_handle_op
    shared_name=shared_name, name=name)
  File "C:\Users\w\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 787, in _apply_op_helper
    op_def=op_def)
  File "C:\Users\w\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\ops.py", line 3273, in create_op
    compute_device=compute_device)
  File "C:\Users\w\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\ops.py", line 3313, in _create_op_helper
    set_shapes_for_outputs(op)
  File "C:\Users\w\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\ops.py", line 2501, in set_shapes_for_outputs
    return _set_shapes_for_outputs(op)
  File "C:\Users\w\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\ops.py", line 2474, in _set_shapes_for_outputs
    shapes = shape_func(op)
  File "C:\Users\w\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\ops.py", line 2404, in call_with_requiring
    return call_cpp_shape_fn(op, require_shape_fn=True)
  File "C:\Users\w\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\common_shapes.py", line 627, in call_cpp_shape_fn
    require_shape_fn)
  File "C:\Users\w\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\common_shapes.py", line 686, in _call_cpp_shape_fn_impl
    input_tensors_as_shapes, status)
  File "C:\Users\w\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 516, in __exit__
    c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.NotFoundError: Op type not registered 'FertileStatsResourceHandleOp' in binary running on PC. Make sure the Op and Kernel are registered in the binary running in this process.

似乎完全是内部错误消息,在github问题中没有提及,这可能表明兼容性问题。 TensorFlow 1.6.0,Python 3.6.4,Windows7。有什么想法吗?

0 个答案:

没有答案