"size mismatch" in simple Mnist implementation

Hello!

I’ve been twisting and turning this both in a notebook and in python but i can’t seem to make it work. Here’s code:

from fastai.vision import *
import torch.nn as nn

class Mnist_Linear_NN(nn.Module):
    def __init__(self):
        super().__init__()
        self.lin1 = nn.Linear(784, 50, bias=True)
        self.lin2 = nn.Linear(50, 10, bias=True)

    def forward(self, xb):
        x = self.lin1(xb)
        return self.lin2(x)


def main():
    np.random.seed(42)
    path_img = Path("data/")
    fnames = get_image_files(path_img)
    pat = r'data\/mnist-\d+-(\d).png'
    bs = 32
    data = ImageDataBunch.from_name_re(path_img, fnames, pat, bs=bs, size=28)
    learn = Learner(data, Mnist_Linear_NN(), metrics=accuracy)
    learn.fit_one_cycle(1)

main()

This returns a long traceback (https://pastebin.com/zsevywL5), which ends with RuntimeError: size mismatch, m1: [2688 x 28], m2: [784 x 50] at /opt/conda/conda-bld/pytorch_1556653114079/work/aten/src/TH/generic/THTensorMath.cpp:961.

Any help in fixing this would be much appreciated! Alternatively: is there any handy guide/info which allows me to implement a custom model into fastai? I’ve been skimming through lessons but haven’t found anything, most use transfer learning/resnets.

I’m working in w10, latest updates, got traceback in windows subsystem anaconda environment with fastai installation, but i don’t think it’s platform related.