tf.keras.Model.save can't handle UNC paths
You can in fact choose `path="\\\\localhost\\c$"`, the UNC path to the root of the C: drive, to reproduce the error. Hi @**early-stopper** 
Can you save the model to a local path and then copy it to the UNC path after saving
Or else use different saving formats
you can find the documentation on the official website on this.

Thank you!

 I could save the model locally and copy it by hand, which works until I want to implement some sort of automatising the training loop. As I said, using paths with drive letter names also resolves the problem. And, finally, using either the 'keras' or the 'h5' format instead of 'SavedModel' seems to resolve the issue as well, though each of those have shortcomings of their own (e.g. when saving custom objects, according to documentation).

Those are all possible workarounds and I will settle for one of them for the moment. Nevertheless, I consider `SavedModel` not handling UNC paths correctly a bug, even more so since it already worked in an earlier version of TensorFlow. Hi @early-stopper ,

As per [documentation](https://www.tensorflow.org/api_docs/python/tf/keras/saving/load_model#:~:text=Args-,filepath,or%20pathlib.Path%20object%2C%20path%20to%20the%20saved%20model%20file.,-custom_objects) the argument filepath should be `str` or `pathlib.Path` object.

Could you please just try with pathlib.Path(path) and let us know if it works. Thanks! Hi @SuryanarayanaY,
kindly see my answer in #62337 to this. In short: Running `pathlib.Path(...)` on Windows will produce an instance of `pathlib.WindowsPath` anyway, so replacing the latter with the former doesn't make a difference. Even if this wasn't the case, you would expect `pathlib.WindowsPath` as a subclass of `pathlib.Path` to work anywhere that an instance of `pathlib.Path` is assumed. Also just want to know whether it works with keras-nightly (i.e keras3.0.dev). Could you able to check it if have bandwidth.

Thanks! I cannot reproduce the error with `keras-nightly`, because it does not support saving models in the `SavedModel` format: running
```python
import pathlib
import keras

path = "\\\\localhost\\c$"
path = pathlib.Path(path)
path = path/'test'
path.mkdir(exist_ok=True, parents=True)

model = keras.Sequential()
model.add(keras.Input(shape=(16,)))
model.add(keras.layers.Dense(8))

model.save(path/'model', save_format='tf')
```
will result in
```
ValueError: Invalid filepath extension for saving. Please add either a `.keras` extension for the native Keras format (recommended) or a `.h5` extension. Use `tf.saved_model.save()` if you want to export a SavedModel for use with TFLite/TFServing/etc. Received: filepath=\\localhost\c$\test\model.
```
It works, of course, when switching to the `keras` saving format, but, as I noted before, so does `tf.saved_model.save()`. The issue only comes up when using the `SavedModel` format. Keras3 won't support 'tf' format. You need to test with .keras only. Its success with Keras3 as per attached [gist](https://colab.research.google.com/gist/SuryanarayanaY/7f2dc1f13c2c451ebc9823393030758d/62319.ipynb#scrollTo=uRgfC8qOh-ng).

If you want to test with tf format you need to import tf-keras package and set `os.environ["TF_USE_LEGACY_KERAS"]="1"`.
Teste the code woth tf format after tf-keras import and model saved fine.Please refer attached [gist](https://colab.research.google.com/gist/SuryanarayanaY/93965dd4d3cce98a4085f4838619ace6/62319-tf-keras.ipynb). I think we can close this issue, the solution is to just use the `keras` format for saving models. As far as I understand it now, the `tf` format can be considered deprecated and there is no use in trying to make it work in future code. Hi @early-stopper ,

Thanks for confirmation. Closing the issue as per author confirmation. Please feel reopen if find any problem.

Thanks! Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/62319">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/62319">No</a>

### Issue type

Bug

### Have you reproduced the bug with TensorFlow Nightly?

No

### Source

binary

### TensorFlow version

tf 2.14.0

### Custom code

Yes

### OS platform and distribution

Windows 10

### Mobile device

_No response_

### Python version

3.11.6

### Bazel version

_No response_

### GCC/compiler version

_No response_

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current behavior?

We use a network drive to share trained model instances among multiple machines. With TensorFlow 2.11, I could use a UNC path to save models like
`model.save("\\\\ComputerName\\path\\to\\folder")`
to save an instance of `tf.keras.Model` to the network drive in the `SavedModel` format. Having updated to TensorFlow 2.14, I now get the following error:
`tensorflow.python.framework.errors_impl.FailedPreconditionError: \\ComputerName\path\to\folder is not a directory.`
A possible workaround is to use the drive letter `J` that I have assigned to `\\ComputerName` on my local machine, so the following works as expected:
`model.save("J:\\path\\to\\folder")`
But that is not really a solution for me, because then I would have to rely on others to use the same letter `J` for the network drive.

### Standalone code to reproduce the issue

```shell
import pathlib
import tensorflow as tf

# Replace dummy with actual UNC path here
path = "\\\\ComputerName\\path\\to\\folder"
path = pathlib.WindowsPath(path)
path.mkdir(exist_ok=True, parents=True)

model = tf.keras.Sequential()
model.add(tf.keras.Input(shape=(16,)))
model.add(tf.keras.layers.Dense(8))

model.save(path)
```


### Relevant log output

_No response_