I got an Xception model.
JavaScript
x
2
1
Xception = tf.keras.applications.Xception(input_shape=(512, 512, 3), include_top=False)
2
I have combined the model to change the Input Channel to 3.
JavaScript
1
6
1
input_layer = keras.Input(shape=(512, 512, 1), name="img_input")
2
x = layers.UpSampling3D(size=(1, 1, 3), name="output")(input_layer)
3
input_model = keras.Model(input_layer, x, name="input_model")
4
5
model = keras.Model(input_model, Xception, name="model")
6
however I have got error
JavaScript
1
2
1
Input tensors to a Functional must come from `tf.keras.Input`. Received: <tensorflow.python.keras.engine.functional.Functional object at 0x7f922942a690> (missing previous layer metadata).
2
Advertisement
Answer
You simply have to embed Xception
in the correct way in your new model:
JavaScript
1
8
1
Xception = tf.keras.applications.Xception(input_shape=(512, 512, 3), include_top=False)
2
3
input_layer = tf.keras.Input(shape=(512, 512, 1), name="img_input")
4
x = tf.keras.layers.UpSampling3D(size=(1, 1, 3), name="upsampling")(input_layer)
5
output = Xception(x)
6
7
model = tf.keras.Model(input_layer, output, name="model")
8
We create a new Input
layer, than we operate upsampling and in the end we pass all to Xception
Here is the running notebook if you are interested