Skip to content

Commit 4d570a1

Browse files
committed
Perform ReLU inplace
1 parent 2a3a733 commit 4d570a1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

torchvision/models/unet.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
def double_conv(in_channels, out_channels):
99
return nn.Sequential(
1010
nn.Conv2d(in_channels, out_channels, 3),
11-
nn.ReLU(),
11+
nn.ReLU(inplace=True),
1212
nn.Conv2d(out_channels, out_channels, 3),
13-
nn.ReLU()
13+
nn.ReLU(inplace=True)
1414
)
1515

1616

@@ -52,7 +52,7 @@ def __init__(self, in_channels, out_channels):
5252
assert in_channels > out_channels
5353

5454
self.upconv = nn.ConvTranspose2d(in_channels, out_channels, 2, 2)
55-
self.relu = nn.ReLU()
55+
self.relu = nn.ReLU(inplace=True)
5656
self.conv = double_conv(in_channels, out_channels)
5757

5858
def forward(self, x, out):

0 commit comments

Comments
 (0)