Learn practical skills, build real-world projects, and advance your career
project_name = 'fashion_mnist_classification'
!conda install numpy pytorch torchvision cpuonly -c pytorch -y
!pip install matplotlib --upgrade --quiet
!pip install jovian --upgrade --quiet
!pip install pandas
Collecting package metadata (current_repodata.json): done Solving environment: done ==> WARNING: A newer version of conda exists. <== current version: 4.8.2 latest version: 4.8.3 Please update conda by running $ conda update -n base conda ## Package Plan ## environment location: /srv/conda/envs/notebook added / updated specs: - cpuonly - numpy - pytorch - torchvision The following packages will be downloaded: package | build ---------------------------|----------------- blas-2.15 | mkl 10 KB conda-forge cpuonly-1.0 | 0 2 KB pytorch freetype-2.10.2 | he06d7ca_0 905 KB conda-forge intel-openmp-2020.1 | 217 780 KB defaults jpeg-9d | h516909a_0 266 KB conda-forge libblas-3.8.0 | 15_mkl 10 KB conda-forge libcblas-3.8.0 | 15_mkl 10 KB conda-forge libgfortran-ng-7.5.0 | hdf63c60_6 1.7 MB conda-forge liblapack-3.8.0 | 15_mkl 10 KB conda-forge liblapacke-3.8.0 | 15_mkl 10 KB conda-forge libpng-1.6.37 | hed695b0_1 308 KB conda-forge libtiff-4.1.0 | hc7e4089_6 668 KB conda-forge libwebp-base-1.1.0 | h516909a_3 845 KB conda-forge lz4-c-1.9.2 | he1b5a44_1 226 KB conda-forge mkl-2020.1 | 217 129.0 MB defaults ninja-1.10.0 | hc9558a2_0 1.9 MB conda-forge numpy-1.18.5 | py37h8960a57_0 5.1 MB conda-forge olefile-0.46 | py_0 31 KB conda-forge pillow-7.1.2 | py37h718be6c_0 658 KB conda-forge pytorch-1.5.0 | py3.7_cpu_0 90.5 MB pytorch torchvision-0.6.0 | py37_cpu 11.0 MB pytorch zstd-1.4.4 | h6597ccf_3 991 KB conda-forge ------------------------------------------------------------ Total: 244.7 MB The following NEW packages will be INSTALLED: blas conda-forge/linux-64::blas-2.15-mkl cpuonly pytorch/noarch::cpuonly-1.0-0 freetype conda-forge/linux-64::freetype-2.10.2-he06d7ca_0 intel-openmp pkgs/main/linux-64::intel-openmp-2020.1-217 jpeg conda-forge/linux-64::jpeg-9d-h516909a_0 libblas conda-forge/linux-64::libblas-3.8.0-15_mkl libcblas conda-forge/linux-64::libcblas-3.8.0-15_mkl libgfortran-ng conda-forge/linux-64::libgfortran-ng-7.5.0-hdf63c60_6 liblapack conda-forge/linux-64::liblapack-3.8.0-15_mkl liblapacke conda-forge/linux-64::liblapacke-3.8.0-15_mkl libpng conda-forge/linux-64::libpng-1.6.37-hed695b0_1 libtiff conda-forge/linux-64::libtiff-4.1.0-hc7e4089_6 libwebp-base conda-forge/linux-64::libwebp-base-1.1.0-h516909a_3 lz4-c conda-forge/linux-64::lz4-c-1.9.2-he1b5a44_1 mkl pkgs/main/linux-64::mkl-2020.1-217 ninja conda-forge/linux-64::ninja-1.10.0-hc9558a2_0 numpy conda-forge/linux-64::numpy-1.18.5-py37h8960a57_0 olefile conda-forge/noarch::olefile-0.46-py_0 pillow conda-forge/linux-64::pillow-7.1.2-py37h718be6c_0 pytorch pytorch/linux-64::pytorch-1.5.0-py3.7_cpu_0 torchvision pytorch/linux-64::torchvision-0.6.0-py37_cpu zstd conda-forge/linux-64::zstd-1.4.4-h6597ccf_3 Downloading and Extracting Packages torchvision-0.6.0 | 11.0 MB | ##################################### | 100% libtiff-4.1.0 | 668 KB | ##################################### | 100% libwebp-base-1.1.0 | 845 KB | ##################################### | 100% libblas-3.8.0 | 10 KB | ##################################### | 100% mkl-2020.1 | 129.0 MB | ##################################### | 100% libgfortran-ng-7.5.0 | 1.7 MB | ##################################### | 100% libpng-1.6.37 | 308 KB | ##################################### | 100% libcblas-3.8.0 | 10 KB | ##################################### | 100% liblapack-3.8.0 | 10 KB | ##################################### | 100% pytorch-1.5.0 | 90.5 MB | ##################################### | 100% liblapacke-3.8.0 | 10 KB | ##################################### | 100% lz4-c-1.9.2 | 226 KB | ##################################### | 100% cpuonly-1.0 | 2 KB | ##################################### | 100% freetype-2.10.2 | 905 KB | ##################################### | 100% zstd-1.4.4 | 991 KB | ##################################### | 100% intel-openmp-2020.1 | 780 KB | ##################################### | 100% ninja-1.10.0 | 1.9 MB | ##################################### | 100% pillow-7.1.2 | 658 KB | ##################################### | 100% olefile-0.46 | 31 KB | ##################################### | 100% blas-2.15 | 10 KB | ##################################### | 100% jpeg-9d | 266 KB | ##################################### | 100% numpy-1.18.5 | 5.1 MB | ##################################### | 100% Preparing transaction: done Verifying transaction: done Executing transaction: done Collecting pandas Downloading pandas-1.0.4-cp37-cp37m-manylinux1_x86_64.whl (10.1 MB) |████████████████████████████████| 10.1 MB 5.3 MB/s eta 0:00:01 |██████▍ | 2.0 MB 5.3 MB/s eta 0:00:02 Requirement already satisfied: numpy>=1.13.3 in /srv/conda/envs/notebook/lib/python3.7/site-packages (from pandas) (1.18.5) Collecting pytz>=2017.2 Downloading pytz-2020.1-py2.py3-none-any.whl (510 kB) |████████████████████████████████| 510 kB 36.5 MB/s eta 0:00:01 Requirement already satisfied: python-dateutil>=2.6.1 in /srv/conda/envs/notebook/lib/python3.7/site-packages (from pandas) (2.8.1) Requirement already satisfied: six>=1.5 in /srv/conda/envs/notebook/lib/python3.7/site-packages (from python-dateutil>=2.6.1->pandas) (1.15.0) Installing collected packages: pytz, pandas Successfully installed pandas-1.0.4 pytz-2020.1
import torch
import jovian
import torchvision
import torch.nn as nn
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import torch.nn.functional as F
import torchvision.transforms as transforms
from torchvision.datasets import FashionMNIST
from torchvision.datasets.utils import download_url
from torch.utils.data import DataLoader, TensorDataset, random_split
train_dataset = FashionMNIST(root='data/', train=True, transform=transforms.ToTensor(), download=True)
test_dataset = FashionMNIST(root='data/', train=False, transform=transforms.ToTensor())
1.9%
Downloading http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/train-images-idx3-ubyte.gz to data/FashionMNIST/raw/train-images-idx3-ubyte.gz
100.0%
Extracting data/FashionMNIST/raw/train-images-idx3-ubyte.gz to data/FashionMNIST/raw
11.3%%
Downloading http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/train-labels-idx1-ubyte.gz to data/FashionMNIST/raw/train-labels-idx1-ubyte.gz Extracting data/FashionMNIST/raw/train-labels-idx1-ubyte.gz to data/FashionMNIST/raw Downloading http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/t10k-images-idx3-ubyte.gz to data/FashionMNIST/raw/t10k-images-idx3-ubyte.gz
159.1%/opt/conda/conda-bld/pytorch_1587428190859/work/torch/csrc/utils/tensor_numpy.cpp:141: UserWarning: The given NumPy array is not writeable, and PyTorch does not support non-writeable tensors. This means you can write to the underlying (supposedly non-writeable) NumPy array using the tensor. You may want to copy the array to protect its data or make it writeable before converting it to a tensor. This type of warning will be suppressed for the rest of this program.
Extracting data/FashionMNIST/raw/t10k-images-idx3-ubyte.gz to data/FashionMNIST/raw Downloading http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/t10k-labels-idx1-ubyte.gz to data/FashionMNIST/raw/t10k-labels-idx1-ubyte.gz Extracting data/FashionMNIST/raw/t10k-labels-idx1-ubyte.gz to data/FashionMNIST/raw Processing... Done!
train_dataset, test_dataset
(Dataset FashionMNIST
     Number of datapoints: 60000
     Root location: data/
     Split: Train
     StandardTransform
 Transform: ToTensor(),
 Dataset FashionMNIST
     Number of datapoints: 10000
     Root location: data/
     Split: Test
     StandardTransform
 Transform: ToTensor())