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


Python core.Dropout方法代碼示例

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


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

示例1: dropout

# 需要導入模塊: from tensorflow.python.layers import core [as 別名]
# 或者: from tensorflow.python.layers.core import Dropout [as 別名]
def dropout(inputs,
            keep_prob=0.5,
            noise_shape=None,
            is_training=True,
            outputs_collections=None,
            scope=None,
            seed=None):
  """Returns a dropout op applied to the input.

  With probability `keep_prob`, outputs the input element scaled up by
  `1 / keep_prob`, otherwise outputs `0`.  The scaling is so that the expected
  sum is unchanged.

  Args:
    inputs: The tensor to pass to the nn.dropout op.
    keep_prob: A scalar `Tensor` with the same type as x. The probability that
      each element is kept.
    noise_shape: A 1-D `Tensor` of type `int32`, representing the shape for
      randomly generated keep/drop flags.
    is_training: A bool `Tensor` indicating whether or not the model is in
      training mode. If so, dropout is applied and values scaled. Otherwise,
      inputs is returned.
    outputs_collections: Collection to add the outputs.
    scope: Optional scope for name_scope.
    seed: A Python integer. Used to create random seeds. See
      `tf.compat.v1.set_random_seed` for behavior.

  Returns:
    A tensor representing the output of the operation.
  """
  with variable_scope.variable_scope(
      scope, 'Dropout', [inputs], custom_getter=_model_variable_getter) as sc:
    inputs = ops.convert_to_tensor(inputs)
    layer = core_layers.Dropout(
        rate=1 - keep_prob,
        noise_shape=noise_shape,
        seed=seed,
        name=sc.name,
        _scope=sc)
    outputs = layer.apply(inputs, training=is_training)
    return utils.collect_named_outputs(outputs_collections, sc.name, outputs) 
開發者ID:taehoonlee,項目名稱:tensornets,代碼行數:43,代碼來源:layers.py

示例2: __init__

# 需要導入模塊: from tensorflow.python.layers import core [as 別名]
# 或者: from tensorflow.python.layers.core import Dropout [as 別名]
def __init__(self, rate, noise_shape=None, seed=None, **kwargs):
    self.supports_masking = True
    # Inheritance call order:
    # 1) tf.layers.Dropout, 2) keras.layers.Layer, 3) tf.layers.Layer
    super(Dropout, self).__init__(**kwargs) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:7,代碼來源:core.py

示例3: call

# 需要導入模塊: from tensorflow.python.layers import core [as 別名]
# 或者: from tensorflow.python.layers.core import Dropout [as 別名]
def call(self, inputs, training=None):
    if training is None:
      training = K.learning_phase()
    output = super(Dropout, self).call(inputs, training=training)
    if training is K.learning_phase():
      output._uses_learning_phase = True  # pylint: disable=protected-access
    return output 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:9,代碼來源:core.py

示例4: get_config

# 需要導入模塊: from tensorflow.python.layers import core [as 別名]
# 或者: from tensorflow.python.layers.core import Dropout [as 別名]
def get_config(self):
    config = {'rate': self.rate}
    base_config = super(Dropout, self).get_config()
    return dict(list(base_config.items()) + list(config.items())) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:6,代碼來源:core.py

示例5: dropout

# 需要導入模塊: from tensorflow.python.layers import core [as 別名]
# 或者: from tensorflow.python.layers.core import Dropout [as 別名]
def dropout(inputs,
            keep_prob=0.5,
            noise_shape=None,
            is_training=True,
            outputs_collections=None,
            scope=None):
  """Returns a dropout op applied to the input.

  With probability `keep_prob`, outputs the input element scaled up by
  `1 / keep_prob`, otherwise outputs `0`.  The scaling is so that the expected
  sum is unchanged.

  Args:
    inputs: The tensor to pass to the nn.dropout op.
    keep_prob: A scalar `Tensor` with the same type as x. The probability
      that each element is kept.
    noise_shape: A 1-D `Tensor` of type `int32`, representing the
      shape for randomly generated keep/drop flags.
    is_training: A bool `Tensor` indicating whether or not the model
      is in training mode. If so, dropout is applied and values scaled.
      Otherwise, inputs is returned.
    outputs_collections: Collection to add the outputs.
    scope: Optional scope for name_scope.

  Returns:
    A tensor representing the output of the operation.
  """
  with variable_scope.variable_scope(
      scope, 'Dropout', [inputs], custom_getter=_model_variable_getter) as sc:
    inputs = ops.convert_to_tensor(inputs)
    layer = core_layers.Dropout(rate=1 - keep_prob,
                                noise_shape=noise_shape,
                                name=sc.name,
                                _scope=sc)
    outputs = layer.apply(inputs, training=is_training)
    return utils.collect_named_outputs(
        outputs_collections, sc.original_name_scope, outputs) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:39,代碼來源:layers.py

示例6: dropout

# 需要導入模塊: from tensorflow.python.layers import core [as 別名]
# 或者: from tensorflow.python.layers.core import Dropout [as 別名]
def dropout(inputs,
            keep_prob=0.5,
            noise_shape=None,
            is_training=True,
            outputs_collections=None,
            scope=None):
  """Returns a dropout op applied to the input.

  With probability `keep_prob`, outputs the input element scaled up by
  `1 / keep_prob`, otherwise outputs `0`.  The scaling is so that the expected
  sum is unchanged.

  Args:
    inputs: the tensor to pass to the nn.dropout op.
    keep_prob: A scalar `Tensor` with the same type as x. The probability
      that each element is kept.
    noise_shape: A 1-D `Tensor` of type `int32`, representing the
      shape for randomly generated keep/drop flags.
    is_training: A bool `Tensor` indicating whether or not the model
      is in training mode. If so, dropout is applied and values scaled.
      Otherwise, inputs is returned.
    outputs_collections: collection to add the outputs.
    scope: Optional scope for name_scope.

  Returns:
    a tensor representing the output of the operation.
  """
  with variable_scope.variable_scope(
      scope, 'Dropout', [inputs], custom_getter=_model_variable_getter) as sc:
    inputs = ops.convert_to_tensor(inputs)
    layer = core_layers.Dropout(rate=1 - keep_prob,
                                noise_shape=noise_shape,
                                name=sc.name,
                                _scope=sc)
    outputs = layer.apply(inputs, training=is_training)
    return utils.collect_named_outputs(
        outputs_collections, sc.original_name_scope, outputs) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:39,代碼來源:layers.py

示例7: __init__

# 需要導入模塊: from tensorflow.python.layers import core [as 別名]
# 或者: from tensorflow.python.layers.core import Dropout [as 別名]
def __init__(self, rate, noise_shape=None, seed=None, **kwargs):
    self.supports_masking = True
    # Inheritance call order:
    # 1) tf.layers.Dropout, 2) keras.layers.Layer, 3) tf.layers.Layer
    super(Dropout, self).__init__(rate=rate,
                                  noise_shape=noise_shape,
                                  seed=seed,
                                  **kwargs) 
開發者ID:PacktPublishing,項目名稱:Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda,代碼行數:10,代碼來源:core.py


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