{"action":"created","issue":{"url":"https://api.github.com/repos/fchollet/keras/issues/1092","labels_url":"https://api.github.com/repos/fchollet/keras/issues/1092/labels{/name}","comments_url":"https://api.github.com/repos/fchollet/keras/issues/1092/comments","events_url":"https://api.github.com/repos/fchollet/keras/issues/1092/events","html_url":"https://github.com/fchollet/keras/issues/1092","id":119092640,"number":1092,"title":"Convolution2D for same border_mode on GPU reduces data size ","user":{"login":"MinhazPalasara","id":11968660,"avatar_url":"https://avatars.githubusercontent.com/u/11968660?v=3","gravatar_id":"","url":"https://api.github.com/users/MinhazPalasara","html_url":"https://github.com/MinhazPalasara","followers_url":"https://api.github.com/users/MinhazPalasara/followers","following_url":"https://api.github.com/users/MinhazPalasara/following{/other_user}","gists_url":"https://api.github.com/users/MinhazPalasara/gists{/gist_id}","starred_url":"https://api.github.com/users/MinhazPalasara/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MinhazPalasara/subscriptions","organizations_url":"https://api.github.com/users/MinhazPalasara/orgs","repos_url":"https://api.github.com/users/MinhazPalasara/repos","events_url":"https://api.github.com/users/MinhazPalasara/events{/privacy}","received_events_url":"https://api.github.com/users/MinhazPalasara/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-26T19:04:15Z","updated_at":"2015-11-27T00:06:56Z","closed_at":null,"body":"#Run this code. I have modified the mnist_cnn.py file to have the \"same\" border_mode. At the end, #it displays the size of first layer output. It should be same as the input i.e (28, 28) but it is ( 27, 27) \r\n\r\n\r\nfrom keras.datasets import mnist\r\nfrom keras.models import Sequential\r\nfrom keras.layers.core import Dense, Dropout, Activation, Flatten\r\nfrom keras.layers.convolutional import Convolution2D, MaxPooling2D\r\nfrom keras.utils import np_utils\r\nimport theano\r\n\r\nbatch_size = 10\r\nnb_classes = 10\r\nnb_epoch = 0\r\n\r\nimg_rows, img_cols = 28, 28\r\nnb_filters = 32\r\nnb_pool = 2\r\nnb_conv = 2\r\n\r\n\r\n(X_train, y_train), (X_test, y_test) = mnist.load_data()\r\n\r\nX_train = X_train.reshape(X_train.shape[0], 1, img_rows, img_cols)\r\nX_test = X_test.reshape(X_test.shape[0], 1, img_rows, img_cols)\r\nX_train = X_train.astype(\"float32\")\r\nX_test = X_test.astype(\"float32\")\r\nX_train /= 255\r\nX_test /= 255\r\n\r\nprint('X_train shape:', X_train.shape)\r\nprint(X_train.shape[0], 'train samples')\r\nprint(X_test.shape[0], 'test samples')\r\n\r\nY_train = np_utils.to_categorical(y_train, nb_classes)\r\nY_test = np_utils.to_categorical(y_test, nb_classes)\r\n\r\nmodel = Sequential()\r\n\r\nmodel.add(Convolution2D(nb_filters, nb_conv, nb_conv,\r\n                        border_mode='same',\r\n                        input_shape=(1, img_rows, img_cols)))\r\nmodel.add(Activation('relu'))\r\nmodel.add(Convolution2D(nb_filters, nb_conv, nb_conv))\r\nmodel.add(Activation('relu'))\r\nmodel.add(MaxPooling2D(pool_size=(nb_pool, nb_pool)))\r\nmodel.add(Dropout(0.25))\r\n\r\nmodel.add(Flatten())\r\nmodel.add(Dense(128))\r\nmodel.add(Activation('relu'))\r\nmodel.add(Dropout(0.5))\r\nmodel.add(Dense(nb_classes))\r\nmodel.add(Activation('softmax'))\r\n\r\nmodel.compile(loss='categorical_crossentropy', optimizer='adadelta')\r\n\r\nlayer_id = 0\r\nmodel.extract_features = theano.function(\r\n            [model.layers[0].input],\r\n            model.layers[layer_id].get_output(False),\r\n            on_unused_input='ignore', allow_input_downcast=True)\r\n\r\noutput = model.extract_features(X_test[0:1, :])\r\nprint(\"output size of layer : \"+str(layer_id)+\" has shape \"+str(output.shape))"},"comment":{"url":"https://api.github.com/repos/fchollet/keras/issues/comments/160008231","html_url":"https://github.com/fchollet/keras/issues/1092#issuecomment-160008231","issue_url":"https://api.github.com/repos/fchollet/keras/issues/1092","id":160008231,"user":{"login":"jocicmarko","id":1452125,"avatar_url":"https://avatars.githubusercontent.com/u/1452125?v=3","gravatar_id":"","url":"https://api.github.com/users/jocicmarko","html_url":"https://github.com/jocicmarko","followers_url":"https://api.github.com/users/jocicmarko/followers","following_url":"https://api.github.com/users/jocicmarko/following{/other_user}","gists_url":"https://api.github.com/users/jocicmarko/gists{/gist_id}","starred_url":"https://api.github.com/users/jocicmarko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jocicmarko/subscriptions","organizations_url":"https://api.github.com/users/jocicmarko/orgs","repos_url":"https://api.github.com/users/jocicmarko/repos","events_url":"https://api.github.com/users/jocicmarko/events{/privacy}","received_events_url":"https://api.github.com/users/jocicmarko/received_events","type":"User","site_admin":false},"created_at":"2015-11-27T00:06:56Z","updated_at":"2015-11-27T00:06:56Z","body":"You should check your layers' shapes by using **print_layer_shapes** function, found in keras/utils/layer_utils."}}