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∈Rnumin×channelin×hin×win and W∈Rnumw×channelw×hw×ww , and get a 4-dimension array: O∈Rnumout×channelout×hout×wout , where numout=numin,channelout=numw,hout=(hin−hw)/strideh+1,wout=(win−ww)/stridew+1 , and channelin must be equal to channelw . stridew , strideh 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∈Rnumin×channelin×hin×win and W∈Rnumw×channelw×hw×ww , and get a 4-dimension array: O∈Rnumout×channelout×hout×wout , where numout=numin,channelout=numw,hout=(hin−hw)/strideh+1,wout=(win−ww)/stridew+1 , and channelin must be equal to channelw . stridew , strideh is the parameters of CNNs.(We ignore other parameters like pad.)
We can use the following formula to represent a simple convolution layer:
O[n][m][x][y]=∑c=0channelin−1∑i=0hw−1∑j=0ww−1I[n][c][x×strideh+i][y×stridew+j]⋅W[m][c][i][j]
nmxy====0,⋯,numout−10,⋯,channelout−10,⋯,hout−10,⋯,wout−1
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 .
Input
In the first line there are four integers:
numin
,
channelin
,
hin
,
win
;
In the second line there are numin×channelin×hin×win integers, represent I . The value of each element in I is -1 or +1.
In the third line there are four integers: numw,channelw,hw,ww .
In the fourth line there are numw×channelw×hw×ww integers, represent W . The value of each element in W is -1 or +1;
In the fifth line there are two integers: strideh , stridew .
Except for the sample,
numin=10,channelin=64,hin=56,win=56
numw=64,channelw=channelin,hw=11,ww=11
strideh=1,stridew=1
In the second line there are numin×channelin×hin×win integers, represent I . The value of each element in I is -1 or +1.
In the third line there are four integers: numw,channelw,hw,ww .
In the fourth line there are numw×channelw×hw×ww integers, represent W . The value of each element in W is -1 or +1;
In the fifth line there are two integers: strideh , stridew .
Except for the sample,
numin=10,channelin=64,hin=56,win=56
numw=64,channelw=channelin,hw=11,ww=11
strideh=1,stridew=1
Output
First, print four integers:
numout
,
channelout
,
hout
,
wout
in a line.
Then print an integer ansmod232 in a line, so that
Then print an integer ansmod232 in a line, so that
ans=∑n=0numout−1∑m=0channelout−1∑x=0hout−1∑y=0wout−1O[n][m][x][y]∗(((n∗channelout+m)∗hout+x)∗wout+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