2017-05-23 9 views
3

How to access values in protos in TensorFlow?と似ていますが、この場合は対応していません。TensorProtoのtensor_content値にアクセスするには?

bytes tensor_content属性はTensorProtoです。私は、ノードの情報を介して取得しようとしている:

name: "conv2d/convolution/Shape" 
op: "Const" 
device: "/device:GPU:0" 
attr { 
    key: "dtype" 
    value { 
    type: DT_INT32 
    } 
} 
attr { 
    key: "value" 
    value { 
    tensor { 
     dtype: DT_INT32 
     tensor_shape { 
     dim { 
      size: 4 
     } 
     } 
     tensor_content: "\003\000\000\000\003\000\000\000\001\000\000\000 \000\000\000" 
    } 
    } 
} 

答えて

3
from tensorflow.python.framework import tensor_util 

for n in tf.get_default_graph().as_graph_def().node: 
    print tensor_util.MakeNdarray(n.attr['value'].tensor) 
:情報について

for node in tf.get_default_graph().as_graph_def().node: node.attr['value'].tensor.tensor_content # decode these bytes

、ノードの印刷は次のようになります

関連する問題