variables.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:Tensormodels 作者: asheshjain399 项目源码 文件源码
def get_unique_variable(name):
  """Gets the variable uniquely identified by that name.

  Args:
    name: a name that uniquely identifies the variable.

  Returns:
    a tensorflow variable.

  Raises:
    ValueError: if no variable uniquely identified by the name exists.
  """
  candidates = tf.get_collection(tf.GraphKeys.VARIABLES, name)
  if not candidates:
    raise ValueError('Couldnt find variable %s' % name)

  for candidate in candidates:
    if candidate.op.name == name:
      return candidate
  raise ValueError('Variable %s does not uniquely identify a variable', name)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号