first model
This commit is contained in:
@@ -49,6 +49,16 @@
|
||||
#include <neural_network/model/model.hpp>
|
||||
|
||||
#include <math/mul.hpp>
|
||||
#include <math/maximum.hpp>
|
||||
#include <neural_network/activation/activation_ReLU.hpp>
|
||||
#include <tensor/generators/linspace.hpp>
|
||||
#include <math/trigonometry/sin.hpp>
|
||||
#include <neural_network/datasets/sine_data.hpp>
|
||||
#include <neural_network/datasets/spiral_data.hpp>
|
||||
#include <neural_network/datasets/vertical_data.hpp>
|
||||
|
||||
|
||||
#include <math.h>
|
||||
|
||||
|
||||
|
||||
@@ -691,92 +701,27 @@ int main(void) {
|
||||
//benchmark_omp_min_work();
|
||||
|
||||
// Comment out benchmark_omp_min_work() when it is not needed.
|
||||
|
||||
|
||||
a[2] = 1.2;
|
||||
b[2] = 3;
|
||||
c[2] = -3;
|
||||
panic::io::print_vector(a);
|
||||
panic::io::print_vector(b);
|
||||
panic::io::print_vector(c);
|
||||
std::cout << a[100] << std::endl;
|
||||
std::cout << a.at(100) << std::endl;
|
||||
std::cout << panic::constants::pi << std::endl;
|
||||
std::cout << 1.23249238423847 << std::endl;
|
||||
|
||||
A(1,0) = 1.2;
|
||||
B(1,0) = 3;
|
||||
C(1,0) = -2;
|
||||
|
||||
panic::io::print_matrix(A);
|
||||
panic::io::print_matrix(B);
|
||||
panic::io::print_matrix(C);
|
||||
|
||||
panic::tensor::real_matrix A1(100, 100, 0.999/100);
|
||||
panic::tensor::real_matrix A2(100, 100, 100);
|
||||
|
||||
|
||||
for (panic::types::uint_t i = 0; i < 5; ++i)
|
||||
{
|
||||
std::cout << A2(0,0) << std::endl;
|
||||
A2 = panic::math::matmul(A1, A2);
|
||||
}
|
||||
|
||||
panic::tensor::real_matrix B1(25, 100, 100);
|
||||
panic::neural_network::layer_dense dense(100,10);
|
||||
std::cout << dense.forward(B1) << std::endl;
|
||||
|
||||
std::cout << "random" << std::endl;
|
||||
|
||||
for (int i = 0; i < 5; ++i)
|
||||
{
|
||||
std::cout << panic::random::uniform() << std::endl;
|
||||
}
|
||||
|
||||
std::cout << "random(min, max)" << std::endl;
|
||||
|
||||
panic::types::real_t a1 = -15;
|
||||
panic::types::real_t a2 = 15;
|
||||
|
||||
for (int i = 0; i < 5; ++i)
|
||||
{
|
||||
std::cout << panic::random::uniform(a1,a2) << std::endl;
|
||||
}
|
||||
|
||||
panic::tensor::real_vector a3(2);
|
||||
panic::random::uniform(a3);
|
||||
panic::io::print_vector(a3);
|
||||
|
||||
|
||||
panic::tensor::uint_vector a4(2);
|
||||
panic::random::uniform(a4, static_cast<panic::types::uint_t>(1), static_cast<panic::types::uint_t>(3));
|
||||
panic::io::print_vector(a4);
|
||||
|
||||
panic::tensor::real_matrix D1(3,3);
|
||||
panic::random::uniform(D1);
|
||||
panic::io::print_matrix(D1);
|
||||
|
||||
panic::tensor::real_matrix D3(3,3);
|
||||
panic::random::uniform(D3, 100.f, 200.f);
|
||||
panic::io::print_matrix(D3);
|
||||
|
||||
std::cout << "neural_network" << std::endl;
|
||||
|
||||
panic::neural_network::layer_dense layer_dense01(3,4);
|
||||
std::cout << layer_dense01.forward(D1) << std::endl;
|
||||
panic::io::print_matrix(layer_dense01.outputs);
|
||||
|
||||
panic::tensor::real_matrix X;
|
||||
panic::tensor::uint_vector y;
|
||||
|
||||
panic::types::uint_t samples = 100;
|
||||
panic::types::uint_t classes = 3;
|
||||
|
||||
panic::neural_network::spiral_data(samples, classes, X, y);
|
||||
|
||||
panic::neural_network::model mymodel;
|
||||
|
||||
mymodel.add_layer_dense(3,4);
|
||||
mymodel.forward(D1);
|
||||
|
||||
|
||||
// Create Dense layer with 2 input features and 3 output values
|
||||
mymodel.add_layer_dense(2,3);
|
||||
|
||||
mymodel.add_activation_ReLU();
|
||||
|
||||
mymodel.forward(X);
|
||||
|
||||
panic::io::print_matrix(mymodel.outputs);
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user