Exemplo n.º 1
0
                    print()
                    continue

                for token_index in range(sent_len + 1):
                    print('-' * 100)
                    print(lib.formatted_clock())
                    print(dataset_name, run, sent_len, token_index)
                    print()

                    if (dataset_name, run, sent_len,
                            token_index) in already_seen:
                        print('Found ready')
                        print()
                        continue

                    full_timer = lib.Timer()

                    filtered_sents_datasource = data.DataSource([
                        ' '.join(sent[:token_index])
                        for sent in filtered_correct_sents
                    ])
                    filtered_sents_datasource.tokenize_sents().compile_sents(
                        langmod_vocab)

                    #sensitivity analysis
                    [
                        grad_next_wrt_prefix,
                        grad_max_wrt_prefix,
                        grad_next_wrt_prevtoken,
                        grad_max_wrt_prevtoken,
                        grad_next_wrt_firsttoken,
Exemplo n.º 2
0
                    config.langmodtrans_corpus_size_factor_exponents
                    if corpus != config.langmodtrans_capgen_dataset else
                    config.langmodtrans_corpus_size_factor_minor_exponents):

                print('=' * 100)
                print(lib.formatted_clock())
                print(corpus, frozen_prefix, corpus_size_factor_exponent, run)
                print()

                if (corpus, frozen_prefix, corpus_size_factor_exponent,
                        run) in already_seen:
                    print('Found ready')
                    print()
                    continue

                full_timer = lib.Timer()

                print('-' * 100)
                print('Phase 1: langmod')
                print()

                dir_name = '{}_{}_{}'.format(frozen_prefix,
                                             corpus_size_factor_exponent, run)
                lib.create_dir(config.results_dir + '/langmodtrans/' + corpus +
                               '/' + dir_name)

                corpus_size = round(10**corpus_size_factor_exponent *
                                    capgen_size)

                datasources = data.load_datasources(corpus)
                datasources['train'] = datasources['train'].without_images(
Exemplo n.º 3
0
 def epoch_started(self, model, epoch_num):
     print(epoch_num, end='\t')
     self.epoch_timer = lib.Timer()
Exemplo n.º 4
0
                best_cost = cost
            already_seen.add(tuple(next_hyperpar))

            print(i,
                  *next_hyperpar,
                  -cost,
                  lib.format_duration(duration),
                  '******' if cost == best_cost else '',
                  sep='\t')

    for _ in range(
            i, config.hyperpar_num_random_evals + config.hyperpar_num_evals):
        i += 1
        num_hyperpars = 1
        while True:
            t = lib.Timer()
            next_hyperpar = standardize_hyperpar(
                opt.ask(num_hyperpars)[-1], architecture
            )  #This allows us to get different hyperparameters every time the previous hyperparameters resulted in <<SEEN>>, <<NAN>>, or <<EMPTY>>
            num_hyperpars += 1

            print(i, *next_hyperpar, sep='\t', end='\t')

            if tuple(next_hyperpar) in already_seen:
                duration = t.get_duration()
                print('<<SEEN>>', lib.format_duration(duration), sep='\t')
                with open(config.hyperpar_dir + '/whereimage/' + architecture +
                          '/search_errors.txt',
                          'a',
                          encoding='utf-8') as f:
                    print(i,