Issue
I don't know how to solve this error but I hope some of you guys know how to solve this issue.
Error:TypeError: __init__() got an unexpected keyword argument 'filepath'
Full error message:
File "train.py", line 167, in <module>
main(args)
File "train.py", line 113, in main
checkpoint_callback=checkpoint_callback(),
File "train.py", line 86, in checkpoint_callback
return ModelCheckpoint(
TypeError: __init__() got an unexpected keyword argument 'filepath'
from pytorch_lightning.callbacks import ModelCheckpoint
save_model_path = path/to/your/dir
def checkpoint_callback():
return ModelCheckpoint(
filepath= save_model_path,
save_top_k=True,
verbose=True,
monitor='val_loss',
mode='min',
prefix=''
)
Solution
ModelCheckpoint
doesn't have a filepath
keyword, it does however have a dirpath
keyword (as you can see in the documentation), replace filepath
with dirpath
, like this:
from pytorch_lightning.callbacks import ModelCheckpoint
save_model_path = path/to/your/dir
def checkpoint_callback():
return ModelCheckpoint(
dirpath=save_model_path, # changed line
save_top_k=True,
verbose=True,
monitor='val_loss',
mode='min',
prefix=''
)
Answered By - Jason Rebelo Neves
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.