How to use Batch normalization in testing model

yichuan9527: Do I get the right understand?

apaszke: 

yichuan9527: OK， I understand. Thank you very much！

apaszke: 

apaszke: No. It’s never recommended to reuse the same Variables between iterations. This will likely lead to graphs growing indefinitely and increasing memory usage. Just recreate them every time, it’s extremely cheap to do.

smth: What I did in the WassersteinGAN code is not an optimal approach, i have to fix that code (will do now).

apaszke: 

apaszke: 

smth: 

smth: 

mderakhshani: <SCODE>YoloV2 (
  (path1): ModuleList (
    (0): Conv2d(3, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
    (1): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True)
    (2): LeakyReLU (0.1)
    (3): MaxPool2d (size=(2, 2), stride=(2, 2), dilation=(1, 1))
    (4): Conv2d(32, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
    (5): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True)
    (6): LeakyReLU (0.1)
    (7): MaxPool2d (size=(2, 2), stride=(2, 2), dilation=(1, 1))
    (8): Conv2d(64, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
    (9): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True)
    (10): LeakyReLU (0.1)
    (11): Conv2d(128, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)
    (12): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True)
    (13): LeakyReLU (0.1)
    (14): Conv2d(64, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
    (15): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True)
    (16): LeakyReLU (0.1)
    (17): MaxPool2d (size=(2, 2), stride=(2, 2), dilation=(1, 1))
    (18): Conv2d(128, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
    (19): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True)
    (20): LeakyReLU (0.1)
    (21): Conv2d(256, 128, kernel_size=(1, 1), stride=(1, 1), bias=False)
    (22): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True)
    (23): LeakyReLU (0.1)
    (24): Conv2d(128, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
    (25): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True)
    (26): LeakyReLU (0.1)
    (27): MaxPool2d (size=(2, 2), stride=(2, 2), dilation=(1, 1))
    (28): Conv2d(256, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
    (29): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True)
    (30): LeakyReLU (0.1)
    (31): Conv2d(512, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)
    (32): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True)
    (33): LeakyReLU (0.1)
    (34): Conv2d(256, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
    (35): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True)
    (36): LeakyReLU (0.1)
    (37): Conv2d(512, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)
    (38): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True)
    (39): LeakyReLU (0.1)
    (40): Conv2d(256, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
    (41): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True)
    (42): LeakyReLU (0.1)
  )
  (parallel1): ModuleList (
    (0): MaxPool2d (size=(2, 2), stride=(2, 2), dilation=(1, 1))
    (1): Conv2d(512, 1024, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
    (2): BatchNorm2d(1024, eps=1e-05, momentum=0.1, affine=True)
    (3): LeakyReLU (0.1)
    (4): Conv2d(1024, 512, kernel_size=(1, 1), stride=(1, 1), bias=False)
    (5): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True)
    (6): LeakyReLU (0.1)
    (7): Conv2d(512, 1024, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
    (8): BatchNorm2d(1024, eps=1e-05, momentum=0.1, affine=True)
    (9): LeakyReLU (0.1)
    (10): Conv2d(1024, 512, kernel_size=(1, 1), stride=(1, 1), bias=False)
    (11): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True)
    (12): LeakyReLU (0.1)
    (13): Conv2d(512, 1024, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
    (14): BatchNorm2d(1024, eps=1e-05, momentum=0.1, affine=True)
    (15): LeakyReLU (0.1)
    (16): Conv2d(1024, 1024, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
    (17): BatchNorm2d(1024, eps=1e-05, momentum=0.1, affine=True)
    (18): LeakyReLU (0.1)
    (19): Conv2d(1024, 1024, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
    (20): BatchNorm2d(1024, eps=1e-05, momentum=0.1, affine=True)
    (21): LeakyReLU (0.1)
  )
  (parallel2): ModuleList (
    (0): Conv2d(512, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)
    (1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True)
    (2): LeakyReLU (0.1)
    (3): space_to_depth (
    )
  )
  (path2): ModuleList (
    (0): Conv2d(1280, 1024, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
    (1): BatchNorm2d(1024, eps=1e-05, momentum=0.1, affine=True)
    (2): LeakyReLU (0.1)
    (3): Conv2d(1024, 425, kernel_size=(1, 1), stride=(1, 1), bias=False)
  )
)
<ECODE>