次の tensorflow モデルの UFF への変換は、tf.matmul 操作で失敗します。
x = tf.placeholder(tf.float32, shape=[None, 1, 1, 100], name="input_x")
y = tf.placeholder(tf.float32, shape=[None, 1, 200, 3], name="input_y")
net = layers.conv2d(x, 100, [1,1], data_format='NHWC')
net = layers.conv2d(net, 200, [1,1], data_format='NHWC')
output = tf.matmul(net, y, name="output")
エラー:
Warning: No conversion function registered for layer: BatchMatMul yet.
Converting as custom op BatchMatMul output
name: "output"
op: "BatchMatMul"
input: "Conv_1/Relu"
input: "input_y"
attr {
key: "T"
value {
type: DT_FLOAT
}
}
attr {
key: "adj_x"
value {
b: false
}
}
attr {
key: "adj_y"
value {
b: false
}
}
Traceback (most recent call last):
File "simple_mlp.py", line 69, in <module>
tf_graph_to_uff(frozen_graph, output_name_list)
File "simple_mlp.py", line 64, in tf_graph_to_uff
text=True)
File "/usr/local/lib/python2.7/dist- packages/uff/converters/tensorflow/conversion_helpers.py", line 75, in from_tensorflow
name="main")
File "/usr/local/lib/python2.7/dist- packages/uff/converters/tensorflow/converter.py", line 64, in convert_tf2uff_graph
uff_graph, input_replacements)
File "/usr/local/lib/python2.7/dist- packages/uff/converters/tensorflow/converter.py", line 51, in convert_tf2uff_node
op, name, tf_node, inputs, uff_graph, tf_nodes=tf_nodes)
File "/usr/local/lib/python2.7/dist- packages/uff/converters/tensorflow/converter.py", line 28, in convert_layer
fields = cls.parse_tf_attrs(tf_node.attr)
File "/usr/local/lib/python2.7/dist- packages/uff/converters/tensorflow/converter.py", line 177, in parse_tf_attrs
for key, val in attrs.items()}
File "/usr/local/lib/python2.7/dist- packages/uff/converters/tensorflow/converter.py", line 177, in <dictcomp>
for key, val in attrs.items()}
File "/usr/local/lib/python2.7/dist- packages/uff/converters/tensorflow/converter.py", line 172, in parse_tf_attr_value
return cls.convert_tf2uff_field(code, val)
File "/usr/local/lib/python2.7/dist- packages/uff/converters/tensorflow/converter.py", line 146, in convert_tf2uff_field
return TensorFlowToUFFConverter.convert_tf2numpy_dtype(val)
File "/usr/local/lib/python2.7/dist- packages/uff/converters/tensorflow/converter.py", line 74, in convert_tf2numpy_dtype
return np.dtype(dt[dtype])
TypeError: list indices must be integers, not AttrValue
私の実際のネットワークには、matmul の後にさらに多くの conv2d 操作があります。したがって、次のオプションを考えることができます。
TensorRT c++ API を使用してネットワーク全体を書き直します。(sampleMNISTAPI の例と同様)
ネットワークを 2 つの UFF ファイルに分割し、何らかの方法でそれらを 1 つのネットワークに結合します。このオプションがどれほど実現可能かはわかりません。
他のより良い代替手段はありますか?