Skip to content

Conversation

@ThomasJButler
Copy link

Problem

The generative_adversarial_network.py script fails to run due to a deprecated import:

Error:

ImportError: cannot import name 'fetch_mldata' from 'sklearn.datasets'
fetch_mldata was deprecated in scikit-learn 0.20 and removed in scikit-learn 1.2.

Solution

  • Replaced fetch_mldata with fetch_openml for MNIST data loading
  • Updated the function call to use 'mnist_784' dataset with version=1 and as_frame=False parameters
  • This maintains the same data structure and functionality while using the modern API

Testing

  • Script imports successfully
  • GAN initialises without errors
  • Training runs successfully with the new data loading method
  • Data format remains compatible with existing code

Changes

  • Line 8: from sklearn.datasets import fetch_mldatafrom sklearn.datasets import fetch_openml
  • Line 81: mnist = fetch_mldata('MNIST original')mnist = fetch_openml('mnist_784', version=1, as_frame=False)

This fix ensures compatibility with modern scikit-learn versions while maintaining backward compatibility with the existing codebase.

- Replace fetch_mldata with fetch_openml for MNIST data loading
- Update function call to use 'mnist_784' dataset with version=1 and as_frame=False
- Resolves ImportError: cannot import name 'fetch_mldata' from 'sklearn.datasets'

fetch_mldata was deprecated in sklearn 0.20 and removed in sklearn 1.2
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.

1 participant