codecamp

TensorFlow如何用常量替换变量

tf.graph_util.convert_variables_to_constants

convert_variables_to_constants (  
    sess ,  
    input_graph_def ,  
    output_node_names ,  
    variable_names_whitelist = None ,  
    variable_names_blacklist = None
  )

定义在:tensorflow/python/framework/graph_util_impl.py

用相同值的常量替换图中的所有变量.

如果您有一个包含变量(Variable)操作的训练有素的图表,那么可以将它们全部转换为具有相同值的 CONST 操作.这样可以用一个 GraphDef 文件完全描述网络,并允许删除许多与加载和保存变量相关的操作.

参数:

  • sess:包含变量的 Active TensorFlow 会话.
  • input_graph_def:具有网络的 GraphDef 对象.
  • output_node_names:图表结果节点的名称字符串列表.
  • variable_names_whitelist:要转换的变量名称集合(默认情况下,所有变量都将被转换).
  • variable_names_blacklist:要省略转换为常量的变量名的集合.

返回值:

GraphDef 包含原版的一个简化的版本.

TensorFlow函数:tf.gfile.Walk
如何操作TensorFlow张量图的节点
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

TensorFlow 函数介绍

TensorFlow 函数模块:tf

TensorFlow的image模块

TensorFlow使用之tf.io

TensorFlow使用之tf.keras

TensorFlow函数教程:tf.keras.applications

TensorFlow函数教程:tf.keras.backend

TensorFlow使用之tf.metrics

TensorFlow使用之tf.nn

TensorFlow使用之tf.python_io

TensorFlow 功能函数

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }