This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class Test{ | |
| public function __call($name, $arguments) | |
| { | |
| var_dump($name); | |
| var_dump($arguments); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function test1($n){ | |
| $n++; | |
| } | |
| function test2(&$n){ | |
| $n++; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| require_once "vendor/autoload.php"; | |
| $myData = new CpChart\Data(); | |
| $myData->addPoints(array(VOID,3,4,3,5)); | |
| $myPicture = new CpChart\Image(700,230,$myData); | |
| $myPicture->setGraphArea(60,40,670,190); | |
| $myPicture->drawScale(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $image = file_get_contents("train-images.idx3-ubyte"); | |
| for($k = 0; $k < 28; $k++){ | |
| $cut_image = substr($image, (16+$k*28), 28); | |
| for($i = 0; $i < strlen($cut_image); $i++) { | |
| $value = (int)(ord($cut_image[$i])); | |
| echo $value === 0 ? "0" : "1"; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class Matrix{ | |
| private $lineArray = array(); | |
| /** | |
| * Matrix constructor. | |
| * @param array $lineArray [[1,2],[3,4]] | |
| * (1,2) | |
| * (3,4) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $y = [0.1,0.05,0.6,0.0,0.05,0.1,0.0,0.1,0.0,0.0]; | |
| $t = [0,0,1,0,0,0,0,0,0,0]; | |
| var_dump(meanSquaredError($y, $t)); | |
| /** | |
| * @param array $y | |
| * @param array $t |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * @param $f function | |
| * @param $x | |
| */ | |
| function numerical_diff($f, $x){ | |
| $h = 1e-4; | |
| return (($f($x + $h) - $f($x - $h))/(2*$h)); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| require_once "numerical_diff.php"; | |
| /** | |
| * 2変数を前提 | |
| */ | |
| function numerical_gradient($f, $x, $y){ | |
| $grad = array(); | |
| $h = 1e-4; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $f = function($x, $y){ | |
| return pow($x, 2) + pow($y, 2); | |
| }; | |
| function numerical_gradient($f, $x, $y){ | |
| $h = 1e-4; | |
| //x | |
| $x_ = ($f($x + $h, $y) - $f($x - $h, $y))/(2*$h); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'matrix' | |
| m = Matrix[[1, 2], [3, 4]] | |
| n = Matrix[[5, 6], [7, 8]] | |
| puts m * n | |