I want a Keras model which always outputs a constant value of a desired output shape.
def build_model(input_shape, output_shape) input = tf.keras.layers.Input(shape=(512,512,3)) x = tf.keras.backend.constant(1, shape=output_shape) output = tf.keras.layers.Lambda(lambda x: x)(x) model = Model(inputs=input, outputs=output) return model model = build_model((512,512,3), (512,512,32))
I get the following error:
Output tensors to a Model must be the output of a TensorFlow
Layer (thus holding past layer metadata). Found: Tensor("Const_3:0", shape=(512, 512, 32), dtype=float32)
How can I fix it?
Input and output are indeed not connected. I want to test the performance of my processing pipeline with the lowest GPU load possible. I think that always outputting the same value without doing any computations won't use the GPU much. But I still make sure that my data is properly loaded (input layer).