How to Replace the input layer of a model

I have a model with input layer as shape (None,128,128,1)
Model: “model”


Layer (type) Output Shape Param #

input_1 (InputLayer) [(None, 128, 128, 1)] 0


conv2d (Conv2D) (None, 126, 126, 16) 160


max_pooling2d (MaxPooling2D) (None, 63, 63, 16) 0


conv2d_1 (Conv2D) (None, 61, 61, 32) 4640


max_pooling2d_1 (MaxPooling2 (None, 30, 30, 32) 0


flatten (Flatten) (None, 28800) 0


dense (Dense) (None, 128) 3686528


dense_1 (Dense) (None, 10) 1290

Total params: 3,692,618
Trainable params: 3,692,618
Non-trainable params: 0

now i have trained and saved the model and later loaded the model USING

new_model = tf.keras.models.load_model('saved_model/my_model')
``
Now i want to change the input layer with shape (256,256,1)
and use the rest of the model weights the same 
how can I do this?
What I have tried 
```python
new_model.layers.pop(0) 
mode=tf.keras.Sequential()
mode.add(tf.keras.Input(shape=(256,256,1)))
for lay in new_model.layers[1:]:
    mode.add(lay)

none of these work for me

is there a way?

I think the approach you followed should work. I tried with mnist example as shown in the following gist.

Only thing is to make sure that changing the input shape should not affect the layers after input layer. Please share entire code (with any dummy data) for further support.

new_model = tf.keras.Sequential(tf.keras.layers.Flatten(input_shape=(14, 56)))
for layer in loaded_model.layers[1:]:
  new_model.add(layer)

As you are changing one of the layer, you need to train the model again to get the updated weights. Before training, you need to compile the model and then train. You could also freeze the layers and fine tune the model.