-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
52 lines (42 loc) · 1.26 KB
/
main.cpp
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <iostream>
#include "./tensor/tensor.h"
#include "./mathematical/mathematical.h"
#include "./mathematical/matrix.h"
template <typename T>
void printTensor(std::vector<T> &a){
for(auto i: a){
std::cout << i << " ";
}
std::cout << std::endl;
}
void sigmoidChecker(){
Tensor<float> w0(std::vector<float> {2});
Tensor<float> x0(std::vector<float> {-1});
Tensor<float> w1(std::vector<float> {-3});
Tensor<float> x1(std::vector<float> {-2});
Tensor<float> w3(std::vector<float> {-3});
Tensor<float> a = w0*x0;
Tensor<float> b = w1*x1;
Tensor<float> c = a+b;
Tensor<float> d = c+w3;
Tensor<float> e = Tensor<float>(std::vector<float> {-1});
Tensor<float> f = d*e;
Tensor<float> g = f.exp();
Tensor<float> h = Tensor<float>(std::vector<float> {1});
Tensor<float> i = h+g;
Tensor<float> j = Tensor<float>(std::vector<float> {1});
Tensor<float> k = j/i;
k.backward(std::vector<float> {1});
printTensor(w0.grad);
printTensor(x0.grad);
printTensor(w1.grad);
printTensor(x1.grad);
printTensor(w3.grad);
}
int main(){
Matrix<float> a({1,2,4,5,6,7}, {3,2});
Matrix<float> a2({1,2,4,5,6,7}, {2,3});
auto m3 = a.dot(a2);
std::cout<<m3<<std::endl;
return 0;
}