Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] 'my_mnist.data' #617

Open
MarwanAshraf22 opened this issue Jun 11, 2023 · 1 comment
Open

[BUG] 'my_mnist.data' #617

MarwanAshraf22 opened this issue Jun 11, 2023 · 1 comment

Comments

@MarwanAshraf22
Copy link

OSError: [Errno 22] Invalid argument: 'my_mnist.data'
Does anyone know how to fix this error?

@Preet-Sojitra
Copy link

Preet-Sojitra commented Jun 17, 2023

This is the code that worked for me:

filename="my_mnist.data"
m, n = X_train.shape # Make sure you have loaded MNIST dataset, for loading refer the code snippet below

X_mm = np.memmap(filename, dtype='float32', mode="write", shape=(m, n))
X_mm[:] = X_train

del X_mm

X_mm = np.memmap(filename, dtype='float32', mode="readonly", shape=(m, n))
batch_size = m // n_batches
inc_pca = IncrementalPCA(n_components=154, batch_size=batch_size)
inc_pca.fit(X_mm)
# Fetching MNIST data
from sklearn.datasets import fetch_openml
from sklearn.model_selection import train_test_split

mnist = fetch_openml('mnist_784', version=1, as_frame=False)
mnist.target = mnist.target.astype(np.uint8)

X = mnist["data"]
y = mnist["target"]

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

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

No branches or pull requests

2 participants