ValueError: Only instances of `keras.Layer` can be added to a Sequential mode
Hi @zzj0402 ,

The code executes fine on Colab as per [gist](https://colab.research.google.com/gist/SuryanarayanaY/8a70d4b8f7772d1da6878a0e9c85507e/63085.ipynb). This moght be related to Kaggle environment which might have incompatible TF and tensorflow_hub version. You may check the Tensorflow and tensorflow_hub in kaggle environment and try to install those works in locally. Neverthless it's not problem with Tensorflow or Keras.

Thanks! i got the same issue also with Kaggle's environment, with @SuryanarayanaY conclusion i got the solution by just 
`pip install tensorflow` 
again and found out that the keras library reinstalls to latest version  ```
!pip install tensorflow
```
fixes the problem in Kaggle. 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/63085">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/63085">No</a>
 i had the same issue, tried all the things explained here but still having the same issue. i am not using kaggle i am coding on jupyter notebook. please help @Kun7l I am also having same issue. I am using jupyter notebook as well with PyCharm. I have tried many things but cannot fix this error. I believe it might be a package incompatibility error. However, I am using most up to date versions.  im also having this using conda, tried conda install again tensorflow and it no compatible with tensorflow_hub that i installed before, please help Has someone resolved this for jupyter notebook / conda enviroment? I am also having a similar problem (although with tensorflow probability) I got the same error when running the official notebook, https://www.tensorflow.org/tutorials/interpretability/integrated_gradients, the environment I am using is tensorflow==2.16 and tensorflow-hub==0.16.
But if I roll back to tensorflow 2.14 and tensorflow-hub 0.15, there is no such error. I've tried to use some previous versions of tensorflow, but on MacOS there was another bug that was't allowing me to use GPU acceleration. So I've solved the problem using the Model Subclassing API, here the example from my code:

    class MyModel(keras.Model):
      def __init__(self):
        super(MyModel, self).__init__()
        self.embedding_layer = embed
        self.dense_layer1 = layers.Dense(256, activation='relu')
        self.dense_layer2 = layers.Dense(128, activation='relu')
        self.dense_layer3 = layers.Dense(64, activation='relu')
        self.output_layer = layers.Dense(13, activation='softmax')

      def call(self, inputs):
        x = self.embedding_layer(inputs)
        x = self.dense_layer1(x)
        x = self.dense_layer2(x)
        x = self.dense_layer3(x)
        return self.output_layer(x)
 do anyone know how to resolve this error, i have been trying and reinstalling the tensorflow to its latest but still its gets the error 
### Issue type

Bug

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

No

### Source

source

### TensorFlow version

v2.15.0-rc1-8-g6887368d6d4 2.15.0

### Custom code

No

### OS platform and distribution

Kaggle

### Mobile device

_No response_

### Python version

_No response_

### Bazel version

_No response_

### GCC/compiler version

_No response_

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current behavior?

When trying to build a sequential model with TFhub model USE in Kaggle, the notebook throws an error complaining that the hub model is not a valid class instance. At the same time, the same code works fine locally.

### Standalone code to reproduce the issue

```shell
import pandas as pd
import tensorflow as tf
import tensorflow_hub as hub
from tensorflow.keras.optimizers import Adam, SGD
from tensorflow.keras.layers import Dense, Input, BatchNormalization, Dropout, Concatenate
from tensorflow.keras.models import Model, Sequential
from tensorflow.keras.callbacks import ModelCheckpoint
module_url = 'https://tfhub.dev/google/universal-sentence-encoder-large/5'
embed = hub.KerasLayer(module_url, trainable=True, name='USE_embedding')
def build_model(embed):
    
    model = Sequential([
        Input(shape=[], dtype=tf.string),
        embed,
        Dense(1, activation='sigmoid')
    ])
    model.compile(loss='mean_squared_error',
              optimizer=tf.keras.optimizers.Adam(
                  learning_rate=0.0001,
                  beta_1=0.9,
                  beta_2=0.999,
                  epsilon=1e-07,
                  amsgrad=False,
                  name='Adam'
              ), metrics=['accuracy'])
    return model
```
```


### Relevant log output

```shell
ValueError                                Traceback (most recent call last)
Cell In[9], line 1
----> 1 model=build_model(embed)
      2 model.fit(descriptions, labels, epochs=4)
      3 model.save('quality/use.keras')

Cell In[8], line 12, in build_model(embed)
     10 def build_model(embed):
---> 12     model = Sequential([
     13         Input(shape=[], dtype=tf.string),
     14         embed,
     15         Dense(1, activation='sigmoid')
     16     ])
     17     model.compile(loss='mean_squared_error',
     18               optimizer=tf.keras.optimizers.Adam(
     19                   learning_rate=0.0001,
   (...)
     24                   name='Adam'
     25               ), metrics=['accuracy'])
     26     return model

File /opt/conda/lib/python3.10/site-packages/keras/src/models/sequential.py:70, in Sequential.__init__(self, layers, trainable, name)
     68 if layers:
     69     for layer in layers:
---> 70         self.add(layer, rebuild=False)
     71     self._maybe_rebuild()

File /opt/conda/lib/python3.10/site-packages/keras/src/models/sequential.py:92, in Sequential.add(self, layer, rebuild)
     90         layer = origin_layer
     91 if not isinstance(layer, Layer):
---> 92     raise ValueError(
     93         "Only instances of `keras.Layer` can be "
     94         f"added to a Sequential model. Received: {layer} "
     95         f"(of type {type(layer)})"
     96     )
     97 if not self._is_layer_name_unique(layer):
     98     raise ValueError(
     99         "All layers added to a Sequential model "
    100         f"should have unique names. Name '{layer.name}' is already "
    101         "the name of a layer in this model. Update the `name` argument "
    102         "to pass a unique name."
    103     )

ValueError: Only instances of `keras.Layer` can be added to a Sequential model. Received: <tensorflow_hub.keras_layer.KerasLayer object at 0x793cedbef220> (of type <class 'tensorflow_hub.keras_layer.KerasLayer'>)
```
```
