def train(self): self.X_train, self.X_crop_train, self.X_test, self.X_crop_test = crop_encoder_data.load_data( 0.5) if K.image_dim_ordering() == 'th': self.X_train = self.X_train.reshape(self.X_train.shape[0], 1, self.param_dict['img_rows'], self.param_dict['img_cols']) self.X_test = self.X_test.reshape(self.X_test.shape[0], 1, self.param_dict['img_rows'], self.param_dict['img_cols']) self.X_crop_train = self.X_crop_train.reshape( self.X_train.shape[0], 1, self.param_dict['crop_rows'], self.param_dict['crop_cols']) self.X_crop_test = self.X_crop_test.reshape( self.X_test.shape[0], 1, self.param_dict['crop_rows'], self.param_dict['crop_cols']) #input_shape = (1, self.img_rows, img_cols) else: self.X_train = self.X_train.reshape(self.X_train.shape[0], self.param_dict['img_rows'], self.param_dict['img_cols'], 1) self.X_test = self.X_test.reshape(self.X_test.shape[0], self.param_dict['img_rows'], self.param_dict['img_cols'], 1) self.X_crop_train = self.X_crop_train.reshape( self.X_train.shape[0], self.param_dict['crop_rows'] * self.param_dict['crop_cols']) self.X_crop_test = X_crop_test.reshape( X_test.shape[0], self.param_dict['crop_rows'] * self.param_dict['crop_cols']) #input_shape = (img_rows,img_cols,1) self.X_train = self.X_train.astype('float32') self.X_train /= 255 self.X_test = self.X_test.astype('float32') self.X_test /= 255 self.X_crop_train = X_crop_train.astype('float32') self.X_crop_train /= 255 self.X_crop_test = X_crop_test.astype('float32') self.X_crop_test /= 255
nb_classes = 8 nb_epoch = 10 # input image dimensions img_rows, img_cols = 128, 128 crop_rows, crop_cols = 32, 32 # number of convolutional filters to use nb_filters = 16 # size of pooling area for max pooling pool_size = (2, 2) # convolution kernel size kernel_size = (3, 3) # the data, shuffled and split between train and test sets X_train, X_crop_train, X_test, X_crop_test = crop_encoder_data.load_data(0.5) # (X_train, y_train), (X_test, y_test) = mnist.load_data() if K.image_dim_ordering() == 'th': 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) X_crop_train = X_crop_train.reshape(X_train.shape[0], 1, crop_rows, crop_cols) X_crop_test = X_crop_test.reshape(X_test.shape[0], 1, crop_rows, crop_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) X_crop_train = X_crop_train.reshape(X_train.shape[0], crop_rows, crop_cols, 1) X_crop_test = X_crop_test.reshape(X_test.shape[0], crop_rows, crop_cols, 1)