Last active
October 24, 2022 06:45
-
-
Save marty1885/dd648a1806348bf4cd2c2fd0feafae36 to your computer and use it in GitHub Desktop.
This file contains 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
#include <iostream> | |
#include <vector> | |
#include "tiny_dnn/tiny_dnn.h" | |
using namespace tiny_dnn; | |
using namespace tiny_dnn::activation; | |
using namespace tiny_dnn::layers; | |
int main() | |
{ | |
network<sequential> net; | |
net << fully_connected_layer(2,3) << sigmoid_layer() | |
<< fully_connected_layer(3,1) << sigmoid_layer(); | |
std::vector<vec_t> trainIn = {{0,0}, {0,1}, {1,0}, {1,1}}; | |
std::vector<vec_t> trainOut = {{0}, {1}, {1}, {0}}; | |
gradient_descent optimizer(0.53f); | |
net.fit<mse>(optimizer, trainIn, trainOut, 1, 1000); | |
net.save("net"); | |
std::cout << net.predict({1,0})[0] << std::endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good job but in this case you can also classify the output like this.
duration: 51.0456 s
result: 1
probability: 99.5675 %