Training with .mat files

I had run this code with a very simple regular expression as you can see \d{4} . But i am getting a error which says Failed to find {pat} in the log. Does this mean my reg expression is wrong?. Also the error says len() of unsized object. I am not sure what caused this error. Pls let me know where i went wrong. Thanks for any help

%reload_ext autoreload
%autoreload 2
%matplotlib inline

from import *
from fastai.metrics import error_rate
from mat4py import loadmat
from pylab import*
import matplotlib
import os
import numpy as np # linear algebra
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.image as mpimg


for dirname,_,filenames in os.walk(’/Users/Ashi/Downloads/TrainingSet2’ ):
for filename in filenames:
print(os.path.join(dirname, filename))

path = (’/Users/Ashi/Downloads/TrainingSet2’)

pat = r’\d{4}’

data = ImageDataBunch.from_name_re(path, filename, pat, ds_tfms=get_transforms(), size=224)

TypeError Traceback (most recent call last)
----> 1 data = ImageDataBunch.from_name_re(path, filename, pat, ds_tfms=get_transforms(), size=224)
2 #data.normalize(imagenet_stats)

~/opt/anaconda3/lib/python3.7/site-packages/fastai/vision/ in from_name_re(cls, path, fnames, pat, valid_pct, **kwargs)
156 assert res,f’Failed to find “{pat}” in “{fn}”’
157 return
–> 158 return cls.from_name_func(path, fnames, _get_label, valid_pct=valid_pct, **kwargs)
160 @staticmethod

~/opt/anaconda3/lib/python3.7/site-packages/fastai/vision/ in from_name_func(cls, path, fnames, label_func, valid_pct, seed, **kwargs)
144 **kwargs):
145 “Create from list of fnames in path with label_func.”
–> 146 src = ImageList(fnames, path=path).split_by_rand_pct(valid_pct, seed)
147 return cls.create_from_ll(src.label_from_func(label_func), **kwargs)
~/opt/anaconda3/lib/python3.7/site-packages/fastai/ in split_by_rand_pct(self, valid_pct, seed)
220 if valid_pct==0.: return self.split_none()
221 if seed is not None: np.random.seed(seed)
–> 222 rand_idx = np.random.permutation(range_of(self))
223 cut = int(valid_pct * len(self))
224 return self.split_by_idx(rand_idx[:cut])

TypeError: len() of unsized object

you can not load mat files directly. you have to use library and define a function for it. something like :

   from import loadmat

   mat_files = get_files(path_mat)
   mat_names = set([os.path.splitext([0] for f in mat_files]);mat_names

 for n in mat_names:
      lbz=[]; %variables
      lbz = loadmat(path_mat+'/'+n+'.mat')
      [do somethings for f in [*lbz]]

can u explain what that code does?

once you load a single mat file with loadmat it returns variables. So the code may be used to get variable names in a matlab file and do something with it.