Skip to content

Fix DenseLayer backpropagation and MNIST download reliability - #1

Draft
maybepritz with Copilot wants to merge 3 commits into
masterfrom
copilot/fix-denselayer-training-issue
Draft

Fix DenseLayer backpropagation and MNIST download reliability#1
maybepritz with Copilot wants to merge 3 commits into
masterfrom
copilot/fix-denselayer-training-issue

Conversation

Copilot AI commented Feb 1, 2026

Copy link
Copy Markdown

Neural network fails to learn on MNIST (~10% accuracy = random guessing) and file downloads intermittently corrupt.

Backpropagation Fix

DenseLayer.backpropagate() was propagating raw error instead of the computed gradient delta:

// Before: bypasses activation derivative
return weights.transpose().multiply(error);

// After: propagates delta correctly  
return weights.transpose().multiply(grad);

The grad already incorporates error × activation_derivative — the signal that must flow through the weight matrix to the previous layer.

Download Fix

downloadFile() used Files.copy() with an unbuffered URL stream, causing truncated GZIP files and EOFException.

  • Replaced with explicit buffered I/O (8KB chunks)
  • Reads until true EOF
  • Maintains replace-if-exists semantics via StandardOpenOption.TRUNCATE_EXISTING
Original prompt

Исправь DenseLayer, нейросеть плохо обучается, после 10 epoch обучения на mnist правильность ответов ~10%


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: maybepritz <79636615+maybepritz@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix DenseLayer to improve training accuracy on MNIST Fix DenseLayer backpropagation to use gradient delta instead of raw error Feb 1, 2026
Copilot AI requested a review from maybepritz February 1, 2026 11:43
Co-authored-by: maybepritz <79636615+maybepritz@users.noreply.github.com>
Copilot AI changed the title Fix DenseLayer backpropagation to use gradient delta instead of raw error Fix DenseLayer backpropagation and MNIST download reliability Feb 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants