Skip to content

When does X go on the outside of a layer versus the inside? #196

Answered by mrdbourke
JoshK68 asked this question in Q&A
Discussion options

You must be logged in to vote

Inside

If it's a model (tf.keras.Model), the x goes on the inside.

For example,

import tensorflow as tf
model = tf.keras.applications.EfficientNetB0(include_top=False) # <- this is a model
model.trainable = False
x = tf.keras.layers.Input(shape=(224, 224, 3), name="input_layer")
x = model(x) # <- inside

Outside

If it's a layer (tf.keras.layers.Layer), the x goes on the outside.

For exmaple,

import tensorflow as tf
model = tf.keras.applications.EfficientNetB0(include_top=False)
model.trainable = False
inputs = tf.keras.layers.Input(shape=(224, 224, 3), name="input_layer")
x = model(inputs)
x = tf.keras.layers.GlobalAveragePooling2D()(x) # <- outside, since it's a layer

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@JoshK68
Comment options

Answer selected by JoshK68
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants