How can I change this code in pytorch form?Do we have Input layer in pytorch?

def build_densenet():
densenet = DenseNet121(weights=‘imagenet’, include_top=False)

input = Input(shape=(SIZE, SIZE, N_ch))
x = Conv2D(3, (3, 3), padding='same')(input)

x = densenet(x)

x = GlobalAveragePooling2D()(x)
x = BatchNormalization()(x)
x = Dropout(0.5)(x)
x = Dense(256, activation='relu')(x)
x = BatchNormalization()(x)
x = Dropout(0.5)(x)

# multi output
output = Dense(2,activation = 'softmax', name='root')(x)

# model
model = Model(input,output)

No, you don’t need to define input layers and can directly pass a tensor to the model.
Take a look at this tutorial for an example of a simple neural network.

thanks for replying, the other question is: we don’t have to change the output of denesnet121 when we pass it to GlobalAveragePooling2D()?