cii-text-analysis/vendor/rubix/ml/benchmarks/NeuralNet/ActivationFunctions/SoftPlusBench.php
Jéremy Munsch f68d2ac333
premier poc
2026-02-11 08:24:04 +01:00

57 lines
1.1 KiB
PHP

<?php
namespace Rubix\ML\Benchmarks\NeuralNet\ActivationFunctions;
use Tensor\Matrix;
use Rubix\ML\NeuralNet\ActivationFunctions\SoftPlus;
/**
* @Groups({"ActivationFunctions"})
* @BeforeMethods({"setUp"})
*/
class SoftPlusBench
{
/**
* @var \Tensor\Matrix
*/
protected $z;
/**
* @var \Tensor\Matrix
*/
protected $computed;
/**
* @var \Rubix\ML\NeuralNet\ActivationFunctions\SoftPlus
*/
protected $activationFn;
public function setUp() : void
{
$this->z = Matrix::uniform(500, 500);
$this->computed = Matrix::uniform(500, 500);
$this->activationFn = new SoftPlus();
}
/**
* @Subject
* @Iterations(3)
* @OutputTimeUnit("milliseconds", precision=3)
*/
public function compute() : void
{
$this->activationFn->compute($this->z);
}
/**
* @Subject
* @Iterations(3)
* @OutputTimeUnit("milliseconds", precision=3)
*/
public function differentiate() : void
{
$this->activationFn->differentiate($this->z, $this->computed);
}
}