@sc-voice/tools 3.27.0 → 3.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sc-voice/tools",
3
- "version": "3.27.0",
3
+ "version": "3.28.0",
4
4
  "description": "Utilities for SC-Voice",
5
5
  "main": "index.mjs",
6
6
  "files": [
@@ -1,7 +1,7 @@
1
1
  export class Activation {
2
2
  constructor(opts = {}) {
3
3
  const msg = 'A8n.ctor';
4
- let { a, b, c, d, fEval, dEval} = opts;
4
+ let { a, b, c, d, fEval, dEval } = opts;
5
5
  if (fEval == null) {
6
6
  throw new Error(`${msg} fEval?`);
7
7
  }
@@ -10,11 +10,19 @@ export class Activation {
10
10
  throw new Error(`${msg} dEval?`);
11
11
  }
12
12
  this.dEval = dEval;
13
-
14
- if (a != null) { this.a = a; }
15
- if (b != null) { this.b = b; }
16
- if (c != null) { this.c = c; }
17
- if (d != null) { this.d = d; }
13
+
14
+ if (a != null) {
15
+ this.a = a;
16
+ }
17
+ if (b != null) {
18
+ this.b = b;
19
+ }
20
+ if (c != null) {
21
+ this.c = c;
22
+ }
23
+ if (d != null) {
24
+ this.d = d;
25
+ }
18
26
  }
19
27
 
20
28
  f(x) {
@@ -31,31 +39,36 @@ export class Activation {
31
39
  static createSoboleva(a = 1, b = 1, c = 1, d = 1) {
32
40
  const msg = 'a8n.createSoboleva';
33
41
  let fEval = (x, a, b, c, d) => {
34
- return (Math.exp(a * x) - Math.exp(-b * x)) /
42
+ return (
43
+ (Math.exp(a * x) - Math.exp(-b * x)) /
35
44
  (Math.exp(c * x) + Math.exp(-d * x))
36
- }
45
+ );
46
+ };
37
47
  let dEval = (x, a, b, c, d) => {
38
- console.log(msg, "UNTESTED");
39
- return (a*Math.exp(a * x) + b*Math.exp(-b * x)) /
40
- (Math.exp(c * x) + Math.exp(-d * x)) -
41
- fEval(x,a,b,c,d) *
42
- (c*Math.exp(c * x) - d*Math.exp(-d * x)) /
43
- (Math.exp(c * x) + Math.exp(-d * x));
44
- }
45
-
48
+ console.log(msg, 'UNTESTED');
49
+ return (
50
+ (a * Math.exp(a * x) + b * Math.exp(-b * x)) /
51
+ (Math.exp(c * x) + Math.exp(-d * x)) -
52
+ (fEval(x, a, b, c, d) *
53
+ (c * Math.exp(c * x) - d * Math.exp(-d * x))) /
54
+ (Math.exp(c * x) + Math.exp(-d * x))
55
+ );
56
+ };
57
+
46
58
  return new Activation({ a, b, c, d, fEval, dEval });
47
59
  }
48
60
 
49
- static createRareN(a=100,b=1) {
50
- let fEval = (x,a) => (x < 1 ? 1 : 1 - Math.exp(((x - a)/x) * b));
51
- let dEval = (x,a) =>
52
- (x < 1 ? 0 : - ( a * b * fEval(x,a,b)) / (x*x));
53
- return new Activation({ a, b, fEval, dEval});
61
+ static createRareN(a = 100, b = 1) {
62
+ let fEval = (x, a) =>
63
+ x < 1 ? 1 : 1 - Math.exp(((x - a) / x) * b);
64
+ let dEval = (x, a) =>
65
+ x < 1 ? 0 : -(a * b * fEval(x, a, b)) / (x * x);
66
+ return new Activation({ a, b, fEval, dEval });
54
67
  }
55
68
 
56
- static createElu(a=0) {
57
- let fEval = (x) => (x >= 0 ? x : (a * (Math.exp(x) - 1)));
58
- let dEval = (x) => "TBD";
69
+ static createElu(a = 0) {
70
+ let fEval = (x) => (x >= 0 ? x : a * (Math.exp(x) - 1));
71
+ let dEval = (x) => 'TBD';
59
72
  //let dEval = (x) => (x >= 0 ? 1 : fEval(x,a)+a);
60
73
  return new Activation({ a, fEval, dEval });
61
74
  }
@@ -65,6 +65,10 @@ export class Interval {
65
65
  return INFINITY;
66
66
  }
67
67
 
68
+ get size(){
69
+ return this.hi - this.lo;
70
+ }
71
+
68
72
  get isOpen() {
69
73
  return this.leftOpen || this.rightOpen || this.isEmpty;
70
74
  }