export { Info };

import * as ValueDesc from "../ValueDesc.js";
import * as FloatValue from "../FloatValue.js";
import * as Weights from "../Weights.js";


/**
 *
 * @member {number} nActivationId
 *   The activation function id (ValueDesc.ActivationFunction.Singleton.Ids.Xxx).
 *
 * @member {FloatValue.Bounds} inputDomainLinear
 *   The input value lower and upper bounds of the activation function for keeping the mapping from input to output almost linear. In
 * general, an activation function is non-linear in the whole domain. However, inside this special part of the domain, it looks almost
 * like a linear function.
 *
 * @member {FloatValue.Bounds} outputRange
 *   The the activation function output value's bounds.
 *
 * @member {Function} pfn
 *   The activation function. (e.g. tf.relu6, tf.sigmoid, tf.tanh, tf.cos, tf.sin, tf.relu)
 */
class Info {

  /**
   */
  constructor( nActivationId, inputDomainLinear, outputRange, pfn ) {
    this.nActivationId = nActivationId;
    this.inputDomainLinear = inputDomainLinear;
    this.outputRange = outputRange;
    this.pfn = pfn;
  }

}


/**
 * Predefined linear domain for every activation function.
 *
 *
 * For example,
 *   - RELU6 is linear between[ 0, 6 ].
 *   - SIGMOID is alomost linear between[ -0.125, +0.125 ].
 *   - TANH is almost linear between[ -0.125, +0.125 ].
 *   - COS is almost linear between[ -( ( PI / 2 ) + 0.025 ), -( ( PI / 2 ) - 0.025 ) ].
 *   - SIN is almost linear between[ -0.025, +0.025 ].
 *   - RELU is linear between[ 0, 6 ].
 *
 */
Base.PredefinedById = new Map( [
  [ ValueDesc.ActivationFunction.Singleton.Ids.RELU6,   new FloatValue.Bounds(                            0,                            6 ) ],
  [ ValueDesc.ActivationFunction.Singleton.Ids.SIGMOID, new FloatValue.Bounds(                       -0.125,                       +0.125 ) ],
  [ ValueDesc.ActivationFunction.Singleton.Ids.TANH,    new FloatValue.Bounds(                       -0.125,                       +0.125 ) ],
  [ ValueDesc.ActivationFunction.Singleton.Ids.COS,     new FloatValue.Bounds( -( ( Math.PI / 2 ) + 0.025 ), -( ( Math.PI / 2 ) - 0.025 ) ) ],
  [ ValueDesc.ActivationFunction.Singleton.Ids.SIN,     new FloatValue.Bounds(                       -0.025,                       +0.025 ) ],
  [ ValueDesc.ActivationFunction.Singleton.Ids.RELU,    new Base(                            0,                            6 ) ],
] );

@@ -11,16 +11,19 @@
 nfo %7D;%0A%0A
+// 
 import *
@@ -56,24 +56,27 @@
 ueDesc.js%22;%0A
+// 
 import * as 
@@ -111,16 +111,19 @@
 ue.js%22;%0A
+// 
 import *
@@ -280,24 +280,145 @@
 ds.Xxx).%0A *%0A
+ * @member %7BFunction%7D pfn%0A *   The activation function. (e.g. tf.relu6, tf.sigmoid, tf.tanh, tf.cos, tf.sin, tf.relu)%0A *%0A
  * @member %7B
@@ -598,16 +598,25 @@
  general
+ speaking
 , an act
@@ -728,18 +728,18 @@
 ooks
+%0A *
  almost
-%0A *
  lik
@@ -865,129 +865,8 @@
 ds.%0A
- *%0A * @member %7BFunction%7D pfn%0A *   The activation function. (e.g. tf.relu6, tf.sigmoid, tf.tanh, tf.cos, tf.sin, tf.relu)%0A
  */%0A
@@ -920,16 +920,21 @@
 ationId,
+ pfn,
  inputDo
@@ -956,21 +956,16 @@
 putRange
-, pfn
  ) %7B%0A   
@@ -1001,16 +1001,36 @@
 tionId;%0A
+    this.pfn = pfn;%0A
     this
@@ -1111,39 +1111,52 @@
 ;%0A  
-  this.pfn = pfn;%0A  %7D%0A%0A%7D%0A%0A%0A/**%0A
+%7D%0A%0A%7D%0A%0A//!!! (2021/12/09 Remarked)%0A// /**%0A// 
  * P
@@ -1214,14 +1214,23 @@
 on.%0A
- *%0A *%0A
+//  *%0A//  *%0A// 
  * F
@@ -1241,16 +1241,19 @@
 xample,%0A
+// 
  *   - R
@@ -1280,24 +1280,27 @@
 en%5B 0, 6 %5D.%0A
+// 
  *   - SIGMO
@@ -1343,24 +1343,27 @@
 , +0.125 %5D.%0A
+// 
  *   - TANH 
@@ -1402,24 +1402,27 @@
 , +0.125 %5D.%0A
+// 
  *   - COS i
@@ -1494,24 +1494,27 @@
  0.025 ) %5D.%0A
+// 
  *   - SIN i
@@ -1556,16 +1556,19 @@
 .025 %5D.%0A
+// 
  *   - R
@@ -1602,15 +1602,24 @@
  %5D.%0A
- *%0A
+//  *%0A// 
  */%0A
+// 
 Base
@@ -1647,16 +1647,19 @@
  Map( %5B%0A
+// 
   %5B Valu
@@ -1789,26 +1789,29 @@
      6 ) %5D,%0A
+//
   
+ 
 %5B ValueDesc.
@@ -1931,34 +1931,37 @@
     +0.125 ) %5D,%0A
+//
   
+ 
 %5B ValueDesc.Acti
@@ -2077,32 +2077,35 @@
     +0.125 ) %5D,%0A
+// 
   %5B ValueDesc.Ac
@@ -2227,24 +2227,27 @@
 .025 ) ) %5D,%0A
+// 
   %5B ValueDes
@@ -2377,16 +2377,19 @@
 25 ) %5D,%0A
+// 
   %5B Valu
@@ -2510,13 +2510,16 @@
  6 ) %5D,%0A
+// 
 %5D );%0A

Update ActivationFunction.js