Skip to content

Commit 76f7d3b

Browse files
raimannmachristianechevarria
authored andcommitted
implementing test for MISH Activation
1 parent 3567044 commit 76f7d3b

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

test/units/methods/ActivationTest.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {expect} from "chai";
12
import {
23
AbsoluteActivation,
34
BentIdentityActivation,
@@ -8,6 +9,7 @@ import {
89
IdentityActivation,
910
InverseActivation,
1011
LogisticActivation,
12+
MISHActivation,
1113
RELUActivation,
1214
SELUActivation,
1315
SinusoidActivation,
@@ -16,7 +18,6 @@ import {
1618
TanhActivation
1719
} from "../../../src/methods/Activation";
1820
import {randDouble} from "../../../src/methods/Utils";
19-
import {expect} from "chai";
2021

2122
describe("Activation", () => {
2223
describe("activation.LOGISTIC()", () => {
@@ -179,4 +180,21 @@ describe("Activation", () => {
179180
expect(new SELUActivation().calc(x, true)).to.be.closeTo(z, 0.01);
180181
});
181182
});
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+
});
182200
});

0 commit comments

Comments
 (0)