Computing the scale parameter.
(x)
| 38 | |
| 39 | |
| 40 | def compute_alpha(x): |
| 41 | """Computing the scale parameter.""" |
| 42 | threshold = _compute_threshold(x) |
| 43 | alpha1_temp1 = tf.where(tf.greater(x, threshold), x, tf.zeros_like(x, tf.float32)) |
| 44 | alpha1_temp2 = tf.where(tf.less(x, -threshold), x, tf.zeros_like(x, tf.float32)) |
| 45 | alpha_array = tf.add(alpha1_temp1, alpha1_temp2, name=None) |
| 46 | alpha_array_abs = tf.abs(alpha_array) |
| 47 | alpha_array_abs1 = tf.where( |
| 48 | tf.greater(alpha_array_abs, 0), tf.ones_like(alpha_array_abs, tf.float32), |
| 49 | tf.zeros_like(alpha_array_abs, tf.float32) |
| 50 | ) |
| 51 | alpha_sum = tf.reduce_sum(input_tensor=alpha_array_abs) |
| 52 | n = tf.reduce_sum(input_tensor=alpha_array_abs1) |
| 53 | # alpha = tf.compat.v1.div(alpha_sum, n) |
| 54 | alpha = tf.math.divide(alpha_sum, n) |
| 55 | return alpha |
| 56 | |
| 57 | |
| 58 | def flatten_reshape(variable, name='flatten'): |
no test coverage detected
searching dependent graphs…