hunk.code_window:         self.mean = mean
           self.low = low
           self.high = high
           # Squash to range if specified.
           # TODO(ekl) might make sense to use a beta distribution instead:
           # http://proceedings.mlr.press/v70/chou17a/chou17a.pdf
           if low is not None:
               self.mean = low + tf.sigmoid(self.mean) * (high - low)
  
hunk.labels: keep keep keep keep replace replace replace keep keep keep
hunk.after_edit:         # Squash to range if specified. We use a sigmoid here this to avoid the
           # mean drifting too far past the bounds and causing nan outputs.
           # https://github.com/ray-project/ray/issues/1862
  
hunk.file_path: python/ray/rllib/models/action_dist.py
hunk.type: replace
file: #!python
  # cython: embedsignature=True, binding=True
  
  #  Copyright 2016 Intel Corporation
  #
  #  Licensed under the Apache License, Version 2.0 (the "License");
  #  you may not use this file except in compliance with the License.
  #  You may obtain a copy of the License at
  #
  #       http://www.apache.org/licenses/LICENSE-2.0
  #
  #  Unless required by applicable law or agreed to in writing, software
  #  distributed under the License is distributed on an "AS IS" BASIS,
  #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  #  See the License for the specific language governing permissions and
  #  limitations under the License.
  
  
  from libc.math cimport log
  
  import numpy as np
  cimport numpy as np
  
  
  def masked_log(x):
      """Compute natural logarithm while accepting nonpositive input
  
      For nonpositive elements, return -inf.
  
      Modified slightly from the original BrainIAK code to support
      Python 2.
  
      Parameters
      ----------
      x: ndarray[T]
  
      Returns
      -------
      ndarray[Union[T, np.float64]]
      """
      y = np.empty(x.shape, dtype=np.float64)
      lim = x.shape[0]
      for i in range(lim):
          if x[i] <= 0:
              y[i] = float("-inf")
          else:
              y[i] = log(x[i])
      return y
  