diff --git a/examples/cifar10_nasnet.py b/examples/cifar10_nasnet.py index 11aba03..56c75ee 100644 --- a/examples/cifar10_nasnet.py +++ b/examples/cifar10_nasnet.py @@ -84,6 +84,9 @@ else: datagen.fit(X_train) # wrap the ImageDataGenerator to yield two label batches [y, y] for each input batch X + # When training a NASNet model, we have to use its auxilary training head + # Therefore the model is technically a 1 input - 2 output model, and requires + # the label to be duplicated for the auxilary head def image_data_generator_wrapper(image_datagenerator, batch_size): iterator = datagen.flow(X_train, Y_train, batch_size=batch_size) diff --git a/keras_contrib/applications/nasnet.py b/keras_contrib/applications/nasnet.py index bab9e9f..12895a6 100644 --- a/keras_contrib/applications/nasnet.py +++ b/keras_contrib/applications/nasnet.py @@ -248,7 +248,7 @@ def NASNet(input_shape=None, # load weights (when available) if weights is not None: - warnings.warn('Weights of NASNet models have not been ported yet for Keras.') + warnings.warn('Weights of NASNet models have not yet been ported to Keras') if old_data_format: K.set_image_data_format(old_data_format) @@ -684,6 +684,10 @@ def _reduction_A(ip, p, filters, weight_decay=5e-5, id=None): def _add_auxilary_head(x, classes, weight_decay): '''Adds an auxilary head for training the model + From section A.7 "Training of ImageNet models" of the paper, all NASNet models are + trained using an auxilary classifier around 2/3 of the depth of the network, with + a loss weight of 0.4 + # Arguments x: input tensor classes: number of output classes