예제 #1
0
    opt = arg_parser.parse_args()
    arg_parser.create_log_path(opt, add_path_var="linear_model")
    opt.SVM_training_samples = 20

    # Device configuration
    opt.device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")

    # random seeds
    torch.manual_seed(opt.seed)
    torch.cuda.manual_seed(opt.seed)
    np.random.seed(opt.seed)

    # load pretrained model
    context_model, _ = load_audio_model.load_model_and_optimizer(
        opt, reload_model=True
    )
    context_model.eval()

    _, train_dataset, _, test_dataset = get_dataloader.get_libri_dataloaders(opt)

    try:
        # Train the model
        speaker_svm, speaker_id_dict, training_speaker_keys = SVM_train(
            opt, context_model, train_dataset
        )

        # Test the model
        accuracy = SVM_test(
            opt,
            speaker_id_dict,
예제 #2
0
        logs.create_log(model, epoch=epoch, optimizer=optimizer)


if __name__ == "__main__":

    opt = arg_parser.parse_args()
    arg_parser.create_log_path(opt)

    # set random seeds
    torch.manual_seed(opt.seed)
    torch.cuda.manual_seed(opt.seed)
    np.random.seed(opt.seed)
    random.seed(opt.seed)

    # load model
    model, optimizer = load_audio_model.load_model_and_optimizer(opt)

    # initialize logger
    logs = logger.Logger(opt)

    # get datasets and dataloaders
    train_loader, train_dataset, test_loader, test_dataset = get_dataloader.get_libri_dataloaders(
        opt
    )

    try:
        # Train the model
        train(opt, model)

    except KeyboardInterrupt:
        print("Training got interrupted, saving log-files now.")
예제 #3
0
    opt.num_epochs = 50
    opt.learning_rate = 1e-3


    arg_parser.create_log_path(opt, add_path_var="linear_model")

    # random seeds
    torch.manual_seed(opt.seed)
    torch.cuda.manual_seed(opt.seed)
    np.random.seed(opt.seed)


    ## load model
    context_model, optimizer = load_audio_model.load_model_and_optimizer(
        opt,
        reload_model=True,
        calc_accuracy=True,
        num_GPU=1,
    )
    context_model.eval()

    n_features = context_model.module.reg_hidden

    loss = loss_supervised_speaker.Speaker_Loss(
        opt, n_features, calc_accuracy=True
    )

    optimizer = torch.optim.Adam(loss.parameters(), lr=opt.learning_rate)

    # load dataset
    train_loader, _, test_loader, _ = get_dataloader.get_libri_dataloaders(opt)