my pytorch version is 0.3
please read the following code.
# x and y are pytorch Variable, which is 1 or 0 in it.
# x =
# y =
# now we check this
print(type(x))
print(type(y))
print(x.shape)
print(y.shape)
# we get z from x and y.
z = x & y
print(type(z))
print(z.shape)
this code will print the following result:
<class ‘torch.autograd.variable.Variable’>
<class ‘torch.autograd.variable.Variable’>
torch.Size([30, 1, 9])
torch.Size([1, 9, 9])
<class ‘torch.autograd.variable.Variable’>
torch.Size([30, 9, 9])
so, my question is why the shape of z is 3099, after “x & y” ? the shape of x is 3019, and the shape of y is 199, what does “&” do in “x & y”?
the x, y and z is as following.
print('x is as following:')
print(x)
print('y is as following:')
print(y)
print('z is as following:')
print(z)
x is as following:
Variable containing:
(0 ,.,.) =
1 1 1 1 1 1 1 1 1(1 ,.,.) =
1 1 1 1 1 1 1 1 1(2 ,.,.) =
1 1 1 1 1 1 1 1 1(3 ,.,.) =
1 1 1 1 1 1 1 1 1(4 ,.,.) =
1 1 1 1 1 1 1 1 1(5 ,.,.) =
1 1 1 1 1 1 1 1 1(6 ,.,.) =
1 1 1 1 1 1 1 1 1(7 ,.,.) =
1 1 1 1 1 1 1 1 1(8 ,.,.) =
1 1 1 1 1 1 1 1 1(9 ,.,.) =
1 1 1 1 1 1 1 1 1(10,.,.) =
1 1 1 1 1 1 1 1 1(11,.,.) =
1 1 1 1 1 1 1 1 1(12,.,.) =
1 1 1 1 1 1 1 1 1(13,.,.) =
1 1 1 1 1 1 1 1 1(14,.,.) =
1 1 1 1 1 1 1 1 1(15,.,.) =
1 1 1 1 1 1 1 1 1(16,.,.) =
1 1 1 1 1 1 1 1 1(17,.,.) =
1 1 1 1 1 1 1 1 1(18,.,.) =
1 1 1 1 1 1 1 1 1(19,.,.) =
1 1 1 1 1 1 1 1 1(20,.,.) =
1 1 1 1 1 1 1 1 1(21,.,.) =
1 1 1 1 1 1 1 1 1(22,.,.) =
1 1 1 1 1 1 1 1 1(23,.,.) =
1 1 1 1 1 1 1 1 1(24,.,.) =
1 1 1 1 1 1 1 1 1(25,.,.) =
1 1 1 1 1 1 1 1 1(26,.,.) =
1 1 1 1 1 1 1 1 1(27,.,.) =
1 1 1 1 1 1 1 1 1(28,.,.) =
1 1 1 1 1 1 1 1 1(29,.,.) =
1 1 1 1 1 1 1 1 1
[torch.ByteTensor of size 30x1x9]y is as following:
Variable containing:
(0 ,.,.) =
1 0 0 0 0 0 0 0 0
1 1 0 0 0 0 0 0 0
1 1 1 0 0 0 0 0 0
1 1 1 1 0 0 0 0 0
1 1 1 1 1 0 0 0 0
1 1 1 1 1 1 0 0 0
1 1 1 1 1 1 1 0 0
1 1 1 1 1 1 1 1 0
1 1 1 1 1 1 1 1 1
[torch.ByteTensor of size 1x9x9]z is as following:
Variable containing:
(0 ,.,.) =
1 0 0 … 0 0 0
1 1 0 … 0 0 0
1 1 1 … 0 0 0
… ⋱ …
1 1 1 … 1 0 0
1 1 1 … 1 1 0
1 1 1 … 1 1 1(1 ,.,.) =
1 0 0 … 0 0 0
1 1 0 … 0 0 0
1 1 1 … 0 0 0
… ⋱ …
1 1 1 … 1 0 0
1 1 1 … 1 1 0
1 1 1 … 1 1 1(2 ,.,.) =
1 0 0 … 0 0 0
1 1 0 … 0 0 0
1 1 1 … 0 0 0
… ⋱ …
1 1 1 … 1 0 0
1 1 1 … 1 1 0
1 1 1 … 1 1 1
…(27,.,.) =
1 0 0 … 0 0 0
1 1 0 … 0 0 0
1 1 1 … 0 0 0
… ⋱ …
1 1 1 … 1 0 0
1 1 1 … 1 1 0
1 1 1 … 1 1 1(28,.,.) =
1 0 0 … 0 0 0
1 1 0 … 0 0 0
1 1 1 … 0 0 0
… ⋱ …
1 1 1 … 1 0 0
1 1 1 … 1 1 0
1 1 1 … 1 1 1(29,.,.) =
1 0 0 … 0 0 0
1 1 0 … 0 0 0
1 1 1 … 0 0 0
… ⋱ …
1 1 1 … 1 0 0
1 1 1 … 1 1 0
1 1 1 … 1 1 1
[torch.ByteTensor of size 30x9x9]