-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.php
More file actions
31 lines (24 loc) · 698 Bytes
/
demo.php
File metadata and controls
31 lines (24 loc) · 698 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
use SimpleNN\Activation;
use SimpleNN\Layer;
require_once "vendor/autoload.php";
// Input data
$X = [
[1, 2, 3, 2.5],
[2, 5, -1, 2],
[-1.5, 2.7, 3.3, -0.8],
];
// Initialize pseudo-random generator, for testing
srand(0);
// Define layers and activation functions
$layer1 = new Layer(4, 5);
$layer2 = new Layer(5, 2);
$activation1 = new Activation\ReLU();
$activation2 = new Activation\ReLU(); // todo SoftPlus
// Forward network
$layer1->forward($X);
$activation1->forward($layer1->getOutput());
$layer2->forward($activation1->getOutput());
$activation2->forward($layer2->getOutput());
// display output of network
\SimpleNN\Tools\Matrix::print($activation2->getOutput());