
获取Switch_v1.pb网络模型【免费下载链接】geGEGraph Engine是面向昇腾的图编译器和执行器提供了计算图优化、多流并行、内存复用和模型下沉等技术手段加速模型执行效率减少模型内存占用。 GE 提供对 PyTorch、TensorFlow 前端的友好接入能力并同时支持 onnx、pb 等主流模型格式的解析与编译。项目地址: https://gitcode.com/cann/ge将如下文件中的脚本复制到.py文件中例如复制到_Switch_v1.py_文件中。import os import numpy as np import tensorflow as tf x tf.compat.v1.placeholder(tf.float32, namex) y tf.compat.v1.placeholder(tf.float32, namey) z tf.compat.v1.placeholder(tf.float32, namez) def then_branch(x, y, z): m tf.square(x) return m tf.multiply(y, z) def else_branch(x, y, z): m tf.pow(x, y) return m - tf.div(y, z) # 控制流算子使用入口执行脚本之后在图中生成对应的V1控制流算子 def testDefun(x, y, z): return tf.cond(predx y, true_fnlambda: then_branch(x, y, z), false_fnlambda: else_branch(x, y, z)), y def testCase(x, y, z): a, b testDefun(x, y, z) return a b * z with tf.compat.v1.Session() as sess: result sess.run(testCase(x, y, z), feed_dict{x: 1., y: .6, z: .2}) with tf.io.gfile.GFile(./Switch_v1.pb, wb) as f: f.write(sess.graph_def.SerializeToString())切换到_Switch_v1.py_脚本所在目录执行如下命令生成Switch_v1.pb网络模型python3.7.5 Switch_v1.py命令执行完毕在当前目录会生成Switch_v1.pb网络模型。【免费下载链接】geGEGraph Engine是面向昇腾的图编译器和执行器提供了计算图优化、多流并行、内存复用和模型下沉等技术手段加速模型执行效率减少模型内存占用。 GE 提供对 PyTorch、TensorFlow 前端的友好接入能力并同时支持 onnx、pb 等主流模型格式的解析与编译。项目地址: https://gitcode.com/cann/ge创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考