dataset = Labeled::quick([ [1.0, 2.5], [0.1, 0.0], [0.002, -6.0], ], ['yes', 'no', 'maybe']); $this->input = new Placeholder1D(2); $this->hidden = [ new Dense(10), new Activation(new ReLU()), new Dense(5), new Activation(new ReLU()), new Dense(3), ]; $this->output = new Multiclass(['yes', 'no', 'maybe'], new CrossEntropy()); $this->network = new FeedForward($this->input, $this->hidden, $this->output, new Adam(0.001)); } /** * @test */ public function build() : void { $this->assertInstanceOf(FeedForward::class, $this->network); $this->assertInstanceOf(Network::class, $this->network); } /** * @test */ public function layers() : void { $this->assertCount(5, iterator_to_array($this->network->layers())); } /** * @test */ public function input() : void { $this->assertInstanceOf(Placeholder1D::class, $this->network->input()); } /** * @test */ public function hidden() : void { $this->assertCount(5, $this->network->hidden()); } /** * @test */ public function output() : void { $this->assertInstanceOf(Output::class, $this->network->output()); } /** * @test */ public function numParams() : void { $this->network->initialize(); $this->assertEquals(103, $this->network->numParams()); } /** * @test */ public function roundtrip() : void { $this->network->initialize(); $loss = $this->network->roundtrip($this->dataset); $this->assertIsFloat($loss); } }