I built a small CNN, and checked its output by comparing with the output of naive implementation of convolution. But these outputs don't match. Something wrong my understanding of naive implementation?
I used Keras==1.0.5 and theano==0.8.2. my code is as below.
net = Sequential()
net.add(Convolution2D(1, 5, 5, input_shape=(1, 10, 10)))
net.compile('sgd', 'mse')
X = np.random.randint(0, 2, 10*10).reshape([1, 1, 10, 10])
y = net.predict(X)[0][0]
# naive implementation
w, b = net.layers[0].get_weights()
w, b, X = w[0][0], b[0], X[0][0]
y_hat = np.zeros(y.shape)
for i in range(y_hat.shape[0]):
for j in range(y_hat.shape[1]):
y_hat[i, j] = (w * X[i:i+5, j:j+5]).sum() + b
y_hat - y # large error
I built a small CNN, and checked its output by comparing with the output of naive implementation of convolution. But these outputs don't match. Something wrong my understanding of naive implementation?
I used Keras==1.0.5 and theano==0.8.2. my code is as below.