Update the input of model(output of one model as input to another model) in a loop

Trying to get the execution time of each layer of a model. When I call intermediate_model error is raised.

input =Input((10,))
def profiling(model, test_input):
    # output_of_all_layers = []
    for layer in model.layers:
        layer = layer(next_layer)
        intermediate_moddel= keras.Model(layer,x)
        start = time.time()
        intermediate_output = intermediate_layer.predict(test_input)
        end = time.time() - start
result = profiling(model,features)

Hi Ash,

you landed in the PyTorch forum, so you might want to post this Keras question in their discussion board or on StackOverflow, where you’ll most likely get a better answer. :wink:

Thanks for your response