Skip to content

Commit

Permalink
MNIST training set and network training done!
Browse files Browse the repository at this point in the history
Achieved a loss of 0.008, with 35 epochs, with 1000 training samples.
  • Loading branch information
LauriSarap committed Aug 21, 2023
1 parent 0dca37b commit 3a0a1db
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Examples/MNIST/MNIST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ int main()
std::vector<Eigen::MatrixXd> x_train;
for (int i = 0; i < training_samples; ++i) // TODO Check how this is done faster. Potentially using Eigen::Map
{
Eigen::VectorXd image_vector(28*28);
Eigen::MatrixXd image_vector(1, 28*28);
for (int row = 0; row < 28; ++row)
{
for (int col = 0; col < 28; ++col)
{
// Normalize the pixel values to be of type double and be between 0 and 1.
image_vector(row * 28 + col) = static_cast<double>(mnist_data.training_images[i](row, col)) / 255.0;
image_vector(0, row * 28 + col) = static_cast<double>(mnist_data.training_images[i](row, col)) / 255.0;
}
}

Expand All @@ -45,8 +45,8 @@ int main()
std::vector<Eigen::MatrixXd> y_train;
for (int i = 0; i < training_samples; ++i)
{
Eigen::VectorXd label_vector = Eigen::VectorXd::Zero(10);
label_vector(mnist_data.training_labels[i]) = 1.0;
Eigen::MatrixXd label_vector = Eigen::MatrixXd::Zero(1, 10);
label_vector(0, mnist_data.training_labels[i]) = 1.0;
y_train.push_back(label_vector);
}

Expand Down

0 comments on commit 3a0a1db

Please sign in to comment.