torch matmul code example
Example 1: torch import
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import DataLoader
from torchvision import datasets, transforms, models
from torchvision.utils import make_grid
import numpy as np
import pandas as pd
from sklearn.metrics import confusion_matrix
import matplotlib.pyplot as plt
%matplotlib inline
transform = transforms.ToTensor()
train_data = datasets.FashionMNIST(root='../Data', train=True, download=True, transform=transform)
test_data = datasets.FashionMNIST(root='../Data', train=False, download=True, transform=transform)
Example 2: pytorch - matrix multiplication
a = torch.tensor([[0, 2, 4], [1, 3, 5]])
b = torch.tensor([[0, 7], [8, 9], [10, 11]])
torch.mm(a, b)