MCPcopy Index your code
hub / github.com/tensorlayer/TensorLayer / compute_alpha

Function compute_alpha

tensorlayer/layers/utils.py:40–55  ·  view source on GitHub ↗

Computing the scale parameter.

(x)

Source from the content-addressed store, hash-verified

38
39
40def 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
58def flatten_reshape(variable, name='flatten'):

Callers 2

forwardMethod · 0.90
forwardMethod · 0.90

Calls 2

_compute_thresholdFunction · 0.85
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…