going beyond the sequential modelthe keras functional api dense layers dense( activation='relu'output_tensor dense(input_tensora layer is function layer may be called on tensorand it returns tensor let' start with minimal example that shows side by side simple sequential model and its equivalent in the functional apifrom keras models import sequentialmodel from keras import layers from keras import input sequential modelwhich you already know about seq_model sequential(seq_model add(layers dense( activation='relu'input_shape=( ,))seq_model add(layers dense( activation='relu')seq_model add(layers dense( activation='softmax')input_tensor input(shape=( ,) layers dense( activation='relu')(input_tensorx layers dense( activation='relu')(xoutput_tensor layers dense( activation='softmax')(xmodel model(input_tensoroutput_tensormodel summary(let' look at itits functional equivalent the model class turns an input tensor and output tensor into model this is what the call to model summary(displayslayer (typeoutput shape param ================================================================input_ (inputlayer(none dense_ (dense(none dense_ (dense(none dense_ (dense(none ================================================================total params , trainable params , non-trainable params the only part that may seem bit magical at this point is instantiating model object using only an input tensor and an output tensor behind the sceneskeras retrieves every layer involved in going from input_tensor to output_tensorbringing them together into graph-like data structure-- model of coursethe reason it works is that output_tensor was obtained by repeatedly transforming input_tensor if you tried to build model from inputs and outputs that weren' relatedyou' get runtimeerrorunrelated_input input(shape=( ,)bad_model model model(unrelated_inputoutput_tensorlicensed to