In Matlab, I have the following code:
x = vl_nnconv(x, 'size', [3 3 3 nfilters(i)], 'pad', 1);
When I do the same thing in Python (Pytorch), I get a syntax error:
for i in range(1, nlayers-1):
if i == 1:
x = nn.conv1d(x,[3 3 3 nfilters(i)], pad())
with the error marked at the [3 3 3 nfilters(i)]
area. I'm not sure what is the syntax error.
The proper formatting for the functional API F.conv1d
(where F
is torch.nn.functional
) is:
F.conv1d(x, weight, bias=None, stride=1, padding=0)
Assuming you have weight
(and optionally bias
) as tensors stored somewhere.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.