text_plain_output_1.png image_output_1.png
import matplotlib.pyplot as plt

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import seaborn as sns

import torch

use_gpu = torch.cuda.is_available()
use_gpu

df_train_path = '/kaggle/input/digit-recognizer/train.csv'
df_test_path = '/kaggle/input/digit-recognizer/test.csv'
X_train = pd.read_csv(df_train_path)
X_test = pd.read_csv(df_test_path)
y_train = X_train['label']
X_train = X_train.drop('label', axis=1)

sns.set_style('darkgrid')
y_train.unique()

X_train /= 255.0
X_test /= 255.0
X_train = X_train.values
y_train = y_train.values
X_test = X_test.values

X_train = X_train.reshape(-1, 1, 28, 28)
X_val = X_val.reshape(-1, 1, 28, 28)

X_train = torch.from_numpy(X_train)
X_val = torch.from_numpy(X_val)
y_train = torch.from_numpy(y_train)
y_val = torch.from_numpy(y_val)

X_train.shape