Esempio n. 1
0
def logaddexp2(x1, x2):
    amax = maximum(x1, x2)
    delta = x1 - x2
    return np_array_ops.where(
        isnan(delta),
        x1 + x2,  # NaNs or infinities of the same sign.
        amax + log1p(exp2(-abs(delta))) / np.log(2))
Esempio n. 2
0
 def nan_reduction(a, axis=None, dtype=None, keepdims=False):
     a = np_array_ops.array(a)
     v = np_array_ops.array(init_val, dtype=a.dtype)
     return reduction(np_array_ops.where(isnan(a), v, a),
                      axis=axis,
                      dtype=dtype,
                      keepdims=keepdims)
Esempio n. 3
0
 def testWhere(self):
   self.assertAllEqual([[1.0, 1.0], [1.0, 1.0]],
                       np_array_ops.where([True], [1.0, 1.0],
                                          [[0, 0], [0, 0]]))