Answer the question
In order to leave comments, you need to log in
Why does an error occur when compiling the model?
Good day, there is a model:
seq = Sequential()
seq.add(Conv2D(6, 3, 3, activation="relu", input_shape=input_shape, padding='valid', data_format="channels_first"))
seq.add(MaxPooling2D(pool_size=(2, 2)))
seq.add(Dropout(0.25))
seq.add(Conv2D(12, 3, 3, activation="relu", padding='valid', data_format="channels_first"))
seq.add(MaxPooling2D(pool_size=(2, 2), data_format='channels_first'))
seq.add(Dropout(0.25))
seq.add(Flatten())
seq.add(Dense(128, activation='relu'))
seq.add(Dropout(0.1))
seq.add(Dense(50, activation='relu'))
X, Y = self.get_data()
x_train, x_test, y_train, y_test = train_test_split(X, Y, test_size=.25)
input_dim = x_train.shape[2:]
img_a = Input(shape=input_dim)
img_b = Input(shape=input_dim)
base_network = self.model(input_dim)
feat_vecs_a = base_network(img_a)
feat_vecs_b = base_network(img_b)
distance = Lambda(self.euclidean_distance, output_shape=self.eucl_dist_output_shape)([feat_vecs_a, feat_vecs_b])
rms = RMSprop()
model = Model(inputs=[img_a, img_b], outputs=distance)
model.compile(loss=self.contrastive_loss, optimizer=rms)
Answer the question
In order to leave comments, you need to log in
Your error says: "Default MaxPoolingOp only supports NHWC on device type CPU", i.e. on the CPU, only channels last is supported for MaxPooling, and you feed channels first. NHWC = (n_samples, height, width, channels).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question