def load_lasagne_adjacency_nn(nn_dir, epoch): init_data_pkl = nn_dir + "/init_data/init_data.pkl" params = proc.load_obj(init_data_pkl) try: max_struc_start_idx = params["max_struc_start_idx"], except KeyError: max_struc_start_idx = None try: max_struc_width = params["max_struc_width"], except KeyError: max_struc_width = None X_tr, y_tr, X_te, y_te = proc.load_lasagne_data( params["gene_len_fname"], params["gene_seq_fname"], params["tr_codons_fname"], params["te_codons_fname"], params["outputs_fname"], rel_cod_idxs=params["rel_cod_idxs"], rel_nt_idxs=params["rel_nt_idxs"], rel_struc_idxs=params["rel_struc_idxs"], struc_fname=params["struc_fname"], max_struc_start_idx=max_struc_start_idx, max_struc_width=max_struc_width, filter_pct=params["filter_pct"]) my_nn = lasagnenn.AdjacencyMLP(X_tr, y_tr, X_te, y_te, name=params["name"], out_dir=params["out_dir"], rel_cod_idxs=params["rel_cod_idxs"], cod_adj_idxs=params["cod_adj_idxs"], rel_nt_idxs=params["rel_nt_idxs"], nt_adj_idxs=params["nt_adj_idxs"], learning_rate=params["learning_rate"], update_method=params["update_method"], widths=params["widths"], nonlinearity=params["nonlinearity"], input_drop_rate=params["input_drop_rate"], hidden_drop_rate=params["hidden_drop_rate"], num_outputs=params["num_outputs"], momentum=params["momentum"], batch_size=params["batch_size"], reloaded=True) my_nn.unpickle_epoch(epoch) return my_nn
def make_lasagne_adjacency_nn(name, expt_dir, gene_seq_fname, gene_len_fname, tr_codons_fname, te_codons_fname, outputs_fname, rel_cod_idxs=[], cod_adj_idxs=[], rel_nt_idxs=[], nt_adj_idxs=[], nonlinearity="tanh", widths=[200], input_drop_rate=0, hidden_drop_rate=0, num_outputs=1, update_method="sgd", filter_pct=False, rel_struc_idxs=False, struc_fname=False, max_struc_start_idx=None, max_struc_width=None, aa_feats=False, learning_rate=0.01, momentum=0.9, batch_size=500): X_tr, y_tr, X_te, y_te = setup_lasagne_nn( name, expt_dir, gene_seq_fname, gene_len_fname, tr_codons_fname, te_codons_fname, outputs_fname, rel_cod_idxs=rel_cod_idxs, rel_nt_idxs=rel_nt_idxs, nonlinearity=nonlinearity, widths=widths, input_drop_rate=input_drop_rate, hidden_drop_rate=hidden_drop_rate, num_outputs=num_outputs, update_method=update_method, filter_max=filter_max, filter_pct=filter_pct, rel_struc_idxs=rel_struc_idxs, struc_fname=struc_fname, max_struc_start_idx=max_struc_start_idx, max_struc_width=max_struc_width, aa_feats=aa_feats, learning_rate=learning_rate, momentum=momentum, batch_size=batch_size) out_dir = expt_dir + "/lasagne_nn" _, _, _, params = inspect.getargvalues(inspect.currentframe()) proc.pickle_obj(params, out_dir + "/{0}/init_data/init_data.pkl".format(name)) my_nn = lasagnenn.AdjacencyMLP(X_tr, y_tr, X_te, y_te, name=name, out_dir=out_dir, rel_cod_idxs=rel_cod_idxs, cod_adj_idxs=cod_adj_idxs, rel_nt_idxs=rel_nt_idxs, nt_adj_idxs=nt_adj_idxs, learning_rate=learning_rate, update_method=update_method, widths=widths, nonlinearity=nonlinearity, input_drop_rate=input_drop_rate, hidden_drop_rate=hidden_drop_rate, num_outputs=num_outputs, momentum=momentum, batch_size=batch_size) return my_nn