diff --git a/mlpp/activation/activation.cpp b/mlpp/activation/activation.cpp index 0f4a634..09d2752 100644 --- a/mlpp/activation/activation.cpp +++ b/mlpp/activation/activation.cpp @@ -2891,10 +2891,10 @@ std::vector MLPPActivation::softmax(std::vector z, bool deriv) { std::vector expZ = alg.exp(z); real_t sum = 0; - for (int i = 0; i < z.size(); i++) { + for (uint32_t i = 0; i < z.size(); i++) { sum += expZ[i]; } - for (int i = 0; i < z.size(); i++) { + for (uint32_t i = 0; i < z.size(); i++) { a[i] = expZ[i] / sum; } return a; @@ -2905,7 +2905,7 @@ std::vector> MLPPActivation::softmax(std::vector> a; a.resize(z.size()); - for (int i = 0; i < z.size(); i++) { + for (uint32_t i = 0; i < z.size(); i++) { a[i] = softmax(z[i]); } return a; @@ -2925,7 +2925,7 @@ std::vector> MLPPActivation::adjSoftmax(std::vector> a; a.resize(z.size()); - for (int i = 0; i < z.size(); i++) { + for (uint32_t i = 0; i < z.size(); i++) { a[i] = adjSoftmax(z[i]); } return a; @@ -2939,8 +2939,8 @@ std::vector> MLPPActivation::softmaxDeriv(std::vector>> MLPPActivation::softmaxDeriv(std:: std::vector> a = softmax(z); deriv.resize(a.size()); - for (int i = 0; i < deriv.size(); i++) { + for (uint32_t i = 0; i < deriv.size(); i++) { deriv[i].resize(a.size()); } - for (int i = 0; i < a.size(); i++) { - for (int j = 0; j < z.size(); j++) { + for (uint32_t i = 0; i < a.size(); i++) { + for (uint32_t j = 0; j < z.size(); j++) { if (i == j) { deriv[i][j] = alg.subtraction(a[i], alg.hadamard_product(a[i], a[i])); } else { @@ -3098,7 +3098,7 @@ std::vector MLPPActivation::unitStep(std::vector z, bool deriv) if (deriv) { std::vector deriv; deriv.resize(z.size()); - for (int i = 0; i < z.size(); i++) { + for (uint32_t i = 0; i < z.size(); i++) { deriv[i] = unitStep(z[i], true); } return deriv; @@ -3106,7 +3106,7 @@ std::vector MLPPActivation::unitStep(std::vector z, bool deriv) std::vector a; a.resize(z.size()); - for (int i = 0; i < a.size(); i++) { + for (uint32_t i = 0; i < a.size(); i++) { a[i] = unitStep(z[i]); } return a; @@ -3116,7 +3116,7 @@ std::vector> MLPPActivation::unitStep(std::vector> deriv; deriv.resize(z.size()); - for (int i = 0; i < z.size(); i++) { + for (uint32_t i = 0; i < z.size(); i++) { deriv[i] = unitStep(z[i], true); } return deriv; @@ -3124,7 +3124,7 @@ std::vector> MLPPActivation::unitStep(std::vector> a; a.resize(z.size()); - for (int i = 0; i < a.size(); i++) { + for (uint32_t i = 0; i < a.size(); i++) { a[i] = unitStep(z[i]); } return a; @@ -3214,7 +3214,7 @@ std::vector MLPPActivation::RELU(std::vector z, bool deriv) { if (deriv) { std::vector deriv; deriv.resize(z.size()); - for (int i = 0; i < z.size(); i++) { + for (uint32_t i = 0; i < z.size(); i++) { deriv[i] = RELU(z[i], true); } return deriv; @@ -3222,7 +3222,7 @@ std::vector MLPPActivation::RELU(std::vector z, bool deriv) { std::vector a; a.resize(z.size()); - for (int i = 0; i < a.size(); i++) { + for (uint32_t i = 0; i < a.size(); i++) { a[i] = RELU(z[i]); } return a; @@ -3232,7 +3232,7 @@ std::vector> MLPPActivation::RELU(std::vector> deriv; deriv.resize(z.size()); - for (int i = 0; i < z.size(); i++) { + for (uint32_t i = 0; i < z.size(); i++) { deriv[i] = RELU(z[i], true); } return deriv; @@ -3240,7 +3240,7 @@ std::vector> MLPPActivation::RELU(std::vector> a; a.resize(z.size()); - for (int i = 0; i < a.size(); i++) { + for (uint32_t i = 0; i < a.size(); i++) { a[i] = RELU(z[i]); } return a; @@ -3261,7 +3261,7 @@ std::vector MLPPActivation::leakyReLU(std::vector z, real_t c, b if (deriv) { std::vector deriv; deriv.resize(z.size()); - for (int i = 0; i < z.size(); i++) { + for (uint32_t i = 0; i < z.size(); i++) { deriv[i] = leakyReLU(z[i], c, true); } return deriv; @@ -3269,7 +3269,7 @@ std::vector MLPPActivation::leakyReLU(std::vector z, real_t c, b std::vector a; a.resize(z.size()); - for (int i = 0; i < a.size(); i++) { + for (uint32_t i = 0; i < a.size(); i++) { a[i] = leakyReLU(z[i], c); } return a; @@ -3279,7 +3279,7 @@ std::vector> MLPPActivation::leakyReLU(std::vector> deriv; deriv.resize(z.size()); - for (int i = 0; i < z.size(); i++) { + for (uint32_t i = 0; i < z.size(); i++) { deriv[i] = leakyReLU(z[i], c, true); } return deriv; @@ -3287,7 +3287,7 @@ std::vector> MLPPActivation::leakyReLU(std::vector> a; a.resize(z.size()); - for (int i = 0; i < a.size(); i++) { + for (uint32_t i = 0; i < a.size(); i++) { a[i] = leakyReLU(z[i], c); } return a; @@ -3312,7 +3312,7 @@ std::vector MLPPActivation::ELU(std::vector z, real_t c, bool de if (deriv) { std::vector deriv; deriv.resize(z.size()); - for (int i = 0; i < z.size(); i++) { + for (uint32_t i = 0; i < z.size(); i++) { deriv[i] = ELU(z[i], c, true); } return deriv; @@ -3320,7 +3320,7 @@ std::vector MLPPActivation::ELU(std::vector z, real_t c, bool de std::vector a; a.resize(z.size()); - for (int i = 0; i < a.size(); i++) { + for (uint32_t i = 0; i < a.size(); i++) { a[i] = ELU(z[i], c); } return a; @@ -3330,7 +3330,7 @@ std::vector> MLPPActivation::ELU(std::vector> deriv; deriv.resize(z.size()); - for (int i = 0; i < z.size(); i++) { + for (uint32_t i = 0; i < z.size(); i++) { deriv[i] = ELU(z[i], c, true); } return deriv; @@ -3338,7 +3338,7 @@ std::vector> MLPPActivation::ELU(std::vector> a; a.resize(z.size()); - for (int i = 0; i < a.size(); i++) { + for (uint32_t i = 0; i < a.size(); i++) { a[i] = ELU(z[i], c); } return a; @@ -3355,7 +3355,7 @@ std::vector MLPPActivation::SELU(std::vector z, real_t lambda, r if (deriv) { std::vector deriv; deriv.resize(z.size()); - for (int i = 0; i < z.size(); i++) { + for (uint32_t i = 0; i < z.size(); i++) { deriv[i] = SELU(z[i], lambda, c, true); } return deriv; @@ -3363,7 +3363,7 @@ std::vector MLPPActivation::SELU(std::vector z, real_t lambda, r std::vector a; a.resize(z.size()); - for (int i = 0; i < a.size(); i++) { + for (uint32_t i = 0; i < a.size(); i++) { a[i] = SELU(z[i], lambda, c); } return a; @@ -3373,7 +3373,7 @@ std::vector> MLPPActivation::SELU(std::vector> deriv; deriv.resize(z.size()); - for (int i = 0; i < z.size(); i++) { + for (uint32_t i = 0; i < z.size(); i++) { deriv[i] = SELU(z[i], lambda, c, true); } return deriv; @@ -3381,7 +3381,7 @@ std::vector> MLPPActivation::SELU(std::vector> a; a.resize(z.size()); - for (int i = 0; i < a.size(); i++) { + for (uint32_t i = 0; i < a.size(); i++) { a[i] = SELU(z[i], lambda, c); } return a; @@ -3398,7 +3398,7 @@ std::vector MLPPActivation::GELU(std::vector z, bool deriv) { if (deriv) { std::vector deriv; deriv.resize(z.size()); - for (int i = 0; i < z.size(); i++) { + for (uint32_t i = 0; i < z.size(); i++) { deriv[i] = GELU(z[i], true); } return deriv; @@ -3406,7 +3406,7 @@ std::vector MLPPActivation::GELU(std::vector z, bool deriv) { std::vector a; a.resize(z.size()); - for (int i = 0; i < a.size(); i++) { + for (uint32_t i = 0; i < a.size(); i++) { a[i] = GELU(z[i]); } return a; @@ -3416,7 +3416,7 @@ std::vector> MLPPActivation::GELU(std::vector> deriv; deriv.resize(z.size()); - for (int i = 0; i < z.size(); i++) { + for (uint32_t i = 0; i < z.size(); i++) { deriv[i] = GELU(z[i], true); } return deriv; @@ -3424,7 +3424,7 @@ std::vector> MLPPActivation::GELU(std::vector> a; a.resize(z.size()); - for (int i = 0; i < a.size(); i++) { + for (uint32_t i = 0; i < a.size(); i++) { a[i] = GELU(z[i]); } return a; @@ -3447,7 +3447,7 @@ std::vector MLPPActivation::sign(std::vector z, bool deriv) { if (deriv) { std::vector deriv; deriv.resize(z.size()); - for (int i = 0; i < z.size(); i++) { + for (uint32_t i = 0; i < z.size(); i++) { deriv[i] = sign(z[i], true); } return deriv; @@ -3455,7 +3455,7 @@ std::vector MLPPActivation::sign(std::vector z, bool deriv) { std::vector a; a.resize(z.size()); - for (int i = 0; i < a.size(); i++) { + for (uint32_t i = 0; i < a.size(); i++) { a[i] = sign(z[i]); } return a; @@ -3465,7 +3465,7 @@ std::vector> MLPPActivation::sign(std::vector> deriv; deriv.resize(z.size()); - for (int i = 0; i < z.size(); i++) { + for (uint32_t i = 0; i < z.size(); i++) { deriv[i] = sign(z[i], true); } return deriv; @@ -3473,7 +3473,7 @@ std::vector> MLPPActivation::sign(std::vector> a; a.resize(z.size()); - for (int i = 0; i < a.size(); i++) { + for (uint32_t i = 0; i < a.size(); i++) { a[i] = sign(z[i]); } return a; @@ -3765,14 +3765,14 @@ std::vector MLPPActivation::activation(std::vector z, bool deriv if (deriv) { std::vector deriv; deriv.resize(z.size()); - for (int i = 0; i < z.size(); i++) { + for (uint32_t i = 0; i < z.size(); i++) { deriv[i] = function(z[i], true); } return deriv; } std::vector a; a.resize(z.size()); - for (int i = 0; i < z.size(); i++) { + for (uint32_t i = 0; i < z.size(); i++) { a[i] = function(z[i], deriv); } return a;