チュートリアル XOR
#include <tiny_dnn/tiny_dnn.h>
#include <vector>
namespace td = tiny_dnn;
namespace tda = tiny_dnn::activation;
int main() {
td::network<td::sequential> net;
net << td::fully_connected_layer(2,3) << td::sigmoid_layer()
<< td::fully_connected_layer(3,1) << td::sigmoid_layer();
std::vector<td::vec_t> trainIn = {{0,0}, {0,1}, {1,0}, {1,1}};
std::vector<td::vec_t> trainOut = {{0}, {1}, {1}, {0}};
td::gradient_descent optimizer; //(0.53);
optimizer.alpha = 0.53f;
net.fit<td::mse>(optimizer, trainIn, trainOut, 1, 1000);
net.save("net");
std::cout << net.predict({0,0})[0] << std::endl;
std::cout << net.predict({0,1})[0] << std::endl;
std::cout << net.predict({1,0})[0] << std::endl;
std::cout << net.predict({1,1})[0] << std::endl;
return 0;
}
出力
0.0411867
0.956243
0.959534
0.037655
0 件のコメント:
コメントを投稿