Unable to load the model using vscode
Make sure to check again that the Google Collab TensorFlow version is the same as your local version. This error often shows up when you try to load a model trained on an older version of TensorFlow into a newer version. > Make sure to check again that the Google Collab TensorFlow version is the same as your local version. This error often shows up when you try to load a model trained on an older version of TensorFlow into a newer version.

@SunnyWan59  Thanks for your response. I make sure that my machine has `tensorflow version = 2.15.0` and the model which is trained using google colab has exactly same version
<img width="419" alt="image" src="https://github.com/tensorflow/tensorflow/assets/24364597/e1228704-2a1e-4b5c-a776-1e3e7789e23c">

<img width="389" alt="image" src="https://github.com/tensorflow/tensorflow/assets/24364597/6a70f7df-7295-41ea-9768-3bd808426205">
 Sir,

I request you to provide me the complete code and files required direct for VS Code execution so that I can run it and test it  in my local machine as the saved model is not available to me to run the code. However, simply from the error logged, I think there is some parameters issue in the model which is causing the model as a whole incompatible between its layers and thus the error.

Thank you. @Praveer1981 If you saved the model please confirm that weights were included using model.save_weights() or a similar method. Please save the model with the same TensorFlow/Keras version you're using in VS Code. 
In order to expedite the trouble-shooting process, please provide a complete code snippet to reproduce the issue reported here. Thank you! @sushreebarsa below is my code ,

reference :
[Train the model](https://keras.io/examples/vision/image_classification_from_scratch/)

```
epochs = 25
modelPath = "/content/drive/MyDrive/SavedModels/FruitClassification"
callbacks = [
    ModelCheckpoint(f"{modelPath}/save_at_{{epoch}}.keras"),
]
model.compile(
    optimizer='adam',
    loss=SparseCategoricalCrossentropy(from_logits=True),
    metrics=['accuracy']
)

history1 = model.fit(
            train_ds,
            epochs=epochs,
            callbacks=callbacks,
            validation_data=val_ds,
        )
```

I haven't used **model.save_weights()** 

 > [sushreebarsa](/sushreebarsa)

@sushreebarsa any advice please ? @Praveer1981 Sorry for the late response!
Please ensure the TensorFlow versions used for saving and loading the model are compatible. Mismatched versions can lead to loading errors.
Could you please make sure that you are using keras3 as the reference you are using is also keras3 based?
Thank you! This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you. This issue was closed because it has been inactive for 7 days since being marked as stale. Please reopen if you'd like to work on this further. 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/62787">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/62787">No</a>

### Issue type

Support

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

No, I dnt know how to do it

### Source

source

### TensorFlow version

2.15.0

### Custom code

Yes

### OS platform and distribution

windows 11

### Mobile device

_No response_

### Python version

3.11.2

### Bazel version

_No response_

### GCC/compiler version

_No response_

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current behavior?

I am unable to load the model using vscode. It throws below error :

**Error loading the model: Layer 'conv2d' expected 2 variables, but received 0 variables during loading. Expected: ['conv2d/kernel:0', 'conv2d/bias:0']**

Below is my  code snippet :

```
epochs = 25
modelPath = "/content/drive/MyDrive/SavedModels/FruitClassification"
callbacks = [
    ModelCheckpoint(f"{modelPath}/save_at_{{epoch}}.keras"),
]
model.compile(
    optimizer='adam',
    loss=SparseCategoricalCrossentropy(from_logits=True),
    metrics=['accuracy']
)

history1 = model.fit(
            train_ds,
            epochs=epochs,
            callbacks=callbacks,
            validation_data=val_ds,
        )

```
Above is the code that I wrote (**Google Colab**) to generate the model with .keras extension. I downloaded that model in my local machine and I am using below code to load the model:

```
try:
    MODEL = tf.keras.models.load_model("./save_at_20.keras")
except ValueError as e:
    print("Error loading the model:", e)
Unfortunately, I encountered the below error:
```

**Error loading the model: Layer 'conv2d' expected 2 variables, but received 0 variables during loading. Expected: ['conv2d/kernel:0', 'conv2d/bias:0']** 

The TensorFlow version is 2.15.0, both in Google Colab and on my local machine. My machine has Python 3.11.2 installed.

could someone help me on it ?

### Standalone code to reproduce the issue

```shell
epochs = 25
modelPath = "/content/drive/MyDrive/SavedModels/FruitClassification"
callbacks = [
    ModelCheckpoint(f"{modelPath}/save_at_{{epoch}}.keras"),
]
model.compile(
    optimizer='adam',
    loss=SparseCategoricalCrossentropy(from_logits=True),
    metrics=['accuracy']
)

history1 = model.fit(
            train_ds,
            epochs=epochs,
            callbacks=callbacks,
            validation_data=val_ds,
        )

Above is the code that I wrote(google colab) to generate the model with .keras extension. I downloaded that model in my local machine and I am using below code to load the model:

try:
    MODEL = tf.keras.models.load_model("./save_at_20.keras")
except ValueError as e:
    print("Error loading the model:", e)
Unfortunately, I encountered the below error:

Error loading the model: Layer 'conv2d' expected 2 variables, but received 0 variables during loading. Expected: ['conv2d/kernel:0', 'conv2d/bias:0']
```


### Relevant log output

_No response_