當前位置: 首頁>>代碼示例>>Python>>正文


Python ops.get_collection_ref方法代碼示例

本文整理匯總了Python中tensorflow.python.framework.ops.get_collection_ref方法的典型用法代碼示例。如果您正苦於以下問題:Python ops.get_collection_ref方法的具體用法?Python ops.get_collection_ref怎麽用?Python ops.get_collection_ref使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tensorflow.python.framework.ops的用法示例。


在下文中一共展示了ops.get_collection_ref方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _add_elements_to_collection

# 需要導入模塊: from tensorflow.python.framework import ops [as 別名]
# 或者: from tensorflow.python.framework.ops import get_collection_ref [as 別名]
def _add_elements_to_collection(elements, collection_list):
  elements = _to_list(elements)
  collection_list = _to_list(collection_list)
  for name in collection_list:
    collection = ops.get_collection_ref(name)
    collection_set = set(collection)
    for element in elements:
      if element not in collection_set:
        collection.append(element) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:11,代碼來源:base.py

示例2: reset_uids

# 需要導入模塊: from tensorflow.python.framework import ops [as 別名]
# 或者: from tensorflow.python.framework.ops import get_collection_ref [as 別名]
def reset_uids():
  layer_name_uids_collection = ops.get_collection_ref('LAYER_NAME_UIDS')
  if layer_name_uids_collection:
    layer_name_uids_collection.pop() 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:6,代碼來源:backend.py

示例3: _set_axis_order

# 需要導入模塊: from tensorflow.python.framework import ops [as 別名]
# 或者: from tensorflow.python.framework.ops import get_collection_ref [as 別名]
def _set_axis_order(axis_order):
  axis_order_list = ops.get_collection_ref(_AXIS_ORDER_KEY)
  if axis_order_list:
    axis_order_list[0] = axis_order
  else:
    axis_order_list.append(axis_order) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:8,代碼來源:core.py

示例4: _add_elements_to_collection

# 需要導入模塊: from tensorflow.python.framework import ops [as 別名]
# 或者: from tensorflow.python.framework.ops import get_collection_ref [as 別名]
def _add_elements_to_collection(elements, collections):
  elements = _to_list(elements)
  collections = _to_list(collections)
  for name in collections:
    collection = ops.get_collection_ref(name)
    collection_set = set(collection)
    for element in elements:
      if element not in collection_set:
        collection.append(element) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:11,代碼來源:base.py

示例5: testWithIsRecomputeKwarg

# 需要導入模塊: from tensorflow.python.framework import ops [as 別名]
# 或者: from tensorflow.python.framework.ops import get_collection_ref [as 別名]
def testWithIsRecomputeKwarg(self):

    kwarg_values = []

    @rev_block_lib.recompute_grad
    def layer_with_recompute(inputs, is_recomputing=False):
      kwarg_values.append(is_recomputing)
      out = core_layers.dense(inputs, 2)
      out = normalization_layers.batch_normalization(out, training=True)
      if is_recomputing:
        # Ensure that the updates are not duplicated by popping off the latest
        # 2 additions.
        update_ops = ops.get_collection_ref(ops.GraphKeys.UPDATE_OPS)
        update_ops.pop()
        update_ops.pop()
      return out

    x = array_ops.ones((2, 4), dtypes.float32)
    with variable_scope.variable_scope("layer1", use_resource=True):
      y = layer_with_recompute(x)
    loss = math_ops.reduce_sum(y)
    tvars = variables.trainable_variables()
    gradients_impl.gradients(loss, [x] + tvars)

    update_ops = ops.get_collection(ops.GraphKeys.UPDATE_OPS)
    self.assertEqual(2, len(update_ops))
    self.assertEqual([False, True], kwarg_values) 
開發者ID:google-research,項目名稱:tf-slim,代碼行數:29,代碼來源:rev_block_lib_test.py

示例6: begin

# 需要導入模塊: from tensorflow.python.framework import ops [as 別名]
# 或者: from tensorflow.python.framework.ops import get_collection_ref [as 別名]
def begin(self):
    local_vars = variables.trainable_variables()
    global_vars = ops.get_collection_ref("global_model")
    self._variable_init_op = self._fed_avg_optimizer._assign_vars(
        local_vars,
        global_vars) 
開發者ID:coMindOrg,項目名稱:federated-averaging-tutorials,代碼行數:8,代碼來源:federated_averaging_optimizer.py

示例7: _add_elements_to_collection

# 需要導入模塊: from tensorflow.python.framework import ops [as 別名]
# 或者: from tensorflow.python.framework.ops import get_collection_ref [as 別名]
def _add_elements_to_collection(elements, collection_list):
  if context.in_eager_mode():
    raise RuntimeError('Using collections from Layers not supported in Eager '
                       'mode. Tried to add %s to %s' % (elements,
                                                        collection_list))
  elements = _to_list(elements)
  collection_list = _to_list(collection_list)
  for name in collection_list:
    collection = ops.get_collection_ref(name)
    collection_set = set(collection)
    for element in elements:
      if element not in collection_set:
        collection.append(element) 
開發者ID:PacktPublishing,項目名稱:Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda,代碼行數:15,代碼來源:base.py


注:本文中的tensorflow.python.framework.ops.get_collection_ref方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。