4 python typeerror python-3.x pytorch
我不知道如何解决这个错误,但我希望你们中的一些人知道如何解决这个问题。
错误:TypeError: __init__() got an unexpected keyword argument 'filepath'
完整错误消息:
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'
Run Code Online (Sandbox Code Playgroud)
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=''
)
Run Code Online (Sandbox Code Playgroud)
Jas*_*ves 11
ModelCheckpoint没有filepath关键字,但是它有一个关键字(正如您在文档dirpath中看到的那样),替换为,如下所示:filepathdirpath
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=''
)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9919 次 |
| 最近记录: |