Beispiel #1
0
def main():

    # Construct argument parser
    parser = argparse.ArgumentParser(description='DSPACE Model training.')
    parser.add_argument('model_fn', help='model h5 file')
    parser.add_argument('--shards', nargs='+')
    args = parser.parse_args()

    outputs = load_outputs("outputs.txt")

    # Train model
    evaluate_model(args.model_fn, args.shards, outputs)
    return
Beispiel #2
0
def main():

    # Construct argument parser
    parser = argparse.ArgumentParser(description='DSPACE Model training.')
    parser.add_argument(
        '-w', '--datadir', type=str, default="data", help="Main data directory for all outputs"
    )
    parser.add_argument(
        '-o', '--output', default='/output', help='output path to write output files to'
    )
    parser.add_argument('-e', '--epochs', type=int, default=10, help='Number of epochs')
    args = parser.parse_args()

    # Construct outputs
    outputs = load_outputs('outputs.txt')

    # Train model
    train_model(args.epochs, args.datadir, args.output, outputs)
Beispiel #3
0
def main():

    # Construct argument parser
    parser = argparse.ArgumentParser(description='DSPACE Model training.')
    parser.add_argument('-w',
                        '--datadir',
                        type=str,
                        default="data",
                        help="Main data directory for all outputs")
    parser.add_argument('-o',
                        '--output',
                        default='/output',
                        help='output path to write output files to')
    parser.add_argument('-e',
                        '--epochs',
                        type=int,
                        default=10,
                        help='Number of epochs')
    parser.add_argument(
        '--tigrfam_filter',
        type=str,
        help=
        'Skip records containing at least one of the listed tifgrfams. (comma separated)'
    )
    args = parser.parse_args()

    # Construct outputs
    outputs = load_outputs('outputs.txt')

    # Construct classflags
    classflags = None
    if args.tigrfam_filter:
        classflags = {"tigrfams": args.tigrfam_filter.split(',')}

    # Train model
    train_model(args.epochs,
                args.datadir,
                args.output,
                outputs,
                classflags=classflags)
Beispiel #4
0
def main():
    """For testing purposes
    """
    parser = argparse.ArgumentParser()
    parser.add_argument('shard_files', nargs='+')
    parser.add_argument('--batch_id', default=1, type=int)
    parser.add_argument('--batch_size', default=8, type=int)
    args = parser.parse_args()

    outputs = load_outputs('outputs.txt')
    batch = BatchProcessor(args.shard_files, args.batch_size, outputs)

    # this will always be the same for a given shard_file input
    for b in batch:
        pass  # print(batch[args.batch_id])

    # these will change everytime
    batch.on_epoch_end()
    for b in batch:
        pass  # print(batch[args.batch_id])

    return
Beispiel #5
0
    def __init__(self, model, onehot_count, multihot_thresh, oprecision, eprecision, vector_form=False, skip_tasks=[], from_embed=False):
        if type(model) is str:
            self.model = load_model(
                model, custom_objects={'precision': precision,
                                       'recall': recall,
                                       'fmeasure': fmeasure}
            )
        else:
            self.model = model

        self.eauto_index = None

        self.model.outputs.append(self.model.get_layer('embedding').output)
        self.embedding_index = len(self.model.outputs) - 1

        self.model.outputs.append(self.model.get_layer('eauto3d').output)
        self.eauto_index = len(self.model.outputs) - 1

        self.onehot_count = onehot_count
        self.multihot_thresh = multihot_thresh
        self.oprecision = oprecision
        self.eprecision = eprecision
        self.vector_form = vector_form
        self.skip_tasks = skip_tasks
        self.from_embed = from_embed

        self.outputs = load_outputs('outputs.txt')

        if self.from_embed:
            inputs, outputs = build_network(self.outputs, from_embed=True)
            model2 = Model(inputs=inputs, outputs=outputs)
            for layer in model2.layers:
                try:
                    layer.set_weights(self.model.get_layer(layer.name).get_weights())
                except:
                    pass
            self.model = model2
            self.eauto_index = len(self.model.outputs) - 1