python 3.x - Conv2D layer output shape in keras -


i want manually give input keras conv2d layer.

i take mnist data set.

conv2d accepts tensors, change x_train x_train_tensor using input command of keras.

my input in format given in keras instructions

(samples,rows, cols,channels)  

example input:

(60000,128,128,1)  

i expecting output like:

(none, 26, 26, 32)  

i getting:

shape=(?, 59998, 26, 32) 

what doing wrong?

my code:

import keras keras.datasets import mnist keras.layers import conv2d keras import backend k keras.layers import input batch_size = 128 num_classes = 10 epochs = 1 # input image dimensions img_rows, img_cols = 28, 28 # data, shuffled , split between train , test sets (x_train, y_train), (x_test, y_test) = mnist.load_data() if k.image_data_format() == 'channels_first':     x_train = x_train.reshape(x_train.shape[0], 1, img_rows, img_cols)     x_test = x_test.reshape(x_test.shape[0], 1, img_rows, img_cols)     input_shape = (1, img_rows, img_cols) else:     x_train = x_train.reshape(x_train.shape[0], img_rows, img_cols, 1)     x_test = x_test.reshape(x_test.shape[0], img_rows, img_cols, 1)     input_shape = (img_rows, img_cols, 1)  x_train = x_train.astype('float32') x_test = x_test.astype('float32') x_train /= 255 x_test /= 255 print('x_train shape:', x_train.shape) print(x_train.shape[0], 'train samples') print(x_test.shape[0], 'test samples')  x_train_tensor=input(shape=(60000,28,28), name='x_train') a=conv2d(32, kernel_size=(3, 3),        activation='relu',        input_shape=input_shape)(x_train_tensor) 

the number of samples not part of input_shape, in case making 2 mistakes. first having wrong input shape, , second specifying 2 input shapes, once in input constructor, , second in conv2d instance:

x_train_tensor=input(shape=(28, 28, 1), name='x_train') a=conv2d(32, kernel_size=(3, 3), activation='relu')(x_train_tensor) 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -