Skip to content

Commit 0a92a40

Browse files
committed
Initial commit
1 parent 29d9955 commit 0a92a40

51 files changed

Lines changed: 212 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/NeuralNet/ActivationFunctions/ELU.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use NumPower;
88
use NDArray;
99
use Rubix\ML\Exceptions\InvalidAlphaException;
10+
use Rubix\ML\Specifications\ExtensionIsLoaded;
1011

1112
/**
1213
* ELU
@@ -41,6 +42,8 @@ public function __construct(protected float $alpha = 1.0)
4142
message: "Alpha must be greater than 0, {$this->alpha} given."
4243
);
4344
}
45+
46+
ExtensionIsLoaded::with('RubixNumPower')->check();
4447
}
4548

4649
/**

src/NeuralNet/ActivationFunctions/GELU.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use NumPower;
88
use NDArray;
9+
use Rubix\ML\Specifications\ExtensionIsLoaded;
910

1011
/**
1112
* GeLU
@@ -49,6 +50,11 @@ class GELU implements ActivationFunction, IBufferDerivative
4950
*/
5051
protected const TRIPLE_BETA = 0.134145;
5152

53+
public function __construct()
54+
{
55+
ExtensionIsLoaded::with('RubixNumPower')->check();
56+
}
57+
5258
/**
5359
* Apply the GeLU activation function to the input.
5460
*

src/NeuralNet/ActivationFunctions/HardSiLU.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use NumPower;
88
use NDArray;
9+
use Rubix\ML\Specifications\ExtensionIsLoaded;
910

1011
/**
1112
* HardSiLU
@@ -35,6 +36,8 @@ class HardSiLU implements ActivationFunction, IBufferDerivative
3536
*/
3637
public function __construct()
3738
{
39+
ExtensionIsLoaded::with('RubixNumPower')->check();
40+
3841
$this->hardSigmoid = new HardSigmoid();
3942
}
4043

src/NeuralNet/ActivationFunctions/HardSigmoid.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use NumPower;
88
use NDArray;
9+
use Rubix\ML\Specifications\ExtensionIsLoaded;
910

1011
/**
1112
* HardSigmoid
@@ -51,6 +52,11 @@ class HardSigmoid implements ActivationFunction, IBufferDerivative
5152
*/
5253
protected const UPPER_BOUND = 2.5;
5354

55+
public function __construct()
56+
{
57+
ExtensionIsLoaded::with('RubixNumPower')->check();
58+
}
59+
5460
/**
5561
* Apply the HardSigmoid activation function to the input.
5662
*

src/NeuralNet/ActivationFunctions/HyperbolicTangent.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use NumPower;
88
use NDArray;
9+
use Rubix\ML\Specifications\ExtensionIsLoaded;
910

1011
/**
1112
* Hyperbolic Tangent
@@ -20,6 +21,11 @@
2021
*/
2122
class HyperbolicTangent implements ActivationFunction, OBufferDerivative
2223
{
24+
public function __construct()
25+
{
26+
ExtensionIsLoaded::with('RubixNumPower')->check();
27+
}
28+
2329
/**
2430
* Apply the Hyperbolic Tangent activation function to the input.
2531
*

src/NeuralNet/ActivationFunctions/LeakyReLU.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use NumPower;
88
use NDArray;
99
use Rubix\ML\Exceptions\InvalidLeakageException;
10+
use Rubix\ML\Specifications\ExtensionIsLoaded;
1011

1112
/**
1213
* Leaky ReLU
@@ -48,6 +49,8 @@ public function __construct(float $leakage = 0.1)
4849
}
4950

5051
$this->leakage = $leakage;
52+
53+
ExtensionIsLoaded::with('RubixNumPower')->check();
5154
}
5255

5356
/**

src/NeuralNet/ActivationFunctions/ReLU.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use NumPower;
88
use NDArray;
9+
use Rubix\ML\Specifications\ExtensionIsLoaded;
910

1011
/**
1112
* ReLU
@@ -24,6 +25,11 @@
2425
*/
2526
class ReLU implements ActivationFunction, IBufferDerivative
2627
{
28+
public function __construct()
29+
{
30+
ExtensionIsLoaded::with('RubixNumPower')->check();
31+
}
32+
2733
/**
2834
* Compute the activation.
2935
*

src/NeuralNet/ActivationFunctions/ReLU6.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use NumPower;
88
use NDArray;
9+
use Rubix\ML\Specifications\ExtensionIsLoaded;
910

1011
/**
1112
* ReLU6
@@ -25,6 +26,11 @@
2526
*/
2627
class ReLU6 implements ActivationFunction, IBufferDerivative
2728
{
29+
public function __construct()
30+
{
31+
ExtensionIsLoaded::with('RubixNumPower')->check();
32+
}
33+
2834
/**
2935
* Compute the activation.
3036
*

src/NeuralNet/ActivationFunctions/SELU.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use NumPower;
88
use NDArray;
9+
use Rubix\ML\Specifications\ExtensionIsLoaded;
910

1011
/**
1112
* SELU
@@ -46,6 +47,11 @@ class SELU implements ActivationFunction, IBufferDerivative
4647
*/
4748
protected const BETA = self::LAMBDA * self::ALPHA;
4849

50+
public function __construct()
51+
{
52+
ExtensionIsLoaded::with('RubixNumPower')->check();
53+
}
54+
4955
/**
5056
* Compute the activation.
5157
*

src/NeuralNet/ActivationFunctions/SiLU.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use NumPower;
88
use NDArray;
9+
use Rubix\ML\Specifications\ExtensionIsLoaded;
910

1011
/**
1112
* SiLU
@@ -36,6 +37,8 @@ class SiLU implements ActivationFunction, IBufferDerivative
3637
*/
3738
public function __construct()
3839
{
40+
ExtensionIsLoaded::with('RubixNumPower')->check();
41+
3942
$this->sigmoid = new Sigmoid();
4043
}
4144

0 commit comments

Comments
 (0)