python - TensorFlow 1.6 中的随机森林
问题描述
想在 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、Windows 7。有什么想法吗?
解决方案
推荐阅读
- php - 如何从 php 中的 JSON 对象数组中读取多个值?
- powerquery - 无法识别 Text.InferNumberType 的 Expression.Error
- django - 如何仅在通过 iframe 从 Django 中的特定域访问时才允许渲染视图?
- javascript - 带有 html-pdf npm 的动态 PDF
- python - 即使没有引发异常,Django transaction.commit_on_success 也会回滚
- python - 为什么第一次向 Django 服务器请求时响应如此缓慢
- perl - 如何预防/控制 Moose 使用忏悔
- python - 查找列表中具有部分内容匹配的所有项目
- julia - (Julia 1.x)通过初始化变量增加分配?
- npm - Allure 报告执行但未能填充数据 - Jasmine 和 Protractor