<?php function sigmoid($x) { $steepness = 0.00069315; return 1 / (1 + exp(-$x * $steepness)); } for ($i = 0; $i <= 10000; ++$i) { echo $i, ': ', sigmoid($i), '<br>'; }
function feedForward($input) { global $numLayers; global $layerSize; global $alpha; global $beta; global $weight; global $prevWeight; global $out; //Assign input to 0th layer foreach ($input as $key => $value) { $out[0][$key] = $value; } //Assign output for each neuron using sigmoid function for ($i = 1; $i < $numLayers; $i++) { for ($j = 0; $j < $layerSize[$i]; $j++) { $sum = 0; if ($i == 1) { $k = 0; foreach ($out[0] as $key => $value) { $sum += $value * $weight[$i][$j][$k++]; } } else { for ($k = 0; $k < $layerSize[$i - 1]; $k++) { $sum += $out[$i - 1][$k] * $weight[$i][$j][$k]; } } //Apply bias $sum += $weight[$i][$j][$layerSize[$i - 1]]; //Finally $out[$i][$j] = sigmoid($sum); } } }