codecamp

TensorFlow构建图形:tf.name_scope函数

tf.name_scope 函数

别名:

  • tf.contrib.keras.backend.name_scope
  • tf.name_scope
name_scope(
    name,
    default_name=None,
    values=None
)

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

参见指南:构建图>实用程序功能

返回在定义 Python 操作时使用的上下文管理器.

该上下文管理器验证给定的 values 来自同一个图形,使该图形成为默认图形,并在该图形中推送名称范围(参考 tf.Graph.name_scope).

例如,下面示例定义一个新的 Python 操作:my_op:

def my_op(a, b, c, name=None):
  with tf.name_scope(name, "MyOp", [a, b, c]) as scope:
    a = tf.convert_to_tensor(a, name="a")
    b = tf.convert_to_tensor(b, name="b")
    c = tf.convert_to_tensor(c, name="c")
    # Define some computation that uses `a`, `b`, and `c`.
    return foo_op(..., name=scope)

参数:

  • name:传递给 op 函数的 name 参数.
  • default_name:如果 name 参数为 None 则使用默认的名称.
  • values:要传递给 op 函数的张量参数列表.

返回值:

该函数返回用于定义 Python 操作系统的上下文管理器,生成名称范围.

可能发生的异常:

  • ValueError:如果既不提供 name 也不提供 default_name,但是提供了 values.
multinomial函数:从多项式分布中抽取样本
TensorFlow函数:tf.negative
温馨提示
下载编程狮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; }