I've built a text classifier using FastAi on Kaggle, while trying to export the trained model i get the following error - TypeError: unsupported operand type(s) for /: 'str' and 'str'
I've tried setting the leaner model directory and path to working directory.
learn_clas.path='/kaggle/working/'
learn_clas.model_dir='/kaggle/working/'
learn_clas.export()
Error i am getting is -
/opt/conda/lib/python3.6/site-packages/fastai/torch_core.py in try_save(state, path, file)
410 def try_save(state:Dict, path:Path=None, file:PathLikeOrBinaryStream=None):
--> 411 target = open(path/file, 'wb') if is_pathlike(file) else file
412 try: torch.save(state, target)
413 except OSError as e:
TypeError: unsupported operand type(s) for /: 'str' and 'str'
You have to replace path/file with the name of the file encased in strings.
target = open(path/file, 'wb') if is_pathlike(file) else file
In your code, python is treating path and file as variables instead of strings literals and trying to divide them. So you need some like this:
target = open('mydirectory/modelname.ext', 'wb') if is_pathlike(file) else file
or you can try
target = open(path+'/'+file, 'wb') if is_pathlike(file) else file