Skip to content

Commit 74d04d2

Browse files
orashisoumith
authored andcommitted
Change division style to prevent error in python3 (#127)
Using python2 style '/' will convert int type to float in python3 which will cause the following error when creating FloatTensor: TypeError: torch.FloatTensor constructor received an invalid combination of arguments - got (float, int, int, int), but expected one of: * no arguments * (int ...) didn't match because some of the arguments have invalid types: (float, int, int, int)
1 parent 8f6b9df commit 74d04d2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

torchvision/models/densenet.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ def __init__(self, growth_rate=32, block_config=(6, 12, 24, 16),
139139
self.features.add_module('denseblock%d' % (i + 1), block)
140140
num_features = num_features + num_layers * growth_rate
141141
if i != len(block_config) - 1:
142-
trans = _Transition(num_input_features=num_features, num_output_features=num_features / 2)
142+
trans = _Transition(num_input_features=num_features, num_output_features=num_features // 2)
143143
self.features.add_module('transition%d' % (i + 1), trans)
144-
num_features = num_features / 2
144+
num_features = num_features // 2
145145

146146
# Final batch norm
147147
self.features.add_module('norm5', nn.BatchNorm2d(num_features))

0 commit comments

Comments
 (0)