Closed KotaShimomura closed 5 months ago
CNNによる画像認識(MNIST, Numpy実装)
上記のnotebookでMNISTがダウンロードできません. そのため,torchvisionのMNISTを利用する方法に変更しています.
該当notebook
import torchvision train_data = torchvision.datasets.MNIST(root="./", train=True, download=True) test_data = torchvision.datasets.MNIST(root="./", train=False, download=True)
x_train = train_data.data.numpy().reshape(-1, 784) y_train = train_data.targets.numpy() x_test = test_data.data.numpy().reshape(-1, 784) y_test = test_data.targets.numpy()
x_train = x_train.reshape(-1, 1, 28, 28) x_test = x_test.reshape(-1, 1, 28, 28)
print(x_train.shape, y_train.shape) print(x_test.shape, y_test.shape)
概要
CNNによる画像認識(MNIST, Numpy実装)
上記のnotebookでMNISTがダウンロードできません. そのため,torchvisionのMNISTを利用する方法に変更しています.
変更点
該当notebook
の編集 MNISTのダウンロード,読み込み部分のプログラムを変更.x_train = train_data.data.numpy().reshape(-1, 784) y_train = train_data.targets.numpy() x_test = test_data.data.numpy().reshape(-1, 784) y_test = test_data.targets.numpy()
x_train = x_train.reshape(-1, 1, 28, 28) x_test = x_test.reshape(-1, 1, 28, 28)
print(x_train.shape, y_train.shape) print(x_test.shape, y_test.shape)