(inputs, dim=-1, margin=0)
| 70 | |
| 71 | |
| 72 | def 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 | |
| 83 | class DNAConv(conv.Conv): |