Skip to content

Commit

Permalink
Fixed negative cases for neural network diff creation
Browse files Browse the repository at this point in the history
  • Loading branch information
FuexFollets committed Feb 10, 2024
1 parent 0dffd4d commit 1351182
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/lexocraft/neural_network/neural_network_diff.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
#include <algorithm>
#include <vector>

#include <Eigen/Eigen>
#include <icecream.hpp>

#include <lexocraft/neural_network/neural_network.hpp>
#include <vector>

namespace lc {
// Give each random float values between -1 and 1.
NeuralNetwork::NeuralNetworkDiff::NeuralNetworkDiff(
const std::vector<std::size_t>& layer_sizes) :
weight_diffs(layer_sizes.size() - 1),
bias_diffs(layer_sizes.size() - 1), layer_sizes(layer_sizes) {

weight_diffs(std::max(std::size_t {0}, layer_sizes.size() - 1)),
bias_diffs(std::max(std::size_t {0}, layer_sizes.size() - 1)), layer_sizes {layer_sizes} {
for (std::size_t index {0}; index < layer_sizes.size() - 1; index++) {
weight_diffs [index] =
Eigen::MatrixXf::Random(layer_sizes [index + 1], layer_sizes [index]);
Expand Down

0 comments on commit 1351182

Please sign in to comment.