Write some keras code which get correct result
from keras.models import Sequential
from keras.optimizers import SGD
from keras.layers import Conv2D
from keras.layers.core import Dense
from keras.layers import Dense, Dropout, Flatten

x_train = np.random.random((6, 4, 4, 1))
y_train = np.arange(6)

model = Sequential()
model.add(Conv2D(32, (3, 3), activation='relu', input_shape=(4, 4, 1), padding='same'))
model.add(Conv2D(32, (3, 3), activation='relu', padding='same'))
model.add(Flatten())
model.add(Dense(1, input_dim = 32*4*4))

sgd = SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True)
model.compile(loss='mean_squared_error', optimizer=sgd)
model.fit(x_train, y_train, batch_size=3, epochs=500)


Result:
Epoch 1/10
6/6 [==============================] - 5s 837ms/step - loss: 7.9785
Epoch 2/10
6/6 [==============================] - 0s 1ms/step - loss: 2.5833
Epoch 3/10
6/6 [==============================] - 0s 1ms/step - loss: 5.8242
Epoch 4/10
6/6 [==============================] - 0s 983us/step - loss: 5.4813
Epoch 5/10
6/6 [==============================] - 0s 951us/step - loss: 3.0968
Epoch 6/10
6/6 [==============================] - 0s 1ms/step - loss: 2.9960
Epoch 7/10
6/6 [==============================] - 0s 986us/step - loss: 1.4687
Epoch 8/10
6/6 [==============================] - 0s 976us/step - loss: 1.2033
Epoch 9/10
6/6 [==============================] - 0s 1ms/step - loss: 0.5037
Epoch 10/10
6/6 [==============================] - 0s 943us/step - loss: 0.2996