Skip to content

Commit

Permalink
inline leaky_relu
Browse files Browse the repository at this point in the history
  • Loading branch information
SermetPekin committed Dec 8, 2024
1 parent e1f5e7b commit d11bddb
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions include/mlp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,23 @@ THE SOFTWARE.
#include <random>
#include <iostream>


std::vector<std::shared_ptr<Value>> leaky_relu(const std::vector<std::shared_ptr<Value>>& inputs) {
inline std::vector<std::shared_ptr<Value>> leaky_relu(const std::vector<std::shared_ptr<Value>> &inputs)
{
std::vector<std::shared_ptr<Value>> outputs;
for (const auto& val : inputs) {
if (val->data > 0) {
for (const auto &val : inputs)
{
if (val->data > 0)
{
outputs.push_back(val);
} else {
outputs.push_back(std::make_shared<Value>(0.01 * val->data)); // Small negative slope
}
else
{
outputs.push_back(std::make_shared<Value>(0.01 * val->data)); // Small negative slope
}
}
return outputs;
}


// ReLU Act. Func.

inline std::vector<std::shared_ptr<Value>> relu(const std::vector<std::shared_ptr<Value>> &inputs)
Expand Down

0 comments on commit d11bddb

Please sign in to comment.