def print_best_model(): space_best_model = load_best_hyperspace() if space_best_model is None: print("No best model to plot. Continuing...") return print("Best hyperspace yet:") print_model_data(['model_name','train_accuracy','test_accuracy','model_param_num']) print_json(space_best_model)
def plot_best_model(): """Plot the best model found yet.""" space_best_model = load_best_hyperspace() if space_best_model is None: tf.logging.info("No best model to plot. Continuing...") return tf.logging.info("Best hyperspace yet:") print_json(space_best_model) plot(space_best_model, "model_best")
def plot_best_model(): """Plot the best model found yet.""" space_best_model = load_best_hyperspace() if space_best_model is None: print("No best model to plot. Continuing...") return # Print best hyperspace and save model png print("Best hyperspace yet:") print_json(space_best_model) plot(space_best_model, "model_best")
import numpy as np from keras import backend as K import time import os # Dimensions of the generated pictures for each filter. img_width = 32 img_height = 32 weight_file = "{}/f37d5.hdf5".format(WEIGHTS_DIR) LAYERS_DIR = "layers" # Load model in test phase mode: no dropout, and use fixed BN K.set_learning_phase(0) model = build_model(load_best_hyperspace()) model.load_weights(weight_file) print('Model loaded.') model.summary() def normalize(x): """Utility function to normalize a tensor by its L2 norm.""" return x / (K.sqrt(K.mean(K.square(x))) + 1e-5) def deprocess_image(x): """Utility function to convert a tensor into a valid image.""" # Normalize tensor: center on 0., ensure std is 0.1 x -= x.mean()
from neural_net import build_and_train, TENSORBOARD_DIR from utils import print_json, load_best_hyperspace from keras.layers.core import K import os __author__ = "Vooban Inc." __copyright__ = "Copyright 2017, Vooban Inc." __license__ = "MIT License" # See: https://github.com/Vooban/Hyperopt-Keras-CNN-CIFAR-100/blob/master/LICENSE" if __name__ == "__main__": """Retrain best model with TensorBoard. Also save best weights.""" space_best_model = load_best_hyperspace() print("Hyperspace:") print_json(space_best_model) model, model_name, results, log_path = build_and_train( space_best_model, save_best_weights=True, log_for_tensorboard=True) print("Model Name:", model_name) print("Note: results 'json' file not saved to 'results/' since it is now " "available in TensorBoard. See above console output for json-styled " "results.") print("Model summary:") model.summary()