1
+ import { expect } from "chai" ;
1
2
import {
2
3
AbsoluteActivation ,
3
4
BentIdentityActivation ,
8
9
IdentityActivation ,
9
10
InverseActivation ,
10
11
LogisticActivation ,
12
+ MISHActivation ,
11
13
RELUActivation ,
12
14
SELUActivation ,
13
15
SinusoidActivation ,
@@ -16,7 +18,6 @@ import {
16
18
TanhActivation
17
19
} from "../../../src/methods/Activation" ;
18
20
import { randDouble } from "../../../src/methods/Utils" ;
19
- import { expect } from "chai" ;
20
21
21
22
describe ( "Activation" , ( ) => {
22
23
describe ( "activation.LOGISTIC()" , ( ) => {
@@ -179,4 +180,21 @@ describe("Activation", () => {
179
180
expect ( new SELUActivation ( ) . calc ( x , true ) ) . to . be . closeTo ( z , 0.01 ) ;
180
181
} ) ;
181
182
} ) ;
183
+ describe ( "activation.MISH()" , ( ) => {
184
+ it ( "activation.MISH(number, derivate=false) => {number}" , ( ) => {
185
+ const x : number = randDouble ( - 50 , 50 ) ;
186
+ const z : number = x * Math . tanh ( Math . log ( 1 + Math . exp ( x ) ) ) ;
187
+ expect ( new MISHActivation ( ) . calc ( x , false ) ) . to . be . closeTo ( z , 0.01 ) ;
188
+ } ) ;
189
+ it ( "activation.MISH(number, derivate=true) => {number}" , ( ) => {
190
+ const x : number = randDouble ( - 50 , 50 ) ;
191
+
192
+ const ex : number = Math . exp ( x ) ;
193
+ const w : number = ex * ex * ex + 4 * ( ex * ex + x * ex + x + 1 ) + 6 * ex ;
194
+ const d : number = 2 * ex + ex * ex + 2 ;
195
+ const z : number = ex * w / ( d * d ) ;
196
+
197
+ expect ( new MISHActivation ( ) . calc ( x , true ) ) . to . be . closeTo ( z , 0.01 ) ;
198
+ } ) ;
199
+ } ) ;
182
200
} ) ;
0 commit comments