作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
与How to access values in protos in TensorFlow?类似,但不适合这种情况。
我在TensorProto中看到了bytes tensor_content
属性。我正在尝试通过以下方式获取有关节点的信息:
for node in tf.get_default_graph().as_graph_def().node:
node.attr['value'].tensor.tensor_content # decode these bytes
有关信息,节点的打印看起来像这样:
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"
}
}
}
最佳答案
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)
关于tensorflow - 如何在TensorFlow中的TensorProto中访问tensor_content值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44125403/
我是一名优秀的程序员,十分优秀!