# load data (x_train, y_train), (x_test, y_test) = cifar10.load_data() # color preprocessing x_train, x_test = color_preprocessing(x_train, x_test) x_train45, x_val, y_train45, y_val = train_test_split(x_train, y_train, test_size=0.1, random_state=seed) # random_state = seed y_train45 = keras.utils.to_categorical(y_train45, num_classes) y_val = keras.utils.to_categorical(y_val, num_classes) y_test = keras.utils.to_categorical(y_test, num_classes) # build network img_input = Input(shape=(img_rows,img_cols,img_channels)) output = wide_residual_network(img_input,num_classes,depth,wide) model = Model(img_input, output) evaluate_model(model, weights_file_10, x_test, y_test, bins = 15, verbose = True) # CIFAR-100 ==================== print("Evaluate CIFAR-100 wide resnet") # load data (x_train, y_train), (x_test, y_test) = cifar100.load_data() # color preprocessing x_train, x_test = color_preprocessing(x_train, x_test) x_train45, x_val, y_train45, y_val = train_test_split(x_train, y_train, test_size=0.1, random_state=seed) # random_state = seed y_train45 = keras.utils.to_categorical(y_train45, num_classes100) y_val = keras.utils.to_categorical(y_val, num_classes100) y_test = keras.utils.to_categorical(y_test, num_classes100)
print("Data loaded.") y_val = keras.utils.to_categorical(y_val, num_classes) y_test = keras.utils.to_categorical(y_test, num_classes) model = resnet152_model() sgd = SGD(lr=1e-2, decay=1e-6, momentum=0.9, nesterov=True) model.compile(optimizer=sgd, loss='categorical_crossentropy', metrics=['accuracy']) print("Start evaluation!") evaluate_model(model, weights_file_resnet, x_test, y_test, bins=15, verbose=True) print("Evaluate DenseNet161") # Subtract mean pixel and multiple by scaling constant # Reference: https://github.com/shicai/DenseNet-Caffe #im[:,:,0] = (im[:,:,0] - 103.94) * 0.017 #im[:,:,1] = (im[:,:,1] - 116.78) * 0.017 #im[:,:,2] = (im[:,:,2] - 123.68) * 0.017 model = DenseNet(reduction=0.5, classes=1000) sgd = SGD(lr=1e-2, decay=1e-6, momentum=0.9, nesterov=True) model.compile(optimizer=sgd,