python - tensorflow2有节点,但图def中没有节点
问题描述
我将模型保存为“已保存模型”。我正在尝试使用freeze graph.py冻结图形, 但它失败并出现错误(dense_1/BiasAdd 不在图形中)所以,我跟踪并打印了图形定义。
有节点def,但图def中没有节点。
node_def { name: "dense_1/BiasAdd" op: "BiasAdd" input: "dense_1/MatMul:product:0" input: "dense_1/BiasAdd/ReadVariableOp:value:0" attr { key: "T" value { type: DT_FLOAT } } attr { key: "_output_shapes" value { list { shape { dim { size: -1 } dim { size: 136 } } } } } experimental_debug_info { original_node_names: "dense_1/BiasAdd" } }
在 tensorflow 1 中,我可以找到输出节点。
node { name: "layer6/logits/BiasAdd" op: "BiasAdd" input: "layer6/logits/MatMul" input: "layer6/logits/bias/read" attr { key: "T" value { type: DT_FLOAT } } attr { key: "_output_shapes" value { list { shape { dim { size: -1 } dim { size: 136 } } } } } attr { key: "data_format" value { s: "NHWC" } } }
首先,我想知道为什么tensorflow 2 graph def中没有输出节点。
其次,我想在 tensorflow2 keras 模型中冻结图形。(我可以在 tensorflow 1.15 中做到这一点)
这是模型。
input_tensor = Input(shape=(WIDTH, HEIGHT, DEPTH)) x = Conv2D(32, 3, activation='relu')(input_tensor) x = BatchNormalization()(x) x = MaxPooling2D(pool_size=(2, 2), strides=(2, 2))(x) x = Conv2D(64, 3, activation='relu')(x) x = BatchNormalization()(x) x = Conv2D(64, 3, activation='relu')(x) x = BatchNormalization()(x) x = MaxPooling2D(pool_size=(2, 2), strides=(2, 2))(x) x = Conv2D(64, 3, activation='relu')(x) x = BatchNormalization()(x) x = Conv2D(64, 3, activation='relu')(x) x = BatchNormalization()(x) x = MaxPooling2D(pool_size=(2, 2), strides=(2, 2))(x) x = Conv2D(128, 3, activation='relu')(x) x = BatchNormalization()(x) x = Conv2D(128, 3, activation='relu')(x) x = BatchNormalization()(x) x = MaxPooling2D(pool_size=(2, 2), strides=(1, 1))(x) x = Conv2D(256, 3, activation='relu')(x) x = BatchNormalization()(x) x = Flatten()(x) x = Dense(256, activation='relu')(x) x = BatchNormalization()(x) output_tensor = Dense(LANDMARK*2)(x) model = Model(input_tensor, output_tensor)
解决方案
推荐阅读
- amazon-web-services - AWS Lambda 无权执行权限中列出的操作
- express - 如何部署使用 Express Router 的 Express 应用程序
- python-3.x - “ValueError:'c' 参数有 28 个元素,不能与大小为 33 的 'x'、大小为 33 的 'y' 一起使用”与 Networkx k-partite graph
- python - 函数只返回一次迭代,而不是多次。怎么了?
- c - 我如何判断输出是否是C中的整数
- dataframe - 规范化和非规范化数据框中的行
- rpy2 - 如何修复 Windows 8.1 上的 init rpy2 - Rblas 丢失?
- firebase - Firestore 双字段查询请求(和 GeoPoint)
- r - 将箱线图创建为一个图
- c# - 在 asp.net core 3.1 中使用匿名用户 ID,例如 .Net 4.x 中的 Request.AnonymousID?