-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
67 lines (48 loc) · 1.87 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "ActivationFuncFactory.h"
#include "Sigmoid.h"
#include "ReLU.h"
#include "Tanh.h"
#include <iostream>
#include "MasterActivationFunction.h"
// Register activation functions
void registerActivationFunctions() {
auto& factory = ActivationFunctionFactory::getInstance();
factory.registerFunction("Sigmoid", []() { return std::make_unique<Sigmoid>(); });
factory.registerFunction("ReLU", []() { return std::make_unique<ReLU>(); });
factory.registerFunction("Tanh", []() { return std::make_unique<Tanh>(); });
}
int main() {
registerActivationFunctions();
auto& factory = ActivationFunctionFactory::getInstance();
try {
auto sigmoid = factory.create("Sigmoid");
auto relu = factory.create("ReLU");
double input = -100;
std::cout << sigmoid->name() << " activation: " << sigmoid->compute(input) << '\n';
std::cout << relu->name() << " activation: " << relu->compute(input) << '\n';
LeakyReLU* leakyRelu = new LeakyReLU();
leakyRelu->setalpha(0.1);
std::cout << leakyRelu->name() << " activation: " << leakyRelu->compute(input) << '\n';
delete leakyRelu;
Swish* swishaf = new Swish();
swishaf->setbeta(2);
std::cout << swishaf->name() << " activation: " << swishaf->compute(input) << '\n';
delete swishaf;
Softplus* softplus = new Softplus();
std::cout << softplus->name() << "activation " << softplus->compute(input) << '\n';
delete softplus;
}
catch (const std::exception& e) {
std::cerr << e.what() << '\n';
}
return 0;
}
#pragma region Question
/*
What is the use of "->" Operator ?
-- access members of an object through a pointer.
-- shorthand for dereferencing a pointer
-- When you have a pointer to an object,
-- you cannot directly use the . operator to access its members.
*/
#pragma endregion