hello everyone, i found a bug about nn.Sequential
function:
i write my network:
convs = nn.Sequential(
nn.Conv1d(512, 64, 3, stride=1, padding=1),
nn.ReLU(),
nn.BatchNorm1d(64),
nn.Conv1d(64, 64, 3, stride=1, padding=1),
nn.ReLU(),
nn.BatchNorm1d(64)
)
the input matrix dimension is (80, 512, 33)
, there is an error which is :
RuntimeError: expected 3D tensor
however, if i use OrderedDict
in Sequential
and all other codes are the same, which is as follows, it works :
convs = nn.Sequential(
OrderedDict([
('conv1', nn.Conv1d(512, 64, 3, stride=1, padding=1)),
('relu1', nn.ReLU()),
('batchnorm1', nn.BatchNorm1d(64)),
('conv2', nn.Conv1d(64, 64, 3, stride=1, padding=1)),
('relu2', nn.ReLU()),
('batchnorm2', nn.BatchNorm1d(64))
])
)