当前位置: 首页>>代码示例>>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;未经允许,请勿转载。