예제 #1
0
def learn_model_from_data(dataset, working_directory, model_name):
    """Use MLP to train the dataset and generate result in working_directory"""
    model_trainer = MLPMeasurementModelTrainer(working_directory)

    trained_model = model_trainer.train(dataset)

    dataset.save_labels(os.path.join(working_directory, model_name + '_model.labels.txt'))
    neon2iosmlp.convert(model_trainer.model_path, os.path.join(working_directory, model_name + '_model.weights.raw'))

    layers = model_trainer.layers(dataset, trained_model)
    neon2iosmlp.write_layers_to_file(layers, os.path.join(working_directory, model_name + '_model.layers.txt'))

    return model_trainer, trained_model
예제 #2
0
def run_training_on(dataset, working_directory):
    """Create a fresh trainer to train a model on the dataset.
    
    The working directory is used to store intermediate model instances."""
    model_trainer = MLPMeasurementModelTrainer(working_directory)

    trained_model = model_trainer.train(dataset)

    # Extract the ordered labels to map them to the outputs of the network
    labels = dataset.ordered_labels()
    # Convert the model to a string representation. It can be loaded later to apply it to new data
    str_model = neon2iosmlp.model2string(model_trainer.model_path)
    # Retrieve the layer configuration (number of nodes in each layer) to be able to reconstruct the network
    layer_config = model_trainer.layers(dataset, trained_model)

    return str_model, layer_config, labels
예제 #3
0
def run_training_on(dataset, working_directory):
    """Create a fresh trainer to train a model on the dataset.
    
    The working directory is used to store intermediate model instances."""
    model_trainer = MLPMeasurementModelTrainer(working_directory)

    trained_model = model_trainer.train(dataset)

    # Extract the ordered labels to map them to the outputs of the network 
    labels = dataset.ordered_labels()
    # Convert the model to a string representation. It can be loaded later to apply it to new data
    str_model = neon2iosmlp.model2string(model_trainer.model_path)
    # Retrieve the layer configuration (number of nodes in each layer) to be able to reconstruct the network
    layer_config = model_trainer.layers(dataset, trained_model)

    return str_model, layer_config, labels 
예제 #4
0
def learn_model_from_data(dataset, working_directory, model_name):
    """Use MLP to train the dataset and generate result in working_directory"""
    model_trainer = MLPMeasurementModelTrainer(working_directory)

    trained_model = model_trainer.train(dataset)

    dataset.save_labels(
        os.path.join(working_directory, model_name + '_model.labels.txt'))
    neon2iosmlp.convert(
        model_trainer.model_path,
        os.path.join(working_directory, model_name + '_model.weights.raw'))

    layers = model_trainer.layers(dataset, trained_model)
    neon2iosmlp.write_layers_to_file(
        layers,
        os.path.join(working_directory, model_name + '_model.layers.txt'))

    return model_trainer, trained_model