示例#1
0
                    metavar='S',
                    help='random seed (default: 42)')
parser.add_argument(
    '--log-interval',
    type=int,
    default=10,
    metavar='N',
    help='how many batches to wait before logging training status (default: 10)'
)

args = parser.parse_args()
if args.classifier: args.idx_label = None
args.betas = tuple(np.array(args.betas, dtype=float))

nu.train_rnn(file_name=args.file_name,
             hidden_size=args.hidden_size,
             n_layers=args.n_layers,
             bidirectional=args.bidirectional,
             classifier=args.classifier,
             idx_label=args.idx_label,
             n_epochs_max=args.epochs,
             train_ratio=args.train_ratio,
             batch_size=args.batch_size,
             n_workers=args.n_workers,
             root_dir=args.root_dir,
             lr=args.lr,
             betas=args.betas,
             opt_level=args.opt_level,
             seed=args.seed,
             log_interval=args.log_interval)
'''
>>>>>>> 18a8402a9b721b66ed28bcee5beabe6256a96076
# train RNNs for scat transformed data
for file_name_scat in file_names_scat:
    meta = torch.load(os.path.join(root_dir, file_name_scat))
    avg_len = meta['avg_len']
    n_filter_octave = meta['n_filter_octave']
    for hidden_size in hidden_sizes:
        for n_layers in n_layerss:
            for bidirectional in bidirectionals:
                try:
                    print("training rnn for {}, avg_len:{}, n_filter_octave:{}, hidden_size:{}, n_layers:{}, bidirectional:{}"
                        .format(file_name_scat, avg_len, n_filter_octave, hidden_size, n_layers, bidirectional))
                    nu.train_rnn(file_name_scat, [hidden_size, hidden_size], n_layers, bidirectional, classifier=False,
                        n_epochs_max=n_epochs_max, train_ratio=train_ratio, batch_size=batch_size,
                        n_workers=n_workers, root_dir=root_dir)
                except:
                    print("exception occurred for {}, avg_len:{}, n_filter_octave:{}, hidden_size:{}, n_layers:{}, bidirectional:{}"
                        .format(file_name_scat, avg_len, n_filter_octave, hidden_size, n_layers, bidirectional))

# train RNNs for raw data
for file_name_data in file_names_data:
    for hidden_size in hidden_sizes:
        for n_layers in n_layerss:
            for bidirectional in bidirectionals:
                try:
                    print("training rnn for {}, hidden_size:{}, n_layers:{}, bidirectional:{}".format(file_name_data, hidden_size, n_layers, bidirectional))
                    nu.train_rnn(file_name_data, [hidden_size, hidden_size], n_layers, bidirectional, classifier=False,
                        n_epochs_max=n_epochs_max, train_ratio=train_ratio, batch_size=batch_size,
                        n_workers=n_workers, root_dir=root_dir)
示例#3
0
        except:
            print("exception for avg_len:{}, n_filter_octave:{}".format(avg_len, n_filter_octave))

# train RNNs for scat transformed data
for file_name_scat in file_names_scat:
    meta = torch.load(os.path.join(root_dir, file_name_scat))
    avg_len = meta['avg_len']
    n_filter_octave = meta['n_filter_octave']
    for hidden_size in hidden_sizes:
        for n_layers in n_layerss:
            for bidirectional in bidirectionals:
                try:
                    print("training rnn for {}, avg_len:{}, n_filter_octave:{}, hidden_size:{}, n_layers:{}, bidirectional:{}"
                        .format(file_name_scat, avg_len, n_filter_octave, hidden_size, n_layers, bidirectional))
                    nu.train_rnn(file_name_scat, hidden_size, n_layers, bidirectional, classifier=True,
                        n_epochs_max=n_epochs_max, train_ratio=train_ratio, batch_size=batch_size,
                        n_workers=n_workers, root_dir=root_dir, lr=lr, betas=betas)
                except:
                    print("exception for file_name_scat:{}, hidden_size:{}, n_layers:{}, bidirectional:{}".format(file_name_scat, hidden_size, n_layers, bidirectional))

# train RNNs for raw data
for hidden_size in hidden_sizes:
    for n_layers in n_layerss:
        for bidirectional in bidirectionals:
            try:
                print("training rnn for {}, hidden_size:{}, n_layers:{}, bidirectional:{}".format(file_name_data, hidden_size, n_layers, bidirectional))
                nu.train_rnn(file_name_data, hidden_size, n_layers, bidirectional, classifier=True,
                    n_epochs_max=n_epochs_max, train_ratio=train_ratio, batch_size=batch_size,
                    n_workers=n_workers, root_dir=root_dir, lr=lr, betas=betas)
            except:
                print("exception for file_name_data:{}, hidden_size:{}, n_layers:{}, bidirectional:{}".format(file_name_data, hidden_size, n_layers, bidirectional))