Compare commits

..

14 Commits

Author SHA1 Message Date
notkshitij f497756963 add answers for may-june 2025 + november-december 2025 pyqs for unit 6 (Reinforcement Learning) 2026-05-26 00:58:41 +05:30
notkshitij 0a597c5917 add answers for may-june 2025 + november-december 2025 pyqs for unit 5 (Deep Generative Models) 2026-05-26 00:51:39 +05:30
notkshitij 03baa08d8a add answers for may-june 2025 + november-december 2025 pyqs for unit 4 (Recurrent Neural Network) 2026-05-26 00:38:48 +05:30
notkshitij 2a71605050 add answers for may-june 2025 + november-december 2025 pyqs for unit 3 (Convolution Neural Network) 2026-05-26 00:38:21 +05:30
notkshitij 702fe6cda6 add may-june 2025 + november-december 2025 pyqs for end-sem. 2026-05-25 23:19:28 +05:30
notkshitij fc477ab15b add link for end-sem pyq answers in README. 2026-05-21 20:45:05 +05:30
notkshitij 628d9f171e add end-sem pyq answers for unit 6 (Reinforcement Learning) 2026-05-21 20:44:23 +05:30
notkshitij 6b81388d0e add end-sem pyq answers for unit 5 (Deep Generative Models) 2026-05-21 20:42:56 +05:30
notkshitij 7bb921a482 add end-sem pyq answers for unit 4 (Recurrent Neural Network) 2026-05-21 20:41:14 +05:30
notkshitij 6135de00dd add end-sem pyq answers for unit 3 (Convolution Neural Network) 2026-05-21 20:34:24 +05:30
notkshitij 8489b2d5aa add end-sem pyqs for DL (may june 2023, nov-dec 2023, may-june 2024) 2026-05-15 01:41:24 +05:30
notkshitij 3f6ece863d chore: add single line of comment above local data loading lines of code @ practical 3b. 2026-05-04 16:35:07 +05:30
notkshitij deb41dfdc8 fix: remove function for loading dataset locally and add basic lines of code to load csv instead for practical 3b notebook. 2026-05-04 16:27:37 +05:30
notkshitij 73f8c867b7 fix: remove function for loading dataset locally and add basic lines of code to load csv instead for practical 3b. 2026-05-04 16:27:06 +05:30
12 changed files with 14 additions and 79 deletions
+8 -28
View File
@@ -38,34 +38,14 @@ from sklearn.metrics import confusion_matrix, classification_report
# Fashion MNIST is built into Keras, downloads automatically on first run # Fashion MNIST is built into Keras, downloads automatically on first run
(X_train, y_train), (X_test, y_test) = tf.keras.datasets.fashion_mnist.load_data() (X_train, y_train), (X_test, y_test) = tf.keras.datasets.fashion_mnist.load_data()
''' # --- Offline alternative (comment out tf.keras line above and use this instead) ---
import numpy as np # import pandas as pd
import gzip # train_df = pd.read_csv('fashion-mnist_train.csv')
import os # test_df = pd.read_csv('fashion-mnist_test.csv')
# y_train = train_df['label'].values
def load_fashion_mnist(path): # y_test = test_df['label'].values
"""Load Fashion MNIST from local .gz files (Kaggle Zalando format).""" # X_train = train_df.drop('label', axis=1).values.reshape(-1, 28, 28) # unflatten pixels to 28x28
files = { # X_test = test_df.drop('label', axis=1).values.reshape(-1, 28, 28)
'X_train': 'train-images-idx3-ubyte.gz',
'y_train': 'train-labels-idx1-ubyte.gz',
'X_test': 't10k-images-idx3-ubyte.gz',
'y_test': 't10k-labels-idx1-ubyte.gz',
}
with gzip.open(os.path.join(path, files['X_train'])) as f:
X_train = np.frombuffer(f.read(), np.uint8, offset=16).reshape(-1, 28, 28)
with gzip.open(os.path.join(path, files['y_train'])) as f:
y_train = np.frombuffer(f.read(), np.uint8, offset=8)
with gzip.open(os.path.join(path, files['X_test'])) as f:
X_test = np.frombuffer(f.read(), np.uint8, offset=16).reshape(-1, 28, 28)
with gzip.open(os.path.join(path, files['y_test'])) as f:
y_test = np.frombuffer(f.read(), np.uint8, offset=8)
return (X_train, y_train), (X_test, y_test)
# Replace the Keras load line with:
(X_train, y_train), (X_test, y_test) = load_fashion_mnist('./fashion-mnist/')
'''
print("Training set shape:", X_train.shape) # (60000, 28, 28) print("Training set shape:", X_train.shape) # (60000, 28, 28)
print("Test set shape: ", X_test.shape) # (10000, 28, 28) print("Test set shape: ", X_test.shape) # (10000, 28, 28)
+3 -50
View File
@@ -51,58 +51,11 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": null,
"id": "859cbc0f", "id": "859cbc0f",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{ "source": "# 2. Load Dataset\n# Fashion MNIST is built into Keras — downloads automatically on first run\n(X_train, y_train), (X_test, y_test) = tf.keras.datasets.fashion_mnist.load_data()\n\n# --- Offline alternative (comment out tf.keras line above and use this instead) ---\n# import pandas as pd\n# train_df = pd.read_csv('fashion-mnist_train.csv')\n# test_df = pd.read_csv('fashion-mnist_test.csv')\n# y_train = train_df['label'].values\n# y_test = test_df['label'].values\n# X_train = train_df.drop('label', axis=1).values.reshape(-1, 28, 28) # unflatten pixels to 28x28\n# X_test = test_df.drop('label', axis=1).values.reshape(-1, 28, 28)\n\nprint(\"Training set shape:\", X_train.shape) # (60000, 28, 28)\nprint(\"Test set shape: \", X_test.shape) # (10000, 28, 28)\nprint(\"Classes:\", np.unique(y_train))"
"name": "stdout",
"output_type": "stream",
"text": [
"Training set shape: (60000, 28, 28)\n",
"Test set shape: (10000, 28, 28)\n",
"Classes: [0 1 2 3 4 5 6 7 8 9]\n"
]
}
],
"source": [
"# 2. Load Dataset\n",
"# Fashion MNIST is built into Keras, downloads automatically on first run\n",
"(X_train, y_train), (X_test, y_test) = tf.keras.datasets.fashion_mnist.load_data()\n",
"\n",
"'''\n",
"import numpy as np\n",
"import gzip\n",
"import os\n",
"\n",
"def load_fashion_mnist(path):\n",
" \"\"\"Load Fashion MNIST from local .gz files (Kaggle Zalando format).\"\"\"\n",
" files = {\n",
" 'X_train': 'train-images-idx3-ubyte.gz',\n",
" 'y_train': 'train-labels-idx1-ubyte.gz',\n",
" 'X_test': 't10k-images-idx3-ubyte.gz',\n",
" 'y_test': 't10k-labels-idx1-ubyte.gz',\n",
" }\n",
"\n",
" with gzip.open(os.path.join(path, files['X_train'])) as f:\n",
" X_train = np.frombuffer(f.read(), np.uint8, offset=16).reshape(-1, 28, 28)\n",
" with gzip.open(os.path.join(path, files['y_train'])) as f:\n",
" y_train = np.frombuffer(f.read(), np.uint8, offset=8)\n",
" with gzip.open(os.path.join(path, files['X_test'])) as f:\n",
" X_test = np.frombuffer(f.read(), np.uint8, offset=16).reshape(-1, 28, 28)\n",
" with gzip.open(os.path.join(path, files['y_test'])) as f:\n",
" y_test = np.frombuffer(f.read(), np.uint8, offset=8)\n",
"\n",
" return (X_train, y_train), (X_test, y_test)\n",
"\n",
"# Replace the Keras load line with:\n",
"(X_train, y_train), (X_test, y_test) = load_fashion_mnist('./fashion-mnist/')\n",
"'''\n",
"\n",
"print(\"Training set shape:\", X_train.shape) # (60000, 28, 28)\n",
"print(\"Test set shape: \", X_test.shape) # (10000, 28, 28)\n",
"print(\"Classes:\", np.unique(y_train))"
]
}, },
{ {
"cell_type": "code", "cell_type": "code",
+2
View File
@@ -59,6 +59,8 @@ This repository gathers comprehensive material for the SPPU Computer Engineering
### [IN-SEM PYQ Answers](Notes/IN-SEM%20PYQ%20Answers/) ### [IN-SEM PYQ Answers](Notes/IN-SEM%20PYQ%20Answers/)
### [END-SEM PYQ Answers](Notes/END-SEM%20PYQ%20Answers/)
### [Question Bank](DL%20-%20Question%20Bank.pdf) ### [Question Bank](DL%20-%20Question%20Bank.pdf)
--- ---