CNN计算Params和FLOPs的三种方式

1. 使用thop库
安装

pip install thop

举个例子

import cycle_generator0609
import torch
from thop import profile

model = cycle_generator0609.Generator(3, 3, 64)  # 自己的网络和参数
inputs = torch.randn(1, 3, 256, 256)  # input 输入
flops, params = profile(model, (inputs,))
print('flops: ', flops)
print('params: ', params)

输出为

D:\Anaconda3\envs\paddlepaddle\python.exe C:/Users/64883/Desktop/cycle_code/flops.py
[INFO] Register count_convNd() for <class 'torch.nn.modules.conv.Conv2d'>.
[INFO] Register count_normalization() for <class 'torch.nn.modules.batchnorm.BatchNorm2d'>.
[INFO] Register count_relu() for <class 'torch.nn.modules.activation.LeakyReLU'>.
[INFO] Register zero_ops() for <class 'torch.nn.modules.container.Sequential'>.
[INFO] Register zero_ops() for <class 'torch.nn.modules.pooling.MaxPool2d'>.
[INFO] Register count_normalization() for <class 'torch.nn.modules.instancenorm.InstanceNorm2d'>.
[INFO] Register count_convNd() for <class 'torch.nn.modules.conv.Conv1d'>.
[INFO] Register count_normalization() for <class 'torch.nn.modules.batchnorm.BatchNorm1d'>.
D:\Anaconda3\envs\paddlepaddle\lib\site-packages\torch\nn\functional.py:718: UserWarning: Named tensors and all their associated APIs are an experimental feature and subject to change. Please do not use them for anything important until they are released as stable. (Triggered internally at  ..\c10/core/TensorImpl.h:1156.)
  return torch.max_pool2d(input, kernel_size, stride, padding, dilation, ceil_mode)
torch.Size([1, 512, 32, 32]) torch.Size([1, 256, 64, 64])
flops:  40880313600.0
params:  7699107.0

2. 使用ptflops库
安装

pip install ptflops

举个例子

import cycle_generator0609
import torch
from ptflops import get_model_complexity_info

with torch.cuda.device(0):
  net = cycle_generator0609.Generator(3, 3, 64)  # 自己的网络和参数
  flops, params = get_model_complexity_info(net, (3, 256, 256), as_strings=True, print_per_layer_stat=True, verbose=True)
  print('Flops:  ', flops)
  print('Params: ', params)

输出为

Generator(
  7.7 M, 100.000% Params, 40.91 GMac, 100.000% MACs, 
  (rfrm1): RFRM(
    6.56 k, 0.085% Params, 434.11 MMac, 1.061% MACs, 
    (conv1): ConvINLReLU(
      160, 0.002% Params, 12.58 MMac, 0.031% MACs, 
      (conv_layer): Sequential(
        160, 0.002% Params, 12.58 MMac, 0.031% MACs, 
        (0): Conv2d(96, 0.001% Params, 6.29 MMac, 0.015% MACs, 3, 32, kernel_size=(1, 1), stride=(1, 1), bias=False)
        (1): BatchNorm2d(64, 0.001% Params, 4.19 MMac, 0.010% MACs, 32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        (2): LeakyReLU(0, 0.000% Params, 2.1 MMac, 0.005% MACs, negative_slope=0.2, inplace=True)
      )
    )
    (conv2): ConvINLReLU(
      4.64 k, 0.060% Params, 305.14 MMac, 0.746% MACs, 
      (conv_layer): Sequential(
        4.64 k, 0.060% Params, 305.14 MMac, 0.746% MACs, 
        (0): Conv2d(4.61 k, 0.060% Params, 301.99 MMac, 0.738% MACs, 32, 16, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (1): BatchNorm2d(32, 0.000% Params, 2.1 MMac, 0.005% MACs, 16, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        (2): LeakyReLU(0, 0.000% Params, 1.05 MMac, 0.003% MACs, negative_slope=0.2, inplace=True)
      )
    )
    (conv3): ConvINLReLU(
      1.17 k, 0.015% Params, 77.07 MMac, 0.188% MACs, 
      (conv_layer): Sequential(
        1.17 k, 0.015% Params, 77.07 MMac, 0.188% MACs, 
        (0): Conv2d(1.15 k, 0.015% Params, 75.5 MMac, 0.185% MACs, 16, 8, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (1): BatchNorm2d(16, 0.000% Params, 1.05 MMac, 0.003% MACs, 8, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        (2): LeakyReLU(0, 0.000% Params, 524.29 KMac, 0.001% MACs, negative_slope=0.2, inplace=True)
      )
    )
    (conv4): ConvINLReLU(
      592, 0.008% Params, 39.32 MMac, 0.096% MACs, 
      (conv_layer): Sequential(
        592, 0.008% Params, 39.32 MMac, 0.096% MACs, 
        (0): Conv2d(576, 0.007% Params, 37.75 MMac, 0.092% MACs, 8, 8, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (1): BatchNorm2d(16, 0.000% Params, 1.05 MMac, 0.003% MACs, 8, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        (2): LeakyReLU(0, 0.000% Params, 524.29 KMac, 0.001% MACs, negative_slope=0.2, inplace=True)
      )
    )
  )
  (eb1): EncoderBlock(
    45.44 k, 0.590% Params, 1.17 GMac, 2.865% MACs, 
    (rfrm): RFRM(
      8.51 k, 0.111% Params, 562.04 MMac, 1.374% MACs, 
      (conv1): ConvINLReLU(
        2.11 k, 0.027% Params, 140.51 MMac, 0.343% MACs, 
        (conv_layer): Sequential(
          2.11 k, 0.027% Params, 140.51 MMac, 0.343% MACs, 
          (0): Conv2d(2.05 k, 0.027% Params, 134.22 MMac, 0.328% MACs, 64, 32, kernel_size=(1, 1), stride=(1, 1), bias=False)
          (1): BatchNorm2d(64, 0.001% Params, 4.19 MMac, 0.010% MACs, 32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (2): LeakyReLU(0, 0.000% Params, 2.1 MMac, 0.005% MACs, negative_slope=0.2, inplace=True)
        )
      )
      (conv2): ConvINLReLU(
        4.64 k, 0.060% Params, 305.14 MMac, 0.746% MACs, 
        (conv_layer): Sequential(
          4.64 k, 0.060% Params, 305.14 MMac, 0.746% MACs, 
          (0): Conv2d(4.61 k, 0.060% Params, 301.99 MMac, 0.738% MACs, 32, 16, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (1): BatchNorm2d(32, 0.000% Params, 2.1 MMac, 0.005% MACs, 16, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (2): LeakyReLU(0, 0.000% Params, 1.05 MMac, 0.003% MACs, negative_slope=0.2, inplace=True)
        )
      )
      (conv3): ConvINLReLU(
        1.17 k, 0.015% Params, 77.07 MMac, 0.188% MACs, 
        (conv_layer): Sequential(
          1.17 k, 0.015% Params, 77.07 MMac, 0.188% MACs, 
          (0): Conv2d(1.15 k, 0.015% Params, 75.5 MMac, 0.185% MACs, 16, 8, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (1): BatchNorm2d(16, 0.000% Params, 1.05 MMac, 0.003% MACs, 8, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (2): LeakyReLU(0, 0.000% Params, 524.29 KMac, 0.001% MACs, negative_slope=0.2, inplace=True)
        )
      )
      (conv4): ConvINLReLU(
        592, 0.008% Params, 39.32 MMac, 0.096% MACs, 
        (conv_layer): Sequential(
          592, 0.008% Params, 39.32 MMac, 0.096% MACs, 
          (0): Conv2d(576, 0.007% Params, 37.75 MMac, 0.092% MACs, 8, 8, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (1): BatchNorm2d(16, 0.000% Params, 1.05 MMac, 0.003% MACs, 8, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (2): LeakyReLU(0, 0.000% Params, 524.29 KMac, 0.001% MACs, negative_slope=0.2, inplace=True)
        )
      )
    )
    (dsm): DSM(
      36.93 k, 0.480% Params, 610.27 MMac, 1.492% MACs, 
      (down): MaxPool2d(0, 0.000% Params, 4.19 MMac, 0.010% MACs, kernel_size=3, stride=2, padding=1, dilation=1, ceil_mode=False)
      (conv): ConvLReLU(
        36.93 k, 0.480% Params, 606.08 MMac, 1.481% MACs, 
        (conv_layer): Sequential(
          36.93 k, 0.480% Params, 606.08 MMac, 1.481% MACs, 
          (0): Conv2d(36.93 k, 0.480% Params, 605.03 MMac, 1.479% MACs, 64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (1): LeakyReLU(0, 0.000% Params, 1.05 MMac, 0.003% MACs, negative_slope=0.2, inplace=True)
        )
      )
    )
  )
  (eb2): EncoderBlock(
    177.28 k, 2.303% Params, 1.1 GMac, 2.678% MACs, 
    (rfrm): RFRM(
      29.7 k, 0.386% Params, 488.64 MMac, 1.194% MACs, 
      (conv1): ConvINLReLU(
        4.22 k, 0.055% Params, 70.25 MMac, 0.172% MACs, 
        (conv_layer): Sequential(
          4.22 k, 0.055% Params, 70.25 MMac, 0.172% MACs, 
          (0): Conv2d(4.1 k, 0.053% Params, 67.11 MMac, 0.164% MACs, 64, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)
          (1): BatchNorm2d(128, 0.002% Params, 2.1 MMac, 0.005% MACs, 64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (2): LeakyReLU(0, 0.000% Params, 1.05 MMac, 0.003% MACs, negative_slope=0.2, inplace=True)
        )
      )
      (conv2): ConvINLReLU(
        18.5 k, 0.240% Params, 303.56 MMac, 0.742% MACs, 
        (conv_layer): Sequential(
          18.5 k, 0.240% Params, 303.56 MMac, 0.742% MACs, 
          (0): Conv2d(18.43 k, 0.239% Params, 301.99 MMac, 0.738% MACs, 64, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (1): BatchNorm2d(64, 0.001% Params, 1.05 MMac, 0.003% MACs, 32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (2): LeakyReLU(0, 0.000% Params, 524.29 KMac, 0.001% MACs, negative_slope=0.2, inplace=True)
        )
      )
      (conv3): ConvINLReLU(
        4.64 k, 0.060% Params, 76.28 MMac, 0.186% MACs, 
        (conv_layer): Sequential(
          4.64 k, 0.060% Params, 76.28 MMac, 0.186% MACs, 
          (0): Conv2d(4.61 k, 0.060% Params, 75.5 MMac, 0.185% MACs, 32, 16, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (1): BatchNorm2d(32, 0.000% Params, 524.29 KMac, 0.001% MACs, 16, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (2): LeakyReLU(0, 0.000% Params, 262.14 KMac, 0.001% MACs, negative_slope=0.2, inplace=True)
        )
      )
      (conv4): ConvINLReLU(
        2.34 k, 0.030% Params, 38.54 MMac, 0.094% MACs, 
        (conv_layer): Sequential(
          2.34 k, 0.030% Params, 38.54 MMac, 0.094% MACs, 
          (0): Conv2d(2.3 k, 0.030% Params, 37.75 MMac, 0.092% MACs, 16, 16, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (1): BatchNorm2d(32, 0.000% Params, 524.29 KMac, 0.001% MACs, 16, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (2): LeakyReLU(0, 0.000% Params, 262.14 KMac, 0.001% MACs, negative_slope=0.2, inplace=True)
        )
      )
    )
    (dsm): DSM(
      147.58 k, 1.917% Params, 607.13 MMac, 1.484% MACs, 
      (down): MaxPool2d(0, 0.000% Params, 2.1 MMac, 0.005% MACs, kernel_size=3, stride=2, padding=1, dilation=1, ceil_mode=False)
      (conv): ConvLReLU(
        147.58 k, 1.917% Params, 605.03 MMac, 1.479% MACs, 
        (conv_layer): Sequential(
          147.58 k, 1.917% Params, 605.03 MMac, 1.479% MACs, 
          (0): Conv2d(147.58 k, 1.917% Params, 604.5 MMac, 1.478% MACs, 128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (1): LeakyReLU(0, 0.000% Params, 524.29 KMac, 0.001% MACs, negative_slope=0.2, inplace=True)
        )
      )
    )
  )
  (eb3): EncoderBlock(
    708.35 k, 9.200% Params, 1.09 GMac, 2.667% MACs, 
    (rfrm): RFRM(
      118.27 k, 1.536% Params, 485.49 MMac, 1.187% MACs, 
      (conv1): ConvINLReLU(
        16.64 k, 0.216% Params, 68.68 MMac, 0.168% MACs, 
        (conv_layer): Sequential(
          16.64 k, 0.216% Params, 68.68 MMac, 0.168% MACs, 
          (0): Conv2d(16.38 k, 0.213% Params, 67.11 MMac, 0.164% MACs, 128, 128, kernel_size=(1, 1), stride=(1, 1), bias=False)
          (1): BatchNorm2d(256, 0.003% Params, 1.05 MMac, 0.003% MACs, 128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (2): LeakyReLU(0, 0.000% Params, 524.29 KMac, 0.001% MACs, negative_slope=0.2, inplace=True)
        )
      )
      (conv2): ConvINLReLU(
        73.86 k, 0.959% Params, 302.78 MMac, 0.740% MACs, 
        (conv_layer): Sequential(
          73.86 k, 0.959% Params, 302.78 MMac, 0.740% MACs, 
          (0): Conv2d(73.73 k, 0.958% Params, 301.99 MMac, 0.738% MACs, 128, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (1): BatchNorm2d(128, 0.002% Params, 524.29 KMac, 0.001% MACs, 64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (2): LeakyReLU(0, 0.000% Params, 262.14 KMac, 0.001% MACs, negative_slope=0.2, inplace=True)
        )
      )
      (conv3): ConvINLReLU(
        18.5 k, 0.240% Params, 75.89 MMac, 0.186% MACs, 
        (conv_layer): Sequential(
          18.5 k, 0.240% Params, 75.89 MMac, 0.186% MACs, 
          (0): Conv2d(18.43 k, 0.239% Params, 75.5 MMac, 0.185% MACs, 64, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (1): BatchNorm2d(64, 0.001% Params, 262.14 KMac, 0.001% MACs, 32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (2): LeakyReLU(0, 0.000% Params, 131.07 KMac, 0.000% MACs, negative_slope=0.2, inplace=True)
        )
      )
      (conv4): ConvINLReLU(
        9.28 k, 0.121% Params, 38.14 MMac, 0.093% MACs, 
        (conv_layer): Sequential(
          9.28 k, 0.121% Params, 38.14 MMac, 0.093% MACs, 
          (0): Conv2d(9.22 k, 0.120% Params, 37.75 MMac, 0.092% MACs, 32, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (1): BatchNorm2d(64, 0.001% Params, 262.14 KMac, 0.001% MACs, 32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (2): LeakyReLU(0, 0.000% Params, 131.07 KMac, 0.000% MACs, negative_slope=0.2, inplace=True)
        )
      )
    )
    (dsm): DSM(
      590.08 k, 7.664% Params, 605.55 MMac, 1.480% MACs, 
      (down): MaxPool2d(0, 0.000% Params, 1.05 MMac, 0.003% MACs, kernel_size=3, stride=2, padding=1, dilation=1, ceil_mode=False)
      (conv): ConvLReLU(
        590.08 k, 7.664% Params, 604.5 MMac, 1.478% MACs, 
        (conv_layer): Sequential(
          590.08 k, 7.664% Params, 604.5 MMac, 1.478% MACs, 
          (0): Conv2d(590.08 k, 7.664% Params, 604.24 MMac, 1.477% MACs, 256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (1): LeakyReLU(0, 0.000% Params, 262.14 KMac, 0.001% MACs, negative_slope=0.2, inplace=True)
        )
      )
    )
  )
  (rfrm2): RFRM(
    472.06 k, 6.131% Params, 483.92 MMac, 1.183% MACs, 
    (conv1): ConvINLReLU(
      66.05 k, 0.858% Params, 67.9 MMac, 0.166% MACs, 
      (conv_layer): Sequential(
        66.05 k, 0.858% Params, 67.9 MMac, 0.166% MACs, 
        (0): Conv2d(65.54 k, 0.851% Params, 67.11 MMac, 0.164% MACs, 256, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)
        (1): BatchNorm2d(512, 0.007% Params, 524.29 KMac, 0.001% MACs, 256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        (2): LeakyReLU(0, 0.000% Params, 262.14 KMac, 0.001% MACs, negative_slope=0.2, inplace=True)
      )
    )
    (conv2): ConvINLReLU(
      295.17 k, 3.834% Params, 302.38 MMac, 0.739% MACs, 
      (conv_layer): Sequential(
        295.17 k, 3.834% Params, 302.38 MMac, 0.739% MACs, 
        (0): Conv2d(294.91 k, 3.830% Params, 301.99 MMac, 0.738% MACs, 256, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (1): BatchNorm2d(256, 0.003% Params, 262.14 KMac, 0.001% MACs, 128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        (2): LeakyReLU(0, 0.000% Params, 131.07 KMac, 0.000% MACs, negative_slope=0.2, inplace=True)
      )
    )
    (conv3): ConvINLReLU(
      73.86 k, 0.959% Params, 75.69 MMac, 0.185% MACs, 
      (conv_layer): Sequential(
        73.86 k, 0.959% Params, 75.69 MMac, 0.185% MACs, 
        (0): Conv2d(73.73 k, 0.958% Params, 75.5 MMac, 0.185% MACs, 128, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (1): BatchNorm2d(128, 0.002% Params, 131.07 KMac, 0.000% MACs, 64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        (2): LeakyReLU(0, 0.000% Params, 65.54 KMac, 0.000% MACs, negative_slope=0.2, inplace=True)
      )
    )
    (conv4): ConvINLReLU(
      36.99 k, 0.480% Params, 37.95 MMac, 0.093% MACs, 
      (conv_layer): Sequential(
        36.99 k, 0.480% Params, 37.95 MMac, 0.093% MACs, 
        (0): Conv2d(36.86 k, 0.479% Params, 37.75 MMac, 0.092% MACs, 64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (1): BatchNorm2d(128, 0.002% Params, 131.07 KMac, 0.000% MACs, 64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        (2): LeakyReLU(0, 0.000% Params, 65.54 KMac, 0.000% MACs, negative_slope=0.2, inplace=True)
      )
    )
  )
  (ftm): FTM(
    2.88 M, 37.472% Params, 2.49 GMac, 6.078% MACs, 
    (conv1): ConvLReLU(
      65.66 k, 0.853% Params, 263.17 KMac, 0.001% MACs, 
      (conv_layer): Sequential(
        65.66 k, 0.853% Params, 263.17 KMac, 0.001% MACs, 
        (0): Conv2d(65.66 k, 0.853% Params, 262.66 KMac, 0.001% MACs, 512, 128, kernel_size=(1, 1), stride=(1, 1))
        (1): LeakyReLU(0, 0.000% Params, 512.0 Mac, 0.000% MACs, negative_slope=0.2, inplace=True)
      )
    )
    (conv2): ConvLReLU(
      65.66 k, 0.853% Params, 263.17 KMac, 0.001% MACs, 
      (conv_layer): Sequential(
        65.66 k, 0.853% Params, 263.17 KMac, 0.001% MACs, 
        (0): Conv2d(65.66 k, 0.853% Params, 262.66 KMac, 0.001% MACs, 512, 128, kernel_size=(1, 1), stride=(1, 1))
        (1): LeakyReLU(0, 0.000% Params, 512.0 Mac, 0.000% MACs, negative_slope=0.2, inplace=True)
      )
    )
    (conv3): ConvLReLU(
      65.66 k, 0.853% Params, 1.05 MMac, 0.003% MACs, 
      (conv_layer): Sequential(
        65.66 k, 0.853% Params, 1.05 MMac, 0.003% MACs, 
        (0): Conv2d(65.66 k, 0.853% Params, 1.05 MMac, 0.003% MACs, 512, 128, kernel_size=(1, 1), stride=(1, 1))
        (1): LeakyReLU(0, 0.000% Params, 2.05 KMac, 0.000% MACs, negative_slope=0.2, inplace=True)
      )
    )
    (conv4): ConvLReLU(
      262.66 k, 3.412% Params, 263.17 KMac, 0.001% MACs, 
      (conv_layer): Sequential(
        262.66 k, 3.412% Params, 263.17 KMac, 0.001% MACs, 
        (0): Conv2d(262.66 k, 3.412% Params, 262.66 KMac, 0.001% MACs, 512, 512, kernel_size=(1, 1), stride=(1, 1))
        (1): LeakyReLU(0, 0.000% Params, 512.0 Mac, 0.000% MACs, negative_slope=0.2, inplace=True)
      )
    )
    (dconv1): DConvINLReLU(
      589.82 k, 7.661% Params, 604.24 MMac, 1.477% MACs, 
      (dblock): Sequential(
        589.82 k, 7.661% Params, 604.24 MMac, 1.477% MACs, 
        (0): Conv2d(589.82 k, 7.661% Params, 603.98 MMac, 1.476% MACs, 512, 128, kernel_size=(3, 3), stride=(1, 1), padding=(3, 3), dilation=(3, 3), bias=False)
        (1): InstanceNorm2d(0, 0.000% Params, 131.07 KMac, 0.000% MACs, 128, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False)
        (2): LeakyReLU(0, 0.000% Params, 131.07 KMac, 0.000% MACs, negative_slope=0.2, inplace=True)
      )
    )
    (dconv2): DConvINLReLU(
      589.82 k, 7.661% Params, 604.24 MMac, 1.477% MACs, 
      (dblock): Sequential(
        589.82 k, 7.661% Params, 604.24 MMac, 1.477% MACs, 
        (0): Conv2d(589.82 k, 7.661% Params, 603.98 MMac, 1.476% MACs, 512, 128, kernel_size=(3, 3), stride=(1, 1), padding=(6, 6), dilation=(6, 6), bias=False)
        (1): InstanceNorm2d(0, 0.000% Params, 131.07 KMac, 0.000% MACs, 128, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False)
        (2): LeakyReLU(0, 0.000% Params, 131.07 KMac, 0.000% MACs, negative_slope=0.2, inplace=True)
      )
    )
    (dconv3): DConvINLReLU(
      589.82 k, 7.661% Params, 604.24 MMac, 1.477% MACs, 
      (dblock): Sequential(
        589.82 k, 7.661% Params, 604.24 MMac, 1.477% MACs, 
        (0): Conv2d(589.82 k, 7.661% Params, 603.98 MMac, 1.476% MACs, 512, 128, kernel_size=(3, 3), stride=(1, 1), padding=(9, 9), dilation=(9, 9), bias=False)
        (1): InstanceNorm2d(0, 0.000% Params, 131.07 KMac, 0.000% MACs, 128, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False)
        (2): LeakyReLU(0, 0.000% Params, 131.07 KMac, 0.000% MACs, negative_slope=0.2, inplace=True)
      )
    )
    (conv5): ConvLReLU(
      655.87 k, 8.519% Params, 672.14 MMac, 1.643% MACs, 
      (conv_layer): Sequential(
        655.87 k, 8.519% Params, 672.14 MMac, 1.643% MACs, 
        (0): Conv2d(655.87 k, 8.519% Params, 671.61 MMac, 1.642% MACs, 1280, 512, kernel_size=(1, 1), stride=(1, 1))
        (1): LeakyReLU(0, 0.000% Params, 524.29 KMac, 0.001% MACs, negative_slope=0.2, inplace=True)
      )
    )
  )
  (db1): DecoderBlock(
    2.56 M, 33.277% Params, 10.49 GMac, 25.638% MACs, 
    (usm): USM(
      2.36 M, 30.650% Params, 9.67 GMac, 23.631% MACs, 
      (conv): ConvLReLU(
        2.36 M, 30.650% Params, 9.67 GMac, 23.631% MACs, 
        (conv_layer): Sequential(
          2.36 M, 30.650% Params, 9.67 GMac, 23.631% MACs, 
          (0): Conv2d(2.36 M, 30.650% Params, 9.67 GMac, 23.626% MACs, 512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (1): LeakyReLU(0, 0.000% Params, 2.1 MMac, 0.005% MACs, negative_slope=0.2, inplace=True)
        )
      )
    )
    (crm): CRM(
      2.05 k, 0.027% Params, 2.05 KMac, 0.000% MACs, 
      (conv1d): Conv1d(1.02 k, 0.013% Params, 1.02 KMac, 0.000% MACs, 512, 512, kernel_size=(2,), stride=(1,), groups=512, bias=False)
      (bn): BatchNorm1d(1.02 k, 0.013% Params, 1.02 KMac, 0.000% MACs, 512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
    )
    (rfrm): RFRM(
      200.19 k, 2.600% Params, 821.04 MMac, 2.007% MACs, 
      (conv1): ConvINLReLU(
        98.56 k, 1.280% Params, 404.23 MMac, 0.988% MACs, 
        (conv_layer): Sequential(
          98.56 k, 1.280% Params, 404.23 MMac, 0.988% MACs, 
          (0): Conv2d(98.3 k, 1.277% Params, 402.65 MMac, 0.984% MACs, 768, 128, kernel_size=(1, 1), stride=(1, 1), bias=False)
          (1): BatchNorm2d(256, 0.003% Params, 1.05 MMac, 0.003% MACs, 128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (2): LeakyReLU(0, 0.000% Params, 524.29 KMac, 0.001% MACs, negative_slope=0.2, inplace=True)
        )
      )
      (conv2): ConvINLReLU(
        73.86 k, 0.959% Params, 302.78 MMac, 0.740% MACs, 
        (conv_layer): Sequential(
          73.86 k, 0.959% Params, 302.78 MMac, 0.740% MACs, 
          (0): Conv2d(73.73 k, 0.958% Params, 301.99 MMac, 0.738% MACs, 128, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (1): BatchNorm2d(128, 0.002% Params, 524.29 KMac, 0.001% MACs, 64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (2): LeakyReLU(0, 0.000% Params, 262.14 KMac, 0.001% MACs, negative_slope=0.2, inplace=True)
        )
      )
      (conv3): ConvINLReLU(
        18.5 k, 0.240% Params, 75.89 MMac, 0.186% MACs, 
        (conv_layer): Sequential(
          18.5 k, 0.240% Params, 75.89 MMac, 0.186% MACs, 
          (0): Conv2d(18.43 k, 0.239% Params, 75.5 MMac, 0.185% MACs, 64, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (1): BatchNorm2d(64, 0.001% Params, 262.14 KMac, 0.001% MACs, 32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (2): LeakyReLU(0, 0.000% Params, 131.07 KMac, 0.000% MACs, negative_slope=0.2, inplace=True)
        )
      )
      (conv4): ConvINLReLU(
        9.28 k, 0.121% Params, 38.14 MMac, 0.093% MACs, 
        (conv_layer): Sequential(
          9.28 k, 0.121% Params, 38.14 MMac, 0.093% MACs, 
          (0): Conv2d(9.22 k, 0.120% Params, 37.75 MMac, 0.092% MACs, 32, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (1): BatchNorm2d(64, 0.001% Params, 262.14 KMac, 0.001% MACs, 32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (2): LeakyReLU(0, 0.000% Params, 131.07 KMac, 0.000% MACs, negative_slope=0.2, inplace=True)
        )
      )
    )
  )
  (db2): DecoderBlock(
    641.28 k, 8.329% Params, 10.5 GMac, 25.656% MACs, 
    (usm): USM(
      590.08 k, 7.664% Params, 9.67 GMac, 23.642% MACs, 
      (conv): ConvLReLU(
        590.08 k, 7.664% Params, 9.67 GMac, 23.642% MACs, 
        (conv_layer): Sequential(
          590.08 k, 7.664% Params, 9.67 GMac, 23.642% MACs, 
          (0): Conv2d(590.08 k, 7.664% Params, 9.67 GMac, 23.631% MACs, 256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (1): LeakyReLU(0, 0.000% Params, 4.19 MMac, 0.010% MACs, negative_slope=0.2, inplace=True)
        )
      )
    )
    (crm): CRM(
      1.02 k, 0.013% Params, 1.02 KMac, 0.000% MACs, 
      (conv1d): Conv1d(512, 0.007% Params, 512.0 Mac, 0.000% MACs, 256, 256, kernel_size=(2,), stride=(1,), groups=256, bias=False)
      (bn): BatchNorm1d(512, 0.007% Params, 512.0 Mac, 0.000% MACs, 256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
    )
    (rfrm): RFRM(
      50.18 k, 0.652% Params, 824.18 MMac, 2.015% MACs, 
      (conv1): ConvINLReLU(
        24.7 k, 0.321% Params, 405.8 MMac, 0.992% MACs, 
        (conv_layer): Sequential(
          24.7 k, 0.321% Params, 405.8 MMac, 0.992% MACs, 
          (0): Conv2d(24.58 k, 0.319% Params, 402.65 MMac, 0.984% MACs, 384, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)
          (1): BatchNorm2d(128, 0.002% Params, 2.1 MMac, 0.005% MACs, 64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (2): LeakyReLU(0, 0.000% Params, 1.05 MMac, 0.003% MACs, negative_slope=0.2, inplace=True)
        )
      )
      (conv2): ConvINLReLU(
        18.5 k, 0.240% Params, 303.56 MMac, 0.742% MACs, 
        (conv_layer): Sequential(
          18.5 k, 0.240% Params, 303.56 MMac, 0.742% MACs, 
          (0): Conv2d(18.43 k, 0.239% Params, 301.99 MMac, 0.738% MACs, 64, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (1): BatchNorm2d(64, 0.001% Params, 1.05 MMac, 0.003% MACs, 32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (2): LeakyReLU(0, 0.000% Params, 524.29 KMac, 0.001% MACs, negative_slope=0.2, inplace=True)
        )
      )
      (conv3): ConvINLReLU(
        4.64 k, 0.060% Params, 76.28 MMac, 0.186% MACs, 
        (conv_layer): Sequential(
          4.64 k, 0.060% Params, 76.28 MMac, 0.186% MACs, 
          (0): Conv2d(4.61 k, 0.060% Params, 75.5 MMac, 0.185% MACs, 32, 16, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (1): BatchNorm2d(32, 0.000% Params, 524.29 KMac, 0.001% MACs, 16, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (2): LeakyReLU(0, 0.000% Params, 262.14 KMac, 0.001% MACs, negative_slope=0.2, inplace=True)
        )
      )
      (conv4): ConvINLReLU(
        2.34 k, 0.030% Params, 38.54 MMac, 0.094% MACs, 
        (conv_layer): Sequential(
          2.34 k, 0.030% Params, 38.54 MMac, 0.094% MACs, 
          (0): Conv2d(2.3 k, 0.030% Params, 37.75 MMac, 0.092% MACs, 16, 16, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (1): BatchNorm2d(32, 0.000% Params, 524.29 KMac, 0.001% MACs, 16, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (2): LeakyReLU(0, 0.000% Params, 262.14 KMac, 0.001% MACs, negative_slope=0.2, inplace=True)
        )
      )
    )
  )
  (db3): DecoderBlock(
    160.7 k, 2.087% Params, 10.51 GMac, 25.692% MACs, 
    (usm): USM(
      147.58 k, 1.917% Params, 9.68 GMac, 23.662% MACs, 
      (conv): ConvLReLU(
        147.58 k, 1.917% Params, 9.68 GMac, 23.662% MACs, 
        (conv_layer): Sequential(
          147.58 k, 1.917% Params, 9.68 GMac, 23.662% MACs, 
          (0): Conv2d(147.58 k, 1.917% Params, 9.67 GMac, 23.642% MACs, 128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
          (1): LeakyReLU(0, 0.000% Params, 8.39 MMac, 0.021% MACs, negative_slope=0.2, inplace=True)
        )
      )
    )
    (crm): CRM(
      512, 0.007% Params, 512.0 Mac, 0.000% MACs, 
      (conv1d): Conv1d(256, 0.003% Params, 256.0 Mac, 0.000% MACs, 128, 128, kernel_size=(2,), stride=(1,), groups=128, bias=False)
      (bn): BatchNorm1d(256, 0.003% Params, 256.0 Mac, 0.000% MACs, 128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
    )
    (rfrm): RFRM(
      12.61 k, 0.164% Params, 830.47 MMac, 2.030% MACs, 
      (conv1): ConvINLReLU(
        6.21 k, 0.081% Params, 408.94 MMac, 1.000% MACs, 
        (conv_layer): Sequential(
          6.21 k, 0.081% Params, 408.94 MMac, 1.000% MACs, 
          (0): Conv2d(6.14 k, 0.080% Params, 402.65 MMac, 0.984% MACs, 192, 32, kernel_size=(1, 1), stride=(1, 1), bias=False)
          (1): BatchNorm2d(64, 0.001% Params, 4.19 MMac, 0.010% MACs, 32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (2): LeakyReLU(0, 0.000% Params, 2.1 MMac, 0.005% MACs, negative_slope=0.2, inplace=True)
        )
      )
      (conv2): ConvINLReLU(
        4.64 k, 0.060% Params, 305.14 MMac, 0.746% MACs, 
        (conv_layer): Sequential(
          4.64 k, 0.060% Params, 305.14 MMac, 0.746% MACs, 
          (0): Conv2d(4.61 k, 0.060% Params, 301.99 MMac, 0.738% MACs, 32, 16, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (1): BatchNorm2d(32, 0.000% Params, 2.1 MMac, 0.005% MACs, 16, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (2): LeakyReLU(0, 0.000% Params, 1.05 MMac, 0.003% MACs, negative_slope=0.2, inplace=True)
        )
      )
      (conv3): ConvINLReLU(
        1.17 k, 0.015% Params, 77.07 MMac, 0.188% MACs, 
        (conv_layer): Sequential(
          1.17 k, 0.015% Params, 77.07 MMac, 0.188% MACs, 
          (0): Conv2d(1.15 k, 0.015% Params, 75.5 MMac, 0.185% MACs, 16, 8, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (1): BatchNorm2d(16, 0.000% Params, 1.05 MMac, 0.003% MACs, 8, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (2): LeakyReLU(0, 0.000% Params, 524.29 KMac, 0.001% MACs, negative_slope=0.2, inplace=True)
        )
      )
      (conv4): ConvINLReLU(
        592, 0.008% Params, 39.32 MMac, 0.096% MACs, 
        (conv_layer): Sequential(
          592, 0.008% Params, 39.32 MMac, 0.096% MACs, 
          (0): Conv2d(576, 0.007% Params, 37.75 MMac, 0.092% MACs, 8, 8, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (1): BatchNorm2d(16, 0.000% Params, 1.05 MMac, 0.003% MACs, 8, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (2): LeakyReLU(0, 0.000% Params, 524.29 KMac, 0.001% MACs, negative_slope=0.2, inplace=True)
        )
      )
    )
  )
  (conv1): ConvLReLU(
    36.93 k, 0.480% Params, 2.42 GMac, 5.926% MACs, 
    (conv_layer): Sequential(
      36.93 k, 0.480% Params, 2.42 GMac, 5.926% MACs, 
      (0): Conv2d(36.93 k, 0.480% Params, 2.42 GMac, 5.916% MACs, 64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
      (1): LeakyReLU(0, 0.000% Params, 4.19 MMac, 0.010% MACs, negative_slope=0.2, inplace=True)
    )
  )
  (conv2): ConvLReLU(
    3.46 k, 0.045% Params, 226.89 MMac, 0.555% MACs, 
    (conv_layer): Sequential(
      3.46 k, 0.045% Params, 226.89 MMac, 0.555% MACs, 
      (0): Conv2d(3.46 k, 0.045% Params, 226.69 MMac, 0.554% MACs, 128, 3, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
      (1): LeakyReLU(0, 0.000% Params, 196.61 KMac, 0.000% MACs, negative_slope=0.2, inplace=True)
    )
  )
  (tanh): Tanh(0, 0.000% Params, 0.0 Mac, 0.000% MACs, )
)
Flops:   40.91 GMac
Params:  7.7 M

3. 使用ptflops库
安装

pip install torchstat

举个例子

from torchstat import stat
import cycle_generator0609
net = cycle_generator0609.Generator(3, 3, 64)
stat(net, (3, 256, 256))    # 输入图片的尺寸

输出为

                       module name   input shape output shape     params memory(MB)              MAdd             Flops  MemRead(B)  MemWrite(B) duration[%]     MemR+W(B)
0         rfrm1.conv1.conv_layer.0     3 256 256   32 256 256       96.0       8.00      10,485,760.0       6,291,456.0    786816.0    8388608.0       1.43%  9.175424e+06
1         rfrm1.conv1.conv_layer.1    32 256 256   32 256 256       64.0       8.00       8,388,608.0       4,194,304.0   8388864.0    8388608.0       0.57%  1.677747e+07
2         rfrm1.conv1.conv_layer.2    32 256 256   32 256 256        0.0       8.00               0.0       2,097,152.0   8388608.0    8388608.0       0.57%  1.677722e+07
3         rfrm1.conv2.conv_layer.0    32 256 256   16 256 256     4608.0       4.00     602,931,200.0     301,989,888.0   8407040.0    4194304.0       1.15%  1.260134e+07
4         rfrm1.conv2.conv_layer.1    16 256 256   16 256 256       32.0       4.00       4,194,304.0       2,097,152.0   4194432.0    4194304.0       0.29%  8.388736e+06
5         rfrm1.conv2.conv_layer.2    16 256 256   16 256 256        0.0       4.00               0.0       1,048,576.0   4194304.0    4194304.0       0.29%  8.388608e+06
6         rfrm1.conv3.conv_layer.0    16 256 256    8 256 256     1152.0       2.00     150,470,656.0      75,497,472.0   4198912.0    2097152.0       0.57%  6.296064e+06
7         rfrm1.conv3.conv_layer.1     8 256 256    8 256 256       16.0       2.00       2,097,152.0       1,048,576.0   2097216.0    2097152.0       0.29%  4.194368e+06
8         rfrm1.conv3.conv_layer.2     8 256 256    8 256 256        0.0       2.00               0.0         524,288.0   2097152.0    2097152.0       0.00%  4.194304e+06
9         rfrm1.conv4.conv_layer.0     8 256 256    8 256 256      576.0       2.00      74,973,184.0      37,748,736.0   2099456.0    2097152.0       0.57%  4.196608e+06
10        rfrm1.conv4.conv_layer.1     8 256 256    8 256 256       16.0       2.00       2,097,152.0       1,048,576.0   2097216.0    2097152.0       0.29%  4.194368e+06
11        rfrm1.conv4.conv_layer.2     8 256 256    8 256 256        0.0       2.00               0.0         524,288.0   2097152.0    2097152.0       0.00%  4.194304e+06
12     eb1.rfrm.conv1.conv_layer.0    64 256 256   32 256 256     2048.0       8.00     266,338,304.0     134,217,728.0  16785408.0    8388608.0       2.01%  2.517402e+07
13     eb1.rfrm.conv1.conv_layer.1    32 256 256   32 256 256       64.0       8.00       8,388,608.0       4,194,304.0   8388864.0    8388608.0       0.57%  1.677747e+07
14     eb1.rfrm.conv1.conv_layer.2    32 256 256   32 256 256        0.0       8.00               0.0       2,097,152.0   8388608.0    8388608.0       0.29%  1.677722e+07
15     eb1.rfrm.conv2.conv_layer.0    32 256 256   16 256 256     4608.0       4.00     602,931,200.0     301,989,888.0   8407040.0    4194304.0       0.86%  1.260134e+07
16     eb1.rfrm.conv2.conv_layer.1    16 256 256   16 256 256       32.0       4.00       4,194,304.0       2,097,152.0   4194432.0    4194304.0       0.57%  8.388736e+06
17     eb1.rfrm.conv2.conv_layer.2    16 256 256   16 256 256        0.0       4.00               0.0       1,048,576.0   4194304.0    4194304.0       0.30%  8.388608e+06
18     eb1.rfrm.conv3.conv_layer.0    16 256 256    8 256 256     1152.0       2.00     150,470,656.0      75,497,472.0   4198912.0    2097152.0       0.56%  6.296064e+06
19     eb1.rfrm.conv3.conv_layer.1     8 256 256    8 256 256       16.0       2.00       2,097,152.0       1,048,576.0   2097216.0    2097152.0       0.29%  4.194368e+06
20     eb1.rfrm.conv3.conv_layer.2     8 256 256    8 256 256        0.0       2.00               0.0         524,288.0   2097152.0    2097152.0       0.00%  4.194304e+06
21     eb1.rfrm.conv4.conv_layer.0     8 256 256    8 256 256      576.0       2.00      74,973,184.0      37,748,736.0   2099456.0    2097152.0       0.57%  4.196608e+06
22     eb1.rfrm.conv4.conv_layer.1     8 256 256    8 256 256       16.0       2.00       2,097,152.0       1,048,576.0   2097216.0    2097152.0       0.00%  4.194368e+06
23     eb1.rfrm.conv4.conv_layer.2     8 256 256    8 256 256        0.0       2.00               0.0         524,288.0   2097152.0    2097152.0       0.00%  4.194304e+06
24                    eb1.dsm.down    64 256 256   64 128 128        0.0       4.00       8,388,608.0       4,194,304.0  16777216.0    4194304.0       2.01%  2.097152e+07
25       eb1.dsm.conv.conv_layer.0    64 128 128   64 128 128    36928.0       4.00   1,207,959,552.0     605,028,352.0   4342016.0    4194304.0       1.43%  8.536320e+06
26       eb1.dsm.conv.conv_layer.1    64 128 128   64 128 128        0.0       4.00               0.0       1,048,576.0   4194304.0    4194304.0       0.29%  8.388608e+06
27     eb2.rfrm.conv1.conv_layer.0    64 128 128   64 128 128     4096.0       4.00     133,169,152.0      67,108,864.0   4210688.0    4194304.0       0.57%  8.404992e+06
28     eb2.rfrm.conv1.conv_layer.1    64 128 128   64 128 128      128.0       4.00       4,194,304.0       2,097,152.0   4194816.0    4194304.0       0.57%  8.389120e+06
29     eb2.rfrm.conv1.conv_layer.2    64 128 128   64 128 128        0.0       4.00               0.0       1,048,576.0   4194304.0    4194304.0       0.00%  8.388608e+06
30     eb2.rfrm.conv2.conv_layer.0    64 128 128   32 128 128    18432.0       2.00     603,455,488.0     301,989,888.0   4268032.0    2097152.0       0.86%  6.365184e+06
31     eb2.rfrm.conv2.conv_layer.1    32 128 128   32 128 128       64.0       2.00       2,097,152.0       1,048,576.0   2097408.0    2097152.0       0.29%  4.194560e+06
32     eb2.rfrm.conv2.conv_layer.2    32 128 128   32 128 128        0.0       2.00               0.0         524,288.0   2097152.0    2097152.0       0.00%  4.194304e+06
33     eb2.rfrm.conv3.conv_layer.0    32 128 128   16 128 128     4608.0       1.00     150,732,800.0      75,497,472.0   2115584.0    1048576.0       0.57%  3.164160e+06
34     eb2.rfrm.conv3.conv_layer.1    16 128 128   16 128 128       32.0       1.00       1,048,576.0         524,288.0   1048704.0    1048576.0       0.00%  2.097280e+06
35     eb2.rfrm.conv3.conv_layer.2    16 128 128   16 128 128        0.0       1.00               0.0         262,144.0   1048576.0    1048576.0       0.00%  2.097152e+06
36     eb2.rfrm.conv4.conv_layer.0    16 128 128   16 128 128     2304.0       1.00      75,235,328.0      37,748,736.0   1057792.0    1048576.0       0.29%  2.106368e+06
37     eb2.rfrm.conv4.conv_layer.1    16 128 128   16 128 128       32.0       1.00       1,048,576.0         524,288.0   1048704.0    1048576.0       0.00%  2.097280e+06
38     eb2.rfrm.conv4.conv_layer.2    16 128 128   16 128 128        0.0       1.00               0.0         262,144.0   1048576.0    1048576.0       0.00%  2.097152e+06
39                    eb2.dsm.down   128 128 128  128  64  64        0.0       2.00       4,194,304.0       2,097,152.0   8388608.0    2097152.0       0.86%  1.048576e+07
40       eb2.dsm.conv.conv_layer.0   128  64  64  128  64  64   147584.0       2.00   1,207,959,552.0     604,504,064.0   2687488.0    2097152.0       1.15%  4.784640e+06
41       eb2.dsm.conv.conv_layer.1   128  64  64  128  64  64        0.0       2.00               0.0         524,288.0   2097152.0    2097152.0       0.00%  4.194304e+06
42     eb3.rfrm.conv1.conv_layer.0   128  64  64  128  64  64    16384.0       2.00     133,693,440.0      67,108,864.0   2162688.0    2097152.0       0.57%  4.259840e+06
43     eb3.rfrm.conv1.conv_layer.1   128  64  64  128  64  64      256.0       2.00       2,097,152.0       1,048,576.0   2098176.0    2097152.0       0.29%  4.195328e+06
44     eb3.rfrm.conv1.conv_layer.2   128  64  64  128  64  64        0.0       2.00               0.0         524,288.0   2097152.0    2097152.0       0.00%  4.194304e+06
45     eb3.rfrm.conv2.conv_layer.0   128  64  64   64  64  64    73728.0       1.00     603,717,632.0     301,989,888.0   2392064.0    1048576.0       0.86%  3.440640e+06
46     eb3.rfrm.conv2.conv_layer.1    64  64  64   64  64  64      128.0       1.00       1,048,576.0         524,288.0   1049088.0    1048576.0       0.00%  2.097664e+06
47     eb3.rfrm.conv2.conv_layer.2    64  64  64   64  64  64        0.0       1.00               0.0         262,144.0   1048576.0    1048576.0       0.00%  2.097152e+06
48     eb3.rfrm.conv3.conv_layer.0    64  64  64   32  64  64    18432.0       0.50     150,863,872.0      75,497,472.0   1122304.0     524288.0       0.29%  1.646592e+06
49     eb3.rfrm.conv3.conv_layer.1    32  64  64   32  64  64       64.0       0.50         524,288.0         262,144.0    524544.0     524288.0       0.00%  1.048832e+06
50     eb3.rfrm.conv3.conv_layer.2    32  64  64   32  64  64        0.0       0.50               0.0         131,072.0    524288.0     524288.0       0.00%  1.048576e+06
51     eb3.rfrm.conv4.conv_layer.0    32  64  64   32  64  64     9216.0       0.50      75,366,400.0      37,748,736.0    561152.0     524288.0       0.29%  1.085440e+06
52     eb3.rfrm.conv4.conv_layer.1    32  64  64   32  64  64       64.0       0.50         524,288.0         262,144.0    524544.0     524288.0       0.00%  1.048832e+06
53     eb3.rfrm.conv4.conv_layer.2    32  64  64   32  64  64        0.0       0.50               0.0         131,072.0    524288.0     524288.0       0.00%  1.048576e+06
54                    eb3.dsm.down   256  64  64  256  32  32        0.0       1.00       2,097,152.0       1,048,576.0   4194304.0    1048576.0       0.29%  5.242880e+06
55       eb3.dsm.conv.conv_layer.0   256  32  32  256  32  32   590080.0       1.00   1,207,959,552.0     604,241,920.0   3408896.0    1048576.0       0.86%  4.457472e+06
56       eb3.dsm.conv.conv_layer.1   256  32  32  256  32  32        0.0       1.00               0.0         262,144.0   1048576.0    1048576.0       0.00%  2.097152e+06
57        rfrm2.conv1.conv_layer.0   256  32  32  256  32  32    65536.0       1.00     133,955,584.0      67,108,864.0   1310720.0    1048576.0       0.29%  2.359296e+06
58        rfrm2.conv1.conv_layer.1   256  32  32  256  32  32      512.0       1.00       1,048,576.0         524,288.0   1050624.0    1048576.0       0.00%  2.099200e+06
59        rfrm2.conv1.conv_layer.2   256  32  32  256  32  32        0.0       1.00               0.0         262,144.0   1048576.0    1048576.0       0.29%  2.097152e+06
60        rfrm2.conv2.conv_layer.0   256  32  32  128  32  32   294912.0       0.50     603,848,704.0     301,989,888.0   2228224.0     524288.0       0.57%  2.752512e+06
61        rfrm2.conv2.conv_layer.1   128  32  32  128  32  32      256.0       0.50         524,288.0         262,144.0    525312.0     524288.0       0.00%  1.049600e+06
62        rfrm2.conv2.conv_layer.2   128  32  32  128  32  32        0.0       0.50               0.0         131,072.0    524288.0     524288.0       0.00%  1.048576e+06
63        rfrm2.conv3.conv_layer.0   128  32  32   64  32  32    73728.0       0.25     150,929,408.0      75,497,472.0    819200.0     262144.0       0.29%  1.081344e+06
64        rfrm2.conv3.conv_layer.1    64  32  32   64  32  32      128.0       0.25         262,144.0         131,072.0    262656.0     262144.0       0.00%  5.248000e+05
65        rfrm2.conv3.conv_layer.2    64  32  32   64  32  32        0.0       0.25               0.0          65,536.0    262144.0     262144.0       0.29%  5.242880e+05
66        rfrm2.conv4.conv_layer.0    64  32  32   64  32  32    36864.0       0.25      75,431,936.0      37,748,736.0    409600.0     262144.0       0.00%  6.717440e+05
67        rfrm2.conv4.conv_layer.1    64  32  32   64  32  32      128.0       0.25         262,144.0         131,072.0    262656.0     262144.0       0.00%  5.248000e+05
68        rfrm2.conv4.conv_layer.2    64  32  32   64  32  32        0.0       0.25               0.0          65,536.0    262144.0     262144.0       0.29%  5.242880e+05
69          ftm.conv1.conv_layer.0   512   2   2  128   2   2    65664.0       0.00         524,288.0         262,656.0    270848.0       2048.0       0.29%  2.728960e+05
70          ftm.conv1.conv_layer.1   128   2   2  128   2   2        0.0       0.00               0.0             512.0      2048.0       2048.0       0.00%  4.096000e+03
71          ftm.conv2.conv_layer.0   512   2   2  128   2   2    65664.0       0.00         524,288.0         262,656.0    270848.0       2048.0       0.29%  2.728960e+05
72          ftm.conv2.conv_layer.1   128   2   2  128   2   2        0.0       0.00               0.0             512.0      2048.0       2048.0       0.00%  4.096000e+03
73          ftm.conv3.conv_layer.0   512   4   4  128   4   4    65664.0       0.01       2,097,152.0       1,050,624.0    295424.0       8192.0       0.00%  3.036160e+05
74          ftm.conv3.conv_layer.1   128   4   4  128   4   4        0.0       0.01               0.0           2,048.0      8192.0       8192.0       0.00%  1.638400e+04
75          ftm.conv4.conv_layer.0   512   1   1  512   1   1   262656.0       0.00         524,288.0         262,656.0   1052672.0       2048.0       0.29%  1.054720e+06
76          ftm.conv4.conv_layer.1   512   1   1  512   1   1        0.0       0.00               0.0             512.0      2048.0       2048.0       0.00%  4.096000e+03
77             ftm.dconv1.dblock.0   512  32  32  128  32  32   589824.0       0.50   1,207,828,480.0     603,979,776.0   4456448.0     524288.0       1.15%  4.980736e+06
78             ftm.dconv1.dblock.1   128  32  32  128  32  32        0.0       0.50               0.0               0.0         0.0          0.0       0.00%  0.000000e+00
79             ftm.dconv1.dblock.2   128  32  32  128  32  32        0.0       0.50               0.0         131,072.0    524288.0     524288.0       0.00%  1.048576e+06
80             ftm.dconv2.dblock.0   512  32  32  128  32  32   589824.0       0.50   1,207,828,480.0     603,979,776.0   4456448.0     524288.0       4.58%  4.980736e+06
81             ftm.dconv2.dblock.1   128  32  32  128  32  32        0.0       0.50               0.0               0.0         0.0          0.0       0.00%  0.000000e+00
82             ftm.dconv2.dblock.2   128  32  32  128  32  32        0.0       0.50               0.0         131,072.0    524288.0     524288.0       0.00%  1.048576e+06
83             ftm.dconv3.dblock.0   512  32  32  128  32  32   589824.0       0.50   1,207,828,480.0     603,979,776.0   4456448.0     524288.0       1.15%  4.980736e+06
84             ftm.dconv3.dblock.1   128  32  32  128  32  32        0.0       0.50               0.0               0.0         0.0          0.0       0.00%  0.000000e+00
85             ftm.dconv3.dblock.2   128  32  32  128  32  32        0.0       0.50               0.0         131,072.0    524288.0     524288.0       0.00%  1.048576e+06
86          ftm.conv5.conv_layer.0  1280  32  32  512  32  32   655872.0       2.00   1,342,177,280.0     671,612,928.0   7866368.0    2097152.0       1.15%  9.963520e+06
87          ftm.conv5.conv_layer.1   512  32  32  512  32  32        0.0       2.00               0.0         524,288.0   2097152.0    2097152.0       0.00%  4.194304e+06
88       db1.usm.conv.conv_layer.0   512  64  64  512  64  64  2359808.0       8.00  19,327,352,832.0   9,665,773,568.0  17827840.0    8388608.0      10.60%  2.621645e+07
89       db1.usm.conv.conv_layer.1   512  64  64  512  64  64        0.0       8.00               0.0       2,097,152.0   8388608.0    8388608.0       0.00%  1.677722e+07
90                  db1.crm.conv1d       512   2      512   1     1024.0       0.00               0.0               0.0         0.0          0.0       0.00%  0.000000e+00
91                      db1.crm.bn       512   1      512   1     1024.0       0.00               0.0               0.0         0.0          0.0       0.00%  0.000000e+00
92     db1.rfrm.conv1.conv_layer.0   768  64  64  128  64  64    98304.0       2.00     804,782,080.0     402,653,184.0  12976128.0    2097152.0       1.43%  1.507328e+07
93     db1.rfrm.conv1.conv_layer.1   128  64  64  128  64  64      256.0       2.00       2,097,152.0       1,048,576.0   2098176.0    2097152.0       0.29%  4.195328e+06
94     db1.rfrm.conv1.conv_layer.2   128  64  64  128  64  64        0.0       2.00               0.0         524,288.0   2097152.0    2097152.0       0.00%  4.194304e+06
95     db1.rfrm.conv2.conv_layer.0   128  64  64   64  64  64    73728.0       1.00     603,717,632.0     301,989,888.0   2392064.0    1048576.0       1.15%  3.440640e+06
96     db1.rfrm.conv2.conv_layer.1    64  64  64   64  64  64      128.0       1.00       1,048,576.0         524,288.0   1049088.0    1048576.0       0.00%  2.097664e+06
97     db1.rfrm.conv2.conv_layer.2    64  64  64   64  64  64        0.0       1.00               0.0         262,144.0   1048576.0    1048576.0       0.00%  2.097152e+06
98     db1.rfrm.conv3.conv_layer.0    64  64  64   32  64  64    18432.0       0.50     150,863,872.0      75,497,472.0   1122304.0     524288.0       0.29%  1.646592e+06
99     db1.rfrm.conv3.conv_layer.1    32  64  64   32  64  64       64.0       0.50         524,288.0         262,144.0    524544.0     524288.0       0.00%  1.048832e+06
100    db1.rfrm.conv3.conv_layer.2    32  64  64   32  64  64        0.0       0.50               0.0         131,072.0    524288.0     524288.0       0.00%  1.048576e+06
101    db1.rfrm.conv4.conv_layer.0    32  64  64   32  64  64     9216.0       0.50      75,366,400.0      37,748,736.0    561152.0     524288.0       0.29%  1.085440e+06
102    db1.rfrm.conv4.conv_layer.1    32  64  64   32  64  64       64.0       0.50         524,288.0         262,144.0    524544.0     524288.0       0.00%  1.048832e+06
103    db1.rfrm.conv4.conv_layer.2    32  64  64   32  64  64        0.0       0.50               0.0         131,072.0    524288.0     524288.0       0.00%  1.048576e+06
104      db2.usm.conv.conv_layer.0   256 128 128  256 128 128   590080.0      16.00  19,327,352,832.0   9,667,870,720.0  19137536.0   16777216.0      12.32%  3.591475e+07
105      db2.usm.conv.conv_layer.1   256 128 128  256 128 128        0.0      16.00               0.0       4,194,304.0  16777216.0   16777216.0       0.29%  3.355443e+07
106                 db2.crm.conv1d       256   2      256   1      512.0       0.00               0.0               0.0         0.0          0.0       0.00%  0.000000e+00
107                     db2.crm.bn       256   1      256   1      512.0       0.00               0.0               0.0         0.0          0.0       0.00%  0.000000e+00
108    db2.rfrm.conv1.conv_layer.0   384 128 128   64 128 128    24576.0       4.00     804,257,792.0     402,653,184.0  25264128.0    4194304.0       2.58%  2.945843e+07
109    db2.rfrm.conv1.conv_layer.1    64 128 128   64 128 128      128.0       4.00       4,194,304.0       2,097,152.0   4194816.0    4194304.0       0.29%  8.389120e+06
110    db2.rfrm.conv1.conv_layer.2    64 128 128   64 128 128        0.0       4.00               0.0       1,048,576.0   4194304.0    4194304.0       0.00%  8.388608e+06
111    db2.rfrm.conv2.conv_layer.0    64 128 128   32 128 128    18432.0       2.00     603,455,488.0     301,989,888.0   4268032.0    2097152.0       0.57%  6.365184e+06
112    db2.rfrm.conv2.conv_layer.1    32 128 128   32 128 128       64.0       2.00       2,097,152.0       1,048,576.0   2097408.0    2097152.0       0.29%  4.194560e+06
113    db2.rfrm.conv2.conv_layer.2    32 128 128   32 128 128        0.0       2.00               0.0         524,288.0   2097152.0    2097152.0       0.00%  4.194304e+06
114    db2.rfrm.conv3.conv_layer.0    32 128 128   16 128 128     4608.0       1.00     150,732,800.0      75,497,472.0   2115584.0    1048576.0       0.57%  3.164160e+06
115    db2.rfrm.conv3.conv_layer.1    16 128 128   16 128 128       32.0       1.00       1,048,576.0         524,288.0   1048704.0    1048576.0       0.00%  2.097280e+06
116    db2.rfrm.conv3.conv_layer.2    16 128 128   16 128 128        0.0       1.00               0.0         262,144.0   1048576.0    1048576.0       0.00%  2.097152e+06
117    db2.rfrm.conv4.conv_layer.0    16 128 128   16 128 128     2304.0       1.00      75,235,328.0      37,748,736.0   1057792.0    1048576.0       0.29%  2.106368e+06
118    db2.rfrm.conv4.conv_layer.1    16 128 128   16 128 128       32.0       1.00       1,048,576.0         524,288.0   1048704.0    1048576.0       0.29%  2.097280e+06
119    db2.rfrm.conv4.conv_layer.2    16 128 128   16 128 128        0.0       1.00               0.0         262,144.0   1048576.0    1048576.0       0.00%  2.097152e+06
120      db3.usm.conv.conv_layer.0   128 256 256  128 256 256   147584.0      32.00  19,327,352,832.0   9,672,065,024.0  34144768.0   33554432.0      13.18%  6.769920e+07
121      db3.usm.conv.conv_layer.1   128 256 256  128 256 256        0.0      32.00               0.0       8,388,608.0  33554432.0   33554432.0       0.86%  6.710886e+07
122                 db3.crm.conv1d       128   2      128   1      256.0       0.00               0.0               0.0         0.0          0.0       0.00%  0.000000e+00
123                     db3.crm.bn       128   1      128   1      256.0       0.00               0.0               0.0         0.0          0.0       0.29%  0.000000e+00
124    db3.rfrm.conv1.conv_layer.0   192 256 256   32 256 256     6144.0       8.00     803,209,216.0     402,653,184.0  50356224.0    8388608.0       5.44%  5.874483e+07
125    db3.rfrm.conv1.conv_layer.1    32 256 256   32 256 256       64.0       8.00       8,388,608.0       4,194,304.0   8388864.0    8388608.0       0.57%  1.677747e+07
126    db3.rfrm.conv1.conv_layer.2    32 256 256   32 256 256        0.0       8.00               0.0       2,097,152.0   8388608.0    8388608.0       0.29%  1.677722e+07
127    db3.rfrm.conv2.conv_layer.0    32 256 256   16 256 256     4608.0       4.00     602,931,200.0     301,989,888.0   8407040.0    4194304.0       1.43%  1.260134e+07
128    db3.rfrm.conv2.conv_layer.1    16 256 256   16 256 256       32.0       4.00       4,194,304.0       2,097,152.0   4194432.0    4194304.0       0.29%  8.388736e+06
129    db3.rfrm.conv2.conv_layer.2    16 256 256   16 256 256        0.0       4.00               0.0       1,048,576.0   4194304.0    4194304.0       0.29%  8.388608e+06
130    db3.rfrm.conv3.conv_layer.0    16 256 256    8 256 256     1152.0       2.00     150,470,656.0      75,497,472.0   4198912.0    2097152.0       0.57%  6.296064e+06
131    db3.rfrm.conv3.conv_layer.1     8 256 256    8 256 256       16.0       2.00       2,097,152.0       1,048,576.0   2097216.0    2097152.0       0.29%  4.194368e+06
132    db3.rfrm.conv3.conv_layer.2     8 256 256    8 256 256        0.0       2.00               0.0         524,288.0   2097152.0    2097152.0       0.00%  4.194304e+06
133    db3.rfrm.conv4.conv_layer.0     8 256 256    8 256 256      576.0       2.00      74,973,184.0      37,748,736.0   2099456.0    2097152.0       0.57%  4.196608e+06
134    db3.rfrm.conv4.conv_layer.1     8 256 256    8 256 256       16.0       2.00       2,097,152.0       1,048,576.0   2097216.0    2097152.0       0.29%  4.194368e+06
135    db3.rfrm.conv4.conv_layer.2     8 256 256    8 256 256        0.0       2.00               0.0         524,288.0   2097152.0    2097152.0       0.29%  4.194304e+06
136             conv1.conv_layer.0    64 256 256   64 256 256    36928.0      16.00   4,831,838,208.0   2,420,113,408.0  16924928.0   16777216.0       4.87%  3.370214e+07
137             conv1.conv_layer.1    64 256 256   64 256 256        0.0      16.00               0.0       4,194,304.0  16777216.0   16777216.0       0.29%  3.355443e+07
138             conv2.conv_layer.0   128 256 256    3 256 256     3459.0       0.75     452,984,832.0     226,689,024.0  33568268.0     786432.0       3.44%  3.435470e+07
139             conv2.conv_layer.1     3 256 256    3 256 256        0.0       0.75               0.0         196,608.0    786432.0     786432.0       0.00%  1.572864e+06
140                           tanh     3 256 256    3 256 256        0.0       0.75               0.0               0.0         0.0          0.0       0.00%  0.000000e+00
total                                                          7699107.0     397.78  81,676,337,152.0  40,910,724,096.0         0.0          0.0     100.00%  1.026237e+09
==========================================================================================================================================================================
Total params: 7,699,107
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total memory: 397.78MB
Total MAdd: 81.68GMAdd
Total Flops: 40.91GFlops
Total MemR+W: 978.7MB

【Total params】网络的整体参数量
【Total memory】模型进行推理时候所需的内存
【Total Flops】网络完成的浮点运算
【Total MAdd】网络完成的乘加操作的数量。
一次乘加=一次乘法+一次加法,可以大致认为(Flops ≈2* MAdd)
【MemR+W】MemR+W = MemRead + MemWrite
(MemRead:网络运行时,从内存中读取的大小)
(MemWrite:网络运行时,写入到内存中的大小)

参考链接1
参考链接2

你可能感兴趣的:(cnn,python,人工智能)