Skip to content

Commit ed2b091

Browse files
committed
for future reference make an activation header instead of using layer
1 parent ebe895b commit ed2b091

7 files changed

Lines changed: 55 additions & 4 deletions

File tree

include/TensorSANN/core/NeuralNetwork.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@ class NeuralNetwork{
1313

1414
virtual ~NeuralNetwork() = default;
1515

16-
void add_layer(Layer &layer){
17-
layers.push_back(layer);
18-
}
19-
16+
void add_layer(Layer &layer);
17+
2018
void set_optimzer(std::shared_ptr<Optimizer> optimzer);
2119

2220
void set_loss_func(std::shared_ptr<LossFunction> lossfunc);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#pragma once
2+
3+
#include <vector>
4+
#include "TensorSANN/optimizers/Optimizer.hpp"
5+
#include "TensorSANN/layers/Layer.hpp"
6+
7+
8+
namespace TensorSANN{
9+
10+
class SGD : Optimizer{
11+
public:
12+
SGD(float learning_rate);
13+
14+
void update(std::vector<Layer> & layers) override;
15+
16+
private:
17+
float learning_rate;
18+
};
19+
20+
}// namespace TensorSANN

src/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ add_subdirectory(activations)
44
add_subdirectory(core)
55
add_subdirectory(layers)
66
add_subdirectory(utils)
7+
add_subdirectory(optimizers)
8+
add_subdirectory(loss)
79

810
# Main executable that links all libraries
911
add_executable(tensor_sann_main main.cpp)
@@ -13,4 +15,6 @@ target_link_libraries(tensor_sann_main
1315
core
1416
layers
1517
utils
18+
optimizers
19+
loss
1620
)

src/loss/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
add_library(loss STATIC
2+
LossFunction.cpp
3+
)
4+
5+
# Include the directory for headers
6+
target_include_directories(loss PUBLIC
7+
${PROJECT_SOURCE_DIR}/include
8+
)

src/loss/LossFunction.cpp

Whitespace-only changes.

src/optimizers/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
add_library(optimizers STATIC
2+
SGD.cpp
3+
)
4+
5+
# Include the directory for headers
6+
target_include_directories(optimizers PUBLIC
7+
${PROJECT_SOURCE_DIR}/include
8+
)

src/optimizers/SGD.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include "TensorSANN/optimizers/SGD.hpp"
2+
3+
namespace TensorSANN{
4+
5+
SGD::SGD(float learning_rate) : learning_rate(learning_rate) {}
6+
7+
void SGD::update(std::vector<Layer> &layers){
8+
for (auto& layer : layers){
9+
// for (size_t i = 0; i < )
10+
}
11+
}
12+
13+
}

0 commit comments

Comments
 (0)