-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
Lines 749 to 772 in a447591
| inline proc hardsigmoid() { | |
| const ref thisData = data; | |
| const dom = this.domain; | |
| var rl = new ndarray(dom, eltType); | |
| ref rld = rl.data; | |
| forall i in dom.every() { | |
| const x = thisData[i]; | |
| rld[i] = max(0, min(1, x/6.0 + 0.5)); | |
| } | |
| return rl; | |
| inline proc hardshrink(l: eltType=0.5) { | |
| const ref thisData = data; | |
| const dom = this.domain; | |
| var rl = new ndarray(dom, eltType); | |
| ref rld = rl.data; | |
| forall i in dom.every() { | |
| const x = thisData[i]; | |
| const float_max = Types.max(eltType); | |
| const xmap0 = ceil(1.0 / float_max * (x - l) * (x + l)); // 0 if x in [-l, l], 1 otherwise | |
| rld[i] = x * xmap0; | |
| } | |
| return rl; | |
| } |
What is hardsigmoid? @BrandynTucknott
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels