Home > Net >  Custom layer misses input on plot_model
Custom layer misses input on plot_model

Time:02-11

I'm following this tutorial enter image description here

Apprently from the tutorial code LogisticEndpoint takes two input, namely the return value of dense and targets. However in the plot, a link from target:InputLayer to predictions:LogisticEndpoint is missing.

How would I revise the tutorial code so that plot is correct?

CodePudding user response:

Inputs to your custom layer should be a list/tuple for two input tensors and not two separate inputs. Check the enter image description here

CodePudding user response:

Your logits are only taking the input. You are not putting in the targets for the network to consider it as a layer. You can concatenate them, and that will make them show up in the plot_model function.

inputs = keras.Input(shape=(3,), name="inputs")
targets = keras.Input(shape=(10,), name="targets")
concat = tf.keras.layers.Concatenate()([inputs, targets])
logits = keras.layers.Dense(10)(concat)

Result: enter image description here

  • Related