示例#1
0
文件: Neuron.php 项目: Harry27PL/si
 protected function randomizeWeights()
 {
     $min = $this->getNeuralNetworkLayer()->getNeuralNetwork()->getRangeMin();
     $max = $this->getNeuralNetworkLayer()->getNeuralNetwork()->getRangeMax();
     foreach ($this->weights as $k => $weight) {
         $this->weights[$k] = randFloat($min, $max);
     }
 }
示例#2
0
文件: index.php 项目: Harry27PL/si
/** @return TrainingData[] */
function prepareTrainingDatas()
{
    $result = [];
    for ($i = 0; $i <= 200; $i++) {
        $x = randFloat(0.1, 5);
        $y = randFloat(0.1, 5);
        $result[] = new TrainingData([$x, $y], [func($x, $y)]);
    }
    return $result;
}
示例#3
0
 private function randomizeRange()
 {
     $this->rangeMin = randFloat(-2, -1);
     $this->rangeMax = randFloat(1, 2);
 }
示例#4
0
 private function randomizeRange()
 {
     $this->rangeMin = randFloat(-2, -1);
     $this->rangeMax = randFloat(1, 2);
     echo '<br>range: ' . $this->rangeMin . ', ' . $this->rangeMax . '<br>';
 }
示例#5
0
    $num = $min + $range * mt_rand(0, 32767) / 32767;
    $num = round($num, 4);
    return (double) $num;
}
$client = new \InfluxDB\Client($host);
$database = $client->selectDB('test');
if ($database->exists()) {
    $database->drop();
}
$database->create(new \InfluxDB\Database\RetentionPolicy('test', '12w', 1, true));
$start = microtime(true);
$countries = ['nl', 'gb', 'us', 'be', 'th', 'jp', 'nl', 'sa'];
$colors = ['orange', 'black', 'yellow', 'white', 'red', 'purple'];
$points = [];
for ($i = 0; $i < 1000; $i++) {
    $points[] = new \InfluxDB\Point('flags', randFloat(1, 999), ['country' => $countries[array_rand($countries)]], ['color' => $colors[array_rand($colors)]], (int) shell_exec('date +%s%N') + mt_rand(1, 1000));
}
// insert the points
$database->writePoints($points);
$end = microtime(true);
$country = $countries[array_rand($countries)];
$color = $colors[array_rand($colors)];
$results = $database->query("SELECT * FROM flags WHERE country = '{$country}' LIMIT 5")->getPoints();
$results2 = $database->query("SELECT * FROM flags WHERE color = '{$color}' LIMIT 5")->getPoints();
echo "Showing top 5 flags from country {$country}:" . PHP_EOL;
print_r($results);
echo PHP_EOL;
echo "Showing top 5 flags with color {$color}:" . PHP_EOL;
print_r($results2);
echo PHP_EOL;
echo sprintf('Executed 1000 inserts in %.2f seconds', $end - $start);