[Python] How do I print the model summary in PyTorch?

Discussão em 'Python' iniciado por Stack, Maio 15, 2025.

  1. Stack

    Stack Membro Participativo

    How do I print the summary of a model in PyTorch like what model.summary() does in Keras:

    Model Summary:
    ____________________________________________________________________________________________________
    Layer (type) Output Shape Param # Connected to
    ====================================================================================================
    input_1 (InputLayer) (None, 1, 15, 27) 0
    ____________________________________________________________________________________________________
    convolution2d_1 (Convolution2D) (None, 8, 15, 27) 872 input_1[0][0]
    ____________________________________________________________________________________________________
    maxpooling2d_1 (MaxPooling2D) (None, 8, 7, 27) 0 convolution2d_1[0][0]
    ____________________________________________________________________________________________________
    flatten_1 (Flatten) (None, 1512) 0 maxpooling2d_1[0][0]
    ____________________________________________________________________________________________________
    dense_1 (Dense) (None, 1) 1513 flatten_1[0][0]
    ====================================================================================================
    Total params: 2,385
    Trainable params: 2,385
    Non-trainable params: 0

    Continue reading...

Compartilhe esta Página