首页 > 解决方案 > 如何获得经过训练的 Keras 模型的图形表示?

问题描述

我想找到图形表示中使用的运算符来构建另一个遵循 ONNX 标准的模型。我使用以下代码以某种方式获取图形表示,但这样做会使 dropout 层充当图形中的标识运算符。

full_model=tf.function(lambda x:model(x))
full_model=full_model.get_concrete_function(tf.TensorSpec(model.inputs[0].shape,model.inputs[0].dtype))
for layer in [op.name for op in 
full_model.graph.get_operations()]:
  print(layer)

我们如何实现这一点,或者我们如何获得模型中使用了哪些所有 ONNX 图运算符?

标签: tensorflowkerasgraphneural-networktf.keras

解决方案


推荐阅读