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


Python gen_array_ops.fill方法代碼示例

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


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

示例1: scheduled_sampling

# 需要導入模塊: from tensorflow.python.ops import gen_array_ops [as 別名]
# 或者: from tensorflow.python.ops.gen_array_ops import fill [as 別名]
def scheduled_sampling(self, batch_size, sampling_probability, true, estimate):
    with variable_scope.variable_scope("ScheduledEmbedding"):
      # Return -1s where we do not sample, and sample_ids elsewhere
      select_sampler = bernoulli.Bernoulli(probs=sampling_probability, dtype=tf.bool)
      select_sample = select_sampler.sample(sample_shape=batch_size)
      sample_ids = array_ops.where(
                  select_sample,
                  tf.range(batch_size),
                  gen_array_ops.fill([batch_size], -1))
      where_sampling = math_ops.cast(
          array_ops.where(sample_ids > -1), tf.int32)
      where_not_sampling = math_ops.cast(
          array_ops.where(sample_ids <= -1), tf.int32)
      _estimate = array_ops.gather_nd(estimate, where_sampling)
      _true = array_ops.gather_nd(true, where_not_sampling)

      base_shape = array_ops.shape(true)
      result1 = array_ops.scatter_nd(indices=where_sampling, updates=_estimate, shape=base_shape)
      result2 = array_ops.scatter_nd(indices=where_not_sampling, updates=_true, shape=base_shape)
      result = result1 + result2
      return result1 + result2 
開發者ID:yaserkl,項目名稱:TransferRL,代碼行數:23,代碼來源:run_summarization.py

示例2: sample

# 需要導入模塊: from tensorflow.python.ops import gen_array_ops [as 別名]
# 或者: from tensorflow.python.ops.gen_array_ops import fill [as 別名]
def sample(self, time, outputs, state, name=None):
        """Gets a sample for one step."""
        with ops.name_scope(name, "ScheduledEmbeddingTrainingHelperSample",
                            [time, outputs, state]):
            # Return -1s where we did not sample, and sample_ids elsewhere
            select_sampler = bernoulli.Bernoulli(
                probs=self._sampling_probability, dtype=dtypes.bool)
            select_sample = select_sampler.sample(
                sample_shape=self.batch_size, seed=self._scheduling_seed)
            sample_id_sampler = categorical.Categorical(logits=outputs)
            return array_ops.where(
                select_sample,
                sample_id_sampler.sample(seed=self._seed),
                gen_array_ops.fill([self.batch_size], -1)) 
開發者ID:qkaren,項目名稱:Counterfactual-StoryRW,代碼行數:16,代碼來源:tf_helpers.py

示例3: sample

# 需要導入模塊: from tensorflow.python.ops import gen_array_ops [as 別名]
# 或者: from tensorflow.python.ops.gen_array_ops import fill [as 別名]
def sample(self, time, outputs, state, name=None):
    with ops.name_scope(name, "ScheduledEmbeddingTrainingHelperSample",
                        [time, outputs, state]):
      # Return -1s where we did not sample, and sample_ids elsewhere
      select_sampler = bernoulli.Bernoulli(
          probs=self._sampling_probability, dtype=dtypes.bool)
      select_sample = select_sampler.sample(
          sample_shape=self.batch_size, seed=self._scheduling_seed)
      sample_id_sampler = categorical.Categorical(logits=outputs)
      return array_ops.where(
          select_sample,
          sample_id_sampler.sample(seed=self._seed),
          gen_array_ops.fill([self.batch_size], -1)) 
開發者ID:NVIDIA,項目名稱:OpenSeq2Seq,代碼行數:15,代碼來源:helper.py

示例4: sample

# 需要導入模塊: from tensorflow.python.ops import gen_array_ops [as 別名]
# 或者: from tensorflow.python.ops.gen_array_ops import fill [as 別名]
def sample(self, time, outputs, state, name=None):
        """Gets a sample for one step."""
        with ops.name_scope(name, "ScheduledEmbeddingTrainingHelperSample",
                            [time, outputs, state]):
            # Return -1s where we did not sample, and sample_ids elsewhere
            select_sampler = tfpd.Bernoulli(
                probs=self._sampling_probability, dtype=dtypes.bool)
            select_sample = select_sampler.sample(
                sample_shape=self.batch_size, seed=self._scheduling_seed)
            sample_id_sampler = tfpd.Categorical(logits=outputs)
            return array_ops.where(
                select_sample,
                sample_id_sampler.sample(seed=self._seed),
                gen_array_ops.fill([self.batch_size], -1)) 
開發者ID:asyml,項目名稱:texar,代碼行數:16,代碼來源:tf_helpers.py

示例5: _create_slots

# 需要導入模塊: from tensorflow.python.ops import gen_array_ops [as 別名]
# 或者: from tensorflow.python.ops.gen_array_ops import fill [as 別名]
def _create_slots(self, var_list):
    for v in var_list:
      with ops.colocate_with(v):
        dtype = v.dtype.base_dtype
        if v.get_shape().is_fully_defined():
          init = init_ops.constant_initializer(self._initial_accumulator_value,
                                               dtype=dtype)
        else:
          # Use a Tensor instead of initializer if variable does not have static
          # shape.
          init_constant = gen_array_ops.fill(array_ops.shape(v),
                                             self._initial_accumulator_value)
          init = math_ops.cast(init_constant, dtype)
      self._get_or_make_slot_with_initializer(v, init, v.get_shape(), dtype,
                                              "accumulator", self._name) 
開發者ID:PacktPublishing,項目名稱:Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda,代碼行數:17,代碼來源:adagrad.py


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