MCPcopy Create free account
hub / github.com/alibaba/euler / restricted_softmax

Function restricted_softmax

tf_euler/python/convolution/dna_conv.py:72–80  ·  view source on GitHub ↗
(inputs, dim=-1, margin=0)

Source from the content-addressed store, hash-verified

70
71
72def restricted_softmax(inputs, dim=-1, margin=0):
73 input_max = tf.reduce_max(inputs, axis=dim, keepdims=True)[0]
74 input_max = tf.clip_by_value(input_max,
75 clip_value_min=0,
76 clip_value_max=tf.float32.max)
77 out = tf.exp((inputs - input_max))
78 out = out / (tf.reduce_sum(out, axis=dim, keepdims=True) +
79 tf.exp(margin - input_max))
80 return out
81
82
83class DNAConv(conv.Conv):

Callers 1

attentionMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected