@dniskav/neuron 0.1.5 → 0.1.6

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/dist/index.d.mts CHANGED
@@ -14,6 +14,12 @@ declare const sigmoid: Activation;
14
14
  declare const tanh: Activation;
15
15
  declare const relu: Activation;
16
16
  declare const linear: Activation;
17
+ declare function makeLeakyRelu(alpha?: number): Activation;
18
+ /** Leaky ReLU with the standard α = 0.01. */
19
+ declare const leakyRelu: Activation;
20
+ declare function makeElu(alpha?: number): Activation;
21
+ /** ELU with the standard α = 1.0. */
22
+ declare const elu: Activation;
17
23
 
18
24
  interface Optimizer {
19
25
  step(weight: number, gradient: number, lr: number): number;
@@ -165,4 +171,4 @@ declare function mseDelta(predicted: number, actual: number): number;
165
171
  declare function crossEntropyDelta(predicted: number, actual: number): number;
166
172
  declare function crossEntropyDeltaRaw(predicted: number, actual: number): number;
167
173
 
168
- export { type Activation, Adam, LSTMLayer, Layer, Momentum, Network, NetworkLSTM, type NetworkLSTMOptions, NetworkN, type NetworkNOptions, Neuron, NeuronN, type Optimizer, type OptimizerFactory, SGD, crossEntropy, crossEntropyDelta, crossEntropyDeltaRaw, linear, mse, mseDelta, relu, sigmoid, tanh };
174
+ export { type Activation, Adam, LSTMLayer, Layer, Momentum, Network, NetworkLSTM, type NetworkLSTMOptions, NetworkN, type NetworkNOptions, Neuron, NeuronN, type Optimizer, type OptimizerFactory, SGD, crossEntropy, crossEntropyDelta, crossEntropyDeltaRaw, elu, leakyRelu, linear, makeElu, makeLeakyRelu, mse, mseDelta, relu, sigmoid, tanh };
package/dist/index.d.ts CHANGED
@@ -14,6 +14,12 @@ declare const sigmoid: Activation;
14
14
  declare const tanh: Activation;
15
15
  declare const relu: Activation;
16
16
  declare const linear: Activation;
17
+ declare function makeLeakyRelu(alpha?: number): Activation;
18
+ /** Leaky ReLU with the standard α = 0.01. */
19
+ declare const leakyRelu: Activation;
20
+ declare function makeElu(alpha?: number): Activation;
21
+ /** ELU with the standard α = 1.0. */
22
+ declare const elu: Activation;
17
23
 
18
24
  interface Optimizer {
19
25
  step(weight: number, gradient: number, lr: number): number;
@@ -165,4 +171,4 @@ declare function mseDelta(predicted: number, actual: number): number;
165
171
  declare function crossEntropyDelta(predicted: number, actual: number): number;
166
172
  declare function crossEntropyDeltaRaw(predicted: number, actual: number): number;
167
173
 
168
- export { type Activation, Adam, LSTMLayer, Layer, Momentum, Network, NetworkLSTM, type NetworkLSTMOptions, NetworkN, type NetworkNOptions, Neuron, NeuronN, type Optimizer, type OptimizerFactory, SGD, crossEntropy, crossEntropyDelta, crossEntropyDeltaRaw, linear, mse, mseDelta, relu, sigmoid, tanh };
174
+ export { type Activation, Adam, LSTMLayer, Layer, Momentum, Network, NetworkLSTM, type NetworkLSTMOptions, NetworkN, type NetworkNOptions, Neuron, NeuronN, type Optimizer, type OptimizerFactory, SGD, crossEntropy, crossEntropyDelta, crossEntropyDeltaRaw, elu, leakyRelu, linear, makeElu, makeLeakyRelu, mse, mseDelta, relu, sigmoid, tanh };
package/dist/index.js CHANGED
@@ -33,7 +33,11 @@ __export(index_exports, {
33
33
  crossEntropy: () => crossEntropy,
34
34
  crossEntropyDelta: () => crossEntropyDelta,
35
35
  crossEntropyDeltaRaw: () => crossEntropyDeltaRaw,
36
+ elu: () => elu,
37
+ leakyRelu: () => leakyRelu,
36
38
  linear: () => linear,
39
+ makeElu: () => makeElu,
40
+ makeLeakyRelu: () => makeLeakyRelu,
37
41
  mse: () => mse,
38
42
  mseDelta: () => mseDelta,
39
43
  relu: () => relu,
@@ -82,6 +86,20 @@ var linear = {
82
86
  fn: (x) => x,
83
87
  dfn: () => 1
84
88
  };
89
+ function makeLeakyRelu(alpha = 0.01) {
90
+ return {
91
+ fn: (x) => x > 0 ? x : alpha * x,
92
+ dfn: (out) => out > 0 ? 1 : alpha
93
+ };
94
+ }
95
+ var leakyRelu = makeLeakyRelu(0.01);
96
+ function makeElu(alpha = 1) {
97
+ return {
98
+ fn: (x) => x > 0 ? x : alpha * (Math.exp(x) - 1),
99
+ dfn: (out) => out > 0 ? 1 : out + alpha
100
+ };
101
+ }
102
+ var elu = makeElu(1);
85
103
 
86
104
  // src/optimizers.ts
87
105
  var SGD = class {
@@ -542,7 +560,11 @@ function crossEntropyDeltaRaw(predicted, actual) {
542
560
  crossEntropy,
543
561
  crossEntropyDelta,
544
562
  crossEntropyDeltaRaw,
563
+ elu,
564
+ leakyRelu,
545
565
  linear,
566
+ makeElu,
567
+ makeLeakyRelu,
546
568
  mse,
547
569
  mseDelta,
548
570
  relu,
package/dist/index.mjs CHANGED
@@ -38,6 +38,20 @@ var linear = {
38
38
  fn: (x) => x,
39
39
  dfn: () => 1
40
40
  };
41
+ function makeLeakyRelu(alpha = 0.01) {
42
+ return {
43
+ fn: (x) => x > 0 ? x : alpha * x,
44
+ dfn: (out) => out > 0 ? 1 : alpha
45
+ };
46
+ }
47
+ var leakyRelu = makeLeakyRelu(0.01);
48
+ function makeElu(alpha = 1) {
49
+ return {
50
+ fn: (x) => x > 0 ? x : alpha * (Math.exp(x) - 1),
51
+ dfn: (out) => out > 0 ? 1 : out + alpha
52
+ };
53
+ }
54
+ var elu = makeElu(1);
41
55
 
42
56
  // src/optimizers.ts
43
57
  var SGD = class {
@@ -497,7 +511,11 @@ export {
497
511
  crossEntropy,
498
512
  crossEntropyDelta,
499
513
  crossEntropyDeltaRaw,
514
+ elu,
515
+ leakyRelu,
500
516
  linear,
517
+ makeElu,
518
+ makeLeakyRelu,
501
519
  mse,
502
520
  mseDelta,
503
521
  relu,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dniskav/neuron",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Minimal neural network from scratch — neuron, layer, network, backpropagation. No dependencies.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",