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


Python tensorflow.scatter_mul方法代碼示例

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


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

示例1: make_update_op

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import scatter_mul [as 別名]
def make_update_op(self, upd_idxs, upd_keys, upd_vals,
                     batch_size, use_recent_idx, intended_output):
    """Function that creates all the update ops."""
    base_update_op = super(LSHMemory, self).make_update_op(
        upd_idxs, upd_keys, upd_vals,
        batch_size, use_recent_idx, intended_output)

    # compute hash slots to be updated
    hash_slot_idxs = self.get_hash_slots(upd_keys)

    # make updates
    update_ops = []
    with tf.control_dependencies([base_update_op]):
      for i, slot_idxs in enumerate(hash_slot_idxs):
        # for each slot, choose which entry to replace
        entry_idx = tf.random_uniform([batch_size],
                                      maxval=self.num_per_hash_slot,
                                      dtype=tf.int32)
        entry_mul = 1 - tf.one_hot(entry_idx, self.num_per_hash_slot,
                                   dtype=tf.int32)
        entry_add = (tf.expand_dims(upd_idxs, 1) *
                     tf.one_hot(entry_idx, self.num_per_hash_slot,
                                dtype=tf.int32))

        mul_op = tf.scatter_mul(self.hash_slots[i], slot_idxs, entry_mul)
        with tf.control_dependencies([mul_op]):
          add_op = tf.scatter_add(self.hash_slots[i], slot_idxs, entry_add)
          update_ops.append(add_op)

    return tf.group(*update_ops) 
開發者ID:ringringyi,項目名稱:DOTA_models,代碼行數:32,代碼來源:memory.py

示例2: testVariableRankMul

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import scatter_mul [as 別名]
def testVariableRankMul(self):
    self._VariableRankTests(tf.scatter_mul) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:4,代碼來源:scatter_ops_test.py

示例3: testRepeatIndicesMul

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import scatter_mul [as 別名]
def testRepeatIndicesMul(self):
    self._VariableRankTests(tf.scatter_mul, True) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:4,代碼來源:scatter_ops_test.py


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