Convolution Layer
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 256000/256000 K (Java/Others)Total Submission(s): 0 Accepted Submission(s): 0
Problem Description
In Convolutional Neural Networks(CNNs), the convolution layer is the most import component.
The convolution layer have two 4-dimension arrays: I∈R
num
in
×channel
in
×h
in
×w
in![]()
![]()
and
W∈R
num
w
×channel
w
×h
w
×w
w![]()
![]()
, and get a 4-dimension array:
O∈R
num
out
×channel
out
×h
out
×w
out![]()
![]()
, where
num
out
=num
in
,channel
out
=num
w
,h
out
=(h
in
−h
w
)/stride
h
+1,w
out
=(w
in
−w
w
)/stride
w
+1
, and
channel
in![]()
must be equal to
channel
w![]()
.
stride
w![]()
,
stride
h![]()
is the parameters of CNNs.(We ignore other parameters like pad.)
We can use the following formula to represent a simple convolution layer:
Today, Xiaoming find a special convolution layer, The value of each element in I
and
W
is either -1 or +1. Please help he compute
O
.
The convolution layer have two 4-dimension arrays: I∈R
We can use the following formula to represent a simple convolution layer:
O[n][m][x][y]=∑
c=0
channel
in
−1
∑
i=0
h
w
−1
∑
j=0
w
w
−1
I[n][c][x×stride
h
+i][y×stride
w
+j]⋅W[m][c][i][j]
n
m
x
y![]()
=
=
=
=![]()
0,⋯,num
out
−1
0,⋯,channel
out
−1
0,⋯,h
out
−1
0,⋯,w
out
−1![]()
![]()
Today, Xiaoming find a special convolution layer, The value of each element in I
Input
In the first line there are four integers:
num
in![]()
,
channel
in![]()
,
h
in![]()
,
w
in![]()
;
In the second line there are num
in
×channel
in
×h
in
×w
in![]()
integers, represent
I
. The value of each element in
I
is -1 or +1.
In the third line there are four integers: num
w
,channel
w
,h
w
,w
w![]()
.
In the fourth line there are num
w
×channel
w
×h
w
×w
w![]()
integers, represent
W
. The value of each element in
W
is -1 or +1;
In the fifth line there are two integers: stride
h![]()
,
stride
w![]()
.
Except for the sample,
num
in
=10,channel
in
=64,h
in
=56,w
in
=56
num
w
=64,channel
w
=channel
in
,h
w
=11,w
w
=11
stride
h
=1,stride
w
=1
In the second line there are num
In the third line there are four integers: num
In the fourth line there are num
In the fifth line there are two integers: stride
Except for the sample,
num
num
stride
Output
First, print four integers:
num
out![]()
,
channel
out![]()
,
h
out![]()
,
w
out![]()
in a line.
Then print an integer ansmod2
32![]()
in a line, so that
Then print an integer ansmod2
ans=∑
n=0
num
out−1![]()
∑
m=0
channel
out
−1
∑
x=0
h
out
−1
∑
y=0
w
out
−1
O[n][m][x][y]∗(((n∗channel
out
+m)∗h
out
+x)∗w
out
+y)
Sample Input
1 1 5 5 -1 1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 -1 1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 1 1 3 3 1 -1 1 -1 1 -1 1 1 -1 1 1
Sample Output
1 1 3 3 4294967286