Skip to content

Update image conversion and reshaping for MNIST - #315

Open
NikJur wants to merge 1 commit into
ccpem:developfrom
NikJur:patch-3
Open

Update image conversion and reshaping for MNIST#315
NikJur wants to merge 1 commit into
ccpem:developfrom
NikJur:patch-3

Conversation

@NikJur

@NikJur NikJur commented Jul 30, 2026

Copy link
Copy Markdown
Contributor
  • previously failed because MNIST stored as flattened 784-element vector, but aVAE expected 28x28 format

Change np.array to np.asarray for image conversion and add reshaping logic for flattened MNIST images.

Change np.array to np.asarray for image conversion and add reshaping logic for flattened MNIST images.
Copilot AI review requested due to automatic review settings July 30, 2026 10:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the MNIST saving pipeline to handle datasets where images are stored as flattened 784-element vectors by converting to NumPy arrays and reshaping into 2D square images before downstream processing.

Changes:

  • Switches image conversion from np.array to np.asarray.
  • Adds logic to detect 1D flattened images and reshape them into a square 2D array (e.g., 28×28), with validation for non-square lengths.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tutorials/mnist_saver.py
Comment on lines 116 to +120
width, height = im.size
image_name = str(label) + '_' + str(index) + self._image_format
image = np.array(image)
image = np.asarray(image)
# MNIST may be stored as flattened 784-element vectors and need converting into 28x28
if image.ndim == 1:0
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