Python tensorflow.python.ops.nn.softplus() Examples

The following are 30 code examples of tensorflow.python.ops.nn.softplus(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module tensorflow.python.ops.nn , or try the search function .
Example #1
Source File: student_t.py    From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License 6 votes vote down vote up
def __init__(self,
               df,
               loc,
               scale,
               validate_args=False,
               allow_nan_stats=True,
               name="StudentTWithAbsDfSoftplusScale"):
    parameters = locals()
    with ops.name_scope(name, values=[df, scale]):
      super(StudentTWithAbsDfSoftplusScale, self).__init__(
          df=math_ops.floor(math_ops.abs(df)),
          loc=loc,
          scale=nn.softplus(scale, name="softplus_scale"),
          validate_args=validate_args,
          allow_nan_stats=allow_nan_stats,
          name=name)
    self._parameters = parameters 
Example #2
Source File: gamma.py    From deep_image_model with Apache License 2.0 6 votes vote down vote up
def __init__(self,
               alpha,
               beta,
               validate_args=False,
               allow_nan_stats=True,
               name="GammaWithSoftplusAlphaBeta"):
    parameters = locals()
    parameters.pop("self")
    with ops.name_scope(name, values=[alpha, beta]) as ns:
      super(GammaWithSoftplusAlphaBeta, self).__init__(
          alpha=nn.softplus(alpha),
          beta=nn.softplus(beta),
          validate_args=validate_args,
          allow_nan_stats=allow_nan_stats,
          name=ns)
    self._parameters = parameters 
Example #3
Source File: inverse_gamma.py    From deep_image_model with Apache License 2.0 6 votes vote down vote up
def __init__(self,
               alpha,
               beta,
               validate_args=False,
               allow_nan_stats=True,
               name="InverseGammaWithSoftplusAlphaBeta"):
    parameters = locals()
    parameters.pop("self")
    with ops.name_scope(name, values=[alpha, beta]) as ns:
      super(InverseGammaWithSoftplusAlphaBeta, self).__init__(
          alpha=nn.softplus(alpha),
          beta=nn.softplus(beta),
          validate_args=validate_args,
          allow_nan_stats=allow_nan_stats,
          name=ns)
    self._parameters = parameters 
Example #4
Source File: gamma.py    From lambda-packs with MIT License 6 votes vote down vote up
def __init__(self,
               concentration,
               rate,
               validate_args=False,
               allow_nan_stats=True,
               name="GammaWithSoftplusConcentrationRate"):
    parameters = locals()
    with ops.name_scope(name, values=[concentration, rate]):
      super(GammaWithSoftplusConcentrationRate, self).__init__(
          concentration=nn.softplus(concentration,
                                    name="softplus_concentration"),
          rate=nn.softplus(rate, name="softplus_rate"),
          validate_args=validate_args,
          allow_nan_stats=allow_nan_stats,
          name=name)
    self._parameters = parameters 
Example #5
Source File: mvn.py    From deep_image_model with Apache License 2.0 6 votes vote down vote up
def __init__(self,
               mu,
               diag_stdev,
               validate_args=False,
               allow_nan_stats=True,
               name="MultivariateNormalDiagWithSoftplusStdDev"):
    parameters = locals()
    parameters.pop("self")
    with ops.name_scope(name, values=[diag_stdev]) as ns:
      super(MultivariateNormalDiagWithSoftplusStDev, self).__init__(
          mu=mu,
          diag_stdev=nn.softplus(diag_stdev),
          validate_args=validate_args,
          allow_nan_stats=allow_nan_stats,
          name=ns)
    self._parameters = parameters 
Example #6
Source File: bernoulli.py    From deep_image_model with Apache License 2.0 6 votes vote down vote up
def _kl_bernoulli_bernoulli(a, b, name=None):
  """Calculate the batched KL divergence KL(a || b) with a and b Bernoulli.

  Args:
    a: instance of a Bernoulli distribution object.
    b: instance of a Bernoulli distribution object.
    name: (optional) Name to use for created operations.
      default is "kl_bernoulli_bernoulli".

  Returns:
    Batchwise KL(a || b)
  """
  with ops.name_scope(name, "kl_bernoulli_bernoulli", [a.logits, b.logits]):
    return (math_ops.sigmoid(a.logits) * (-nn.softplus(-a.logits) +
                                          nn.softplus(-b.logits)) +
            math_ops.sigmoid(-a.logits) * (-nn.softplus(a.logits) +
                                           nn.softplus(b.logits))) 
Example #7
Source File: laplace.py    From deep_image_model with Apache License 2.0 6 votes vote down vote up
def __init__(self,
               loc,
               scale,
               validate_args=False,
               allow_nan_stats=True,
               name="LaplaceWithSoftplusScale"):
    parameters = locals()
    parameters.pop("self")
    with ops.name_scope(name, values=[loc, scale]) as ns:
      super(LaplaceWithSoftplusScale, self).__init__(
          loc=loc,
          scale=nn.softplus(scale),
          validate_args=validate_args,
          allow_nan_stats=allow_nan_stats,
          name=ns)
    self._parameters = parameters 
Example #8
Source File: normal.py    From deep_image_model with Apache License 2.0 6 votes vote down vote up
def __init__(self,
               mu,
               sigma,
               validate_args=False,
               allow_nan_stats=True,
               name="NormalWithSoftplusSigma"):
    parameters = locals()
    parameters.pop("self")
    with ops.name_scope(name, values=[sigma]) as ns:
      super(NormalWithSoftplusSigma, self).__init__(
          mu=mu,
          sigma=nn.softplus(sigma),
          validate_args=validate_args,
          allow_nan_stats=allow_nan_stats,
          name=ns)
    self._parameters = parameters 
Example #9
Source File: gamma.py    From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License 6 votes vote down vote up
def __init__(self,
               concentration,
               rate,
               validate_args=False,
               allow_nan_stats=True,
               name="GammaWithSoftplusConcentrationRate"):
    parameters = locals()
    with ops.name_scope(name, values=[concentration, rate]):
      super(GammaWithSoftplusConcentrationRate, self).__init__(
          concentration=nn.softplus(concentration,
                                    name="softplus_concentration"),
          rate=nn.softplus(rate, name="softplus_rate"),
          validate_args=validate_args,
          allow_nan_stats=allow_nan_stats,
          name=name)
    self._parameters = parameters 
Example #10
Source File: beta.py    From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License 6 votes vote down vote up
def __init__(self,
               concentration1,
               concentration0,
               validate_args=False,
               allow_nan_stats=True,
               name="BetaWithSoftplusConcentration"):
    parameters = locals()
    with ops.name_scope(name, values=[concentration1,
                                      concentration0]) as ns:
      super(BetaWithSoftplusConcentration, self).__init__(
          concentration1=nn.softplus(concentration1,
                                     name="softplus_concentration1"),
          concentration0=nn.softplus(concentration0,
                                     name="softplus_concentration0"),
          validate_args=validate_args,
          allow_nan_stats=allow_nan_stats,
          name=ns)
    self._parameters = parameters 
Example #11
Source File: beta.py    From deep_image_model with Apache License 2.0 6 votes vote down vote up
def __init__(self,
               a,
               b,
               validate_args=False,
               allow_nan_stats=True,
               name="BetaWithSoftplusAB"):
    parameters = locals()
    parameters.pop("self")
    with ops.name_scope(name, values=[a, b]) as ns:
      super(BetaWithSoftplusAB, self).__init__(
          a=nn.softplus(a),
          b=nn.softplus(b),
          validate_args=validate_args,
          allow_nan_stats=allow_nan_stats,
          name=ns)
    self._parameters = parameters 
Example #12
Source File: bernoulli.py    From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License 6 votes vote down vote up
def _kl_bernoulli_bernoulli(a, b, name=None):
  """Calculate the batched KL divergence KL(a || b) with a and b Bernoulli.

  Args:
    a: instance of a Bernoulli distribution object.
    b: instance of a Bernoulli distribution object.
    name: (optional) Name to use for created operations.
      default is "kl_bernoulli_bernoulli".

  Returns:
    Batchwise KL(a || b)
  """
  with ops.name_scope(name, "kl_bernoulli_bernoulli",
                      values=[a.logits, b.logits]):
    delta_probs0 = nn.softplus(-b.logits) - nn.softplus(-a.logits)
    delta_probs1 = nn.softplus(b.logits) - nn.softplus(a.logits)
    return (math_ops.sigmoid(a.logits) * delta_probs0
            + math_ops.sigmoid(-a.logits) * delta_probs1) 
Example #13
Source File: gamma.py    From keras-lambda with MIT License 6 votes vote down vote up
def __init__(self,
               alpha,
               beta,
               validate_args=False,
               allow_nan_stats=True,
               name="GammaWithSoftplusAlphaBeta"):
    parameters = locals()
    parameters.pop("self")
    with ops.name_scope(name, values=[alpha, beta]) as ns:
      super(GammaWithSoftplusAlphaBeta, self).__init__(
          alpha=nn.softplus(alpha, name="softplus_alpha"),
          beta=nn.softplus(beta, name="softplus_beta"),
          validate_args=validate_args,
          allow_nan_stats=allow_nan_stats,
          name=ns)
    self._parameters = parameters 
Example #14
Source File: inverse_gamma.py    From keras-lambda with MIT License 6 votes vote down vote up
def __init__(self,
               alpha,
               beta,
               validate_args=False,
               allow_nan_stats=True,
               name="InverseGammaWithSoftplusAlphaBeta"):
    parameters = locals()
    parameters.pop("self")
    with ops.name_scope(name, values=[alpha, beta]) as ns:
      super(InverseGammaWithSoftplusAlphaBeta, self).__init__(
          alpha=nn.softplus(alpha, name="softplus_alpha"),
          beta=nn.softplus(beta, name="softplus_gamma"),
          validate_args=validate_args,
          allow_nan_stats=allow_nan_stats,
          name=ns)
    self._parameters = parameters 
Example #15
Source File: beta.py    From keras-lambda with MIT License 6 votes vote down vote up
def __init__(self,
               a,
               b,
               validate_args=False,
               allow_nan_stats=True,
               name="BetaWithSoftplusAB"):
    parameters = locals()
    parameters.pop("self")
    with ops.name_scope(name, values=[a, b]) as ns:
      super(BetaWithSoftplusAB, self).__init__(
          a=nn.softplus(a, name="softplus_a"),
          b=nn.softplus(b, name="softplus_b"),
          validate_args=validate_args,
          allow_nan_stats=allow_nan_stats,
          name=ns)
    self._parameters = parameters 
Example #16
Source File: mvn.py    From keras-lambda with MIT License 6 votes vote down vote up
def __init__(self,
               mu,
               diag_stdev,
               validate_args=False,
               allow_nan_stats=True,
               name="MultivariateNormalDiagWithSoftplusStdDev"):
    parameters = locals()
    parameters.pop("self")
    with ops.name_scope(name, values=[diag_stdev]) as ns:
      super(MultivariateNormalDiagWithSoftplusStDev, self).__init__(
          mu=mu,
          diag_stdev=nn.softplus(diag_stdev),
          validate_args=validate_args,
          allow_nan_stats=allow_nan_stats,
          name=ns)
    self._parameters = parameters 
Example #17
Source File: bernoulli.py    From keras-lambda with MIT License 6 votes vote down vote up
def _kl_bernoulli_bernoulli(a, b, name=None):
  """Calculate the batched KL divergence KL(a || b) with a and b Bernoulli.

  Args:
    a: instance of a Bernoulli distribution object.
    b: instance of a Bernoulli distribution object.
    name: (optional) Name to use for created operations.
      default is "kl_bernoulli_bernoulli".

  Returns:
    Batchwise KL(a || b)
  """
  with ops.name_scope(name, "kl_bernoulli_bernoulli", [a.logits, b.logits]):
    return (math_ops.sigmoid(a.logits) * (-nn.softplus(-a.logits) +
                                          nn.softplus(-b.logits)) +
            math_ops.sigmoid(-a.logits) * (-nn.softplus(a.logits) +
                                           nn.softplus(b.logits))) 
Example #18
Source File: laplace.py    From keras-lambda with MIT License 6 votes vote down vote up
def __init__(self,
               loc,
               scale,
               validate_args=False,
               allow_nan_stats=True,
               name="LaplaceWithSoftplusScale"):
    parameters = locals()
    parameters.pop("self")
    with ops.name_scope(name, values=[loc, scale]) as ns:
      super(LaplaceWithSoftplusScale, self).__init__(
          loc=loc,
          scale=nn.softplus(scale, name="softplus_scale"),
          validate_args=validate_args,
          allow_nan_stats=allow_nan_stats,
          name=ns)
    self._parameters = parameters 
Example #19
Source File: normal.py    From keras-lambda with MIT License 6 votes vote down vote up
def __init__(self,
               mu,
               sigma,
               validate_args=False,
               allow_nan_stats=True,
               name="NormalWithSoftplusSigma"):
    parameters = locals()
    parameters.pop("self")
    with ops.name_scope(name, values=[sigma]) as ns:
      super(NormalWithSoftplusSigma, self).__init__(
          mu=mu,
          sigma=nn.softplus(sigma, name="softplus_sigma"),
          validate_args=validate_args,
          allow_nan_stats=allow_nan_stats,
          name=ns)
    self._parameters = parameters 
Example #20
Source File: laplace.py    From auto-alt-text-lambda-api with MIT License 6 votes vote down vote up
def __init__(self,
               loc,
               scale,
               validate_args=False,
               allow_nan_stats=True,
               name="LaplaceWithSoftplusScale"):
    parameters = locals()
    parameters.pop("self")
    with ops.name_scope(name, values=[loc, scale]) as ns:
      super(LaplaceWithSoftplusScale, self).__init__(
          loc=loc,
          scale=nn.softplus(scale, name="softplus_scale"),
          validate_args=validate_args,
          allow_nan_stats=allow_nan_stats,
          name=ns)
    self._parameters = parameters 
Example #21
Source File: normal.py    From auto-alt-text-lambda-api with MIT License 6 votes vote down vote up
def __init__(self,
               mu,
               sigma,
               validate_args=False,
               allow_nan_stats=True,
               name="NormalWithSoftplusSigma"):
    parameters = locals()
    parameters.pop("self")
    with ops.name_scope(name, values=[sigma]) as ns:
      super(NormalWithSoftplusSigma, self).__init__(
          mu=mu,
          sigma=nn.softplus(sigma, name="softplus_sigma"),
          validate_args=validate_args,
          allow_nan_stats=allow_nan_stats,
          name=ns)
    self._parameters = parameters 
Example #22
Source File: bernoulli.py    From auto-alt-text-lambda-api with MIT License 6 votes vote down vote up
def _kl_bernoulli_bernoulli(a, b, name=None):
  """Calculate the batched KL divergence KL(a || b) with a and b Bernoulli.

  Args:
    a: instance of a Bernoulli distribution object.
    b: instance of a Bernoulli distribution object.
    name: (optional) Name to use for created operations.
      default is "kl_bernoulli_bernoulli".

  Returns:
    Batchwise KL(a || b)
  """
  with ops.name_scope(name, "kl_bernoulli_bernoulli", [a.logits, b.logits]):
    return (math_ops.sigmoid(a.logits) * (-nn.softplus(-a.logits) +
                                          nn.softplus(-b.logits)) +
            math_ops.sigmoid(-a.logits) * (-nn.softplus(a.logits) +
                                           nn.softplus(b.logits))) 
Example #23
Source File: beta.py    From lambda-packs with MIT License 6 votes vote down vote up
def __init__(self,
               concentration1,
               concentration0,
               validate_args=False,
               allow_nan_stats=True,
               name="BetaWithSoftplusConcentration"):
    parameters = locals()
    with ops.name_scope(name, values=[concentration1,
                                      concentration0]) as ns:
      super(BetaWithSoftplusConcentration, self).__init__(
          concentration1=nn.softplus(concentration1,
                                     name="softplus_concentration1"),
          concentration0=nn.softplus(concentration0,
                                     name="softplus_concentration0"),
          validate_args=validate_args,
          allow_nan_stats=allow_nan_stats,
          name=ns)
    self._parameters = parameters 
Example #24
Source File: student_t.py    From lambda-packs with MIT License 6 votes vote down vote up
def __init__(self,
               df,
               loc,
               scale,
               validate_args=False,
               allow_nan_stats=True,
               name="StudentTWithAbsDfSoftplusScale"):
    parameters = locals()
    with ops.name_scope(name, values=[df, scale]):
      super(StudentTWithAbsDfSoftplusScale, self).__init__(
          df=math_ops.floor(math_ops.abs(df)),
          loc=loc,
          scale=nn.softplus(scale, name="softplus_scale"),
          validate_args=validate_args,
          allow_nan_stats=allow_nan_stats,
          name=name)
    self._parameters = parameters 
Example #25
Source File: mvn.py    From auto-alt-text-lambda-api with MIT License 6 votes vote down vote up
def __init__(self,
               mu,
               diag_stdev,
               validate_args=False,
               allow_nan_stats=True,
               name="MultivariateNormalDiagWithSoftplusStdDev"):
    parameters = locals()
    parameters.pop("self")
    with ops.name_scope(name, values=[diag_stdev]) as ns:
      super(MultivariateNormalDiagWithSoftplusStDev, self).__init__(
          mu=mu,
          diag_stdev=nn.softplus(diag_stdev),
          validate_args=validate_args,
          allow_nan_stats=allow_nan_stats,
          name=ns)
    self._parameters = parameters 
Example #26
Source File: beta.py    From auto-alt-text-lambda-api with MIT License 6 votes vote down vote up
def __init__(self,
               a,
               b,
               validate_args=False,
               allow_nan_stats=True,
               name="BetaWithSoftplusAB"):
    parameters = locals()
    parameters.pop("self")
    with ops.name_scope(name, values=[a, b]) as ns:
      super(BetaWithSoftplusAB, self).__init__(
          a=nn.softplus(a, name="softplus_a"),
          b=nn.softplus(b, name="softplus_b"),
          validate_args=validate_args,
          allow_nan_stats=allow_nan_stats,
          name=ns)
    self._parameters = parameters 
Example #27
Source File: inverse_gamma.py    From auto-alt-text-lambda-api with MIT License 6 votes vote down vote up
def __init__(self,
               alpha,
               beta,
               validate_args=False,
               allow_nan_stats=True,
               name="InverseGammaWithSoftplusAlphaBeta"):
    parameters = locals()
    parameters.pop("self")
    with ops.name_scope(name, values=[alpha, beta]) as ns:
      super(InverseGammaWithSoftplusAlphaBeta, self).__init__(
          alpha=nn.softplus(alpha, name="softplus_alpha"),
          beta=nn.softplus(beta, name="softplus_gamma"),
          validate_args=validate_args,
          allow_nan_stats=allow_nan_stats,
          name=ns)
    self._parameters = parameters 
Example #28
Source File: inverse_gamma.py    From lambda-packs with MIT License 6 votes vote down vote up
def __init__(self,
               concentration,
               rate,
               validate_args=False,
               allow_nan_stats=True,
               name="InverseGammaWithSoftplusConcentrationRate"):
    parameters = locals()
    with ops.name_scope(name, values=[concentration, rate]):
      super(InverseGammaWithSoftplusConcentrationRate, self).__init__(
          concentration=nn.softplus(concentration,
                                    name="softplus_concentration"),
          rate=nn.softplus(rate, name="softplus_rate"),
          validate_args=validate_args,
          allow_nan_stats=allow_nan_stats,
          name=name)
    self._parameters = parameters 
Example #29
Source File: gamma.py    From auto-alt-text-lambda-api with MIT License 6 votes vote down vote up
def __init__(self,
               alpha,
               beta,
               validate_args=False,
               allow_nan_stats=True,
               name="GammaWithSoftplusAlphaBeta"):
    parameters = locals()
    parameters.pop("self")
    with ops.name_scope(name, values=[alpha, beta]) as ns:
      super(GammaWithSoftplusAlphaBeta, self).__init__(
          alpha=nn.softplus(alpha, name="softplus_alpha"),
          beta=nn.softplus(beta, name="softplus_beta"),
          validate_args=validate_args,
          allow_nan_stats=allow_nan_stats,
          name=ns)
    self._parameters = parameters 
Example #30
Source File: backend.py    From lambda-packs with MIT License 5 votes vote down vote up
def softplus(x):
  """Softplus of a tensor.

  Arguments:
      x: A tensor or variable.

  Returns:
      A tensor.
  """
  return nn.softplus(x)