If a path to folder which wasn't created yet is set as filepath in ModelCheckpoint, the folder isn't created.
🐛 Bug
This pull request changed the behavior of ModelCheckpoint:
#2153
Now it looks like this:
if os.path.isdir(filepath):
    self.dirpath, self.filename = filepath, '{epoch}'
else:
    filepath = os.path.realpath(filepath)
    self.dirpath, self.filename = os.path.split(filepath)
os.makedirs(self.dirpath, exist_ok=True)
Theoretically, if filepath is a directory, it should make self.dirpath be equal to filepath, and if filepath is a path to file, then self.dirpath is a part of the defined filepath
But in fact, if the defined directory wasn't created yet (for example I want separate folder for each run), then os.path.isdir(filepath) is False and filepath is treated like a filename and is splitted.
For example, I set saved_models as a filepath.
After os.realpath it turns into something like path_to_run_dir/saved_models
Then we have this line: self.dirpath, self.filename = os.path.split(filepath)
And as a result self.dirpath is equal to path_to_run_dir