pytorch/examples

OSError: [Errno 22] Invalid argument:

Open

#887 aperta il 14 feb 2021

Vedi su GitHub
 (3 commenti) (0 reazioni) (0 assegnatari)Python (9429 fork)batch import
good first issue

Metriche repository

Star
 (21.634 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

https://github.com/pytorch/examples/blob/36441a83b6595524a538e342594ee6482754f374/fast_neural_style/neural_style/neural_style.py#L117

Spent 2 hours training a model for it to fail the save with error prefixed with OSError: [Errno 22] Invalid argument :(

For now I'm just adding fail-safe but I am sure it can be written cleaner

custom_save_path = save_model_path
while True:
    try:
        torch.save(transformer.state_dict(), custom_save_path)
        break
    except:
        print("Please enter new save path:")
        custom_save_path = input() 

print("\nDone, trained model saved at", custom_save_path)

Guida contributor