2017-02-27 86 views
0

我正在为在x86和ARMv7上运行的TensorFlow(r1.0)创建新的操作(https://www.tensorflow.org/extend/adding_an_op)。TensorFlow新操作:AttributeError:'模块'对象没有属性'custom_op'

在ARMv7上运行TensorFlow需要稍作修改,但本指南有很多帮助: https://github.com/samjabrahams/tensorflow-on-raspberry-pi/blob/master/GUIDE.md

但我注意到自定义操作不适用于TensorFlow的我的ARMv7安装

例如,当我测试我的自定义操作在Python脚本上的ARMv7:

import tensorflow as tf 
_custom_op_module = tf.load_op_library('custom_op.so') 
custom_op = _custom_op_module.add_stub 

我得到以下错误(这并不在x86上显示出来):

$ python test_custom_op.py 
    Traceback (most recent call last): 
    File "custom_op.py", line 3, in <module> 
    add_stub = _custom_op_module.add_stub 
    AttributeError: 'module' object has no attribute 'custom_op' 

我进一步调查了这个问题,显然在.so库文件中没有我的自定义操作。

$ python 
>>> import tensorflow as tf 
>>> _custom_op_module = tf.load_op_library('custom_op.so') 
>>> dir(_custom_op_module) 
>>> ['LIB_HANDLE', 'OP_LIST', '_InitOpDefLibrary', '__builtins__', '__doc__', '__name__', '__package__', '_collections', '_common_shapes', '_op_def_lib', '_op_def_library', '_op_def_pb2', '_op_def_registry', '_ops', '_text_format'] 
>>> _custom_op_module.OP_LIST 

>>> 

在x86相同的命令有以下的输出:

>>> import tensorflow as tf 
>>> _custom_op_module = tf.load_op_library('custom_op.so') 
>>> dir(_custom_op_module) 
>>> ['LIB_HANDLE', 'OP_LIST', '_InitOpDefLibrary', '__builtins__', '__doc__', '__name__', '__package__', '_add_stub_outputs', '_collections', '_common_shapes', '_op_def_lib', '_op_def_library', '_op_def_pb2', '_op_def_registry', '_ops', '_text_format', 'custom_op'] 
>>> _custom_op_module.OP_LIST 
op { 
    name: "CustomOp" 
    ... 
} 
>>> 

是否有人有类似的问题?我们可以认为这是一个错误?

回答

0

显然,重新编译和重新安装TF使它工作。

相关问题