def get_relative_errors(test_data_id):
    '\n    Compute and save the relative errors of every point found on every network in a testing set.\n    Relative error is defined in (Katz and Reggia 2017).\n    test_data_id should be as in fxpt_experiments.generate_test_data (without file extension).\n    '
    (network_sizes, num_samples, _) = fe.load_test_data(('%s.npz' % test_data_id))
    for alg in ['traverse', 'baseline']:
        for (N, S) in zip(network_sizes, num_samples):
            for samp in range(S):
                print(('%s, alg %s, N %d,samp %d' % (test_data_id, alg, N, samp)))
                npz = np.load(('results/%s_%s_N_%d_s_%d.npz' % (alg, test_data_id, N, samp)))
                W = npz['W']
                fxV = npz['fxV']
                (fxV, converged) = rfx.refine_fxpts_capped(W, fxV)
                margin = rfx.estimate_forward_error(W, fxV)
                f = (np.tanh(W.dot(fxV)) - fxV)
                re = np.fabs((f / margin))
                (re_fx, re_un) = (re[:, converged].max(axis=0), re[:, (~ converged)].max(axis=0))
                re_fx = re_fx[(re_fx > 0)]
                (f_fx, f_un) = (np.fabs(f[:, converged]).max(axis=0), np.fabs(f[:, (~ converged)]).max(axis=0))
                f_fx = f_fx[(f_fx > 0)]
                re_npz = {}
                re_npz['f_fx'] = f_fx
                re_npz['f_un'] = f_un
                re_npz['re_fx'] = re_fx
                re_npz['re_un'] = re_un
                fe.save_npz_file(('results/%s_re_%s_N_%d_s_%d.npz' % (alg, test_data_id, N, samp)), **re_npz)
Compute and save the relative errors of every point found on every network in a testing set.
Relative error is defined in (Katz and Reggia 2017).
test_data_id should be as in fxpt_experiments.generate_test_data (without file extension).
def get_relative_errors(test_data_id):
    '\n    Compute and save the relative errors of every point found on every network in a testing set.\n    Relative error is defined in (Katz and Reggia 2017).\n    test_data_id should be as in fxpt_experiments.generate_test_data (without file extension).\n    '
    (network_sizes, num_samples, _) = fe.load_test_data(('%s.npz' % test_data_id))
    for alg in ['traverse', 'baseline']:
        for (N, S) in zip(network_sizes, num_samples):
            for samp in range(S):
                print(('%s, alg %s, N %d,samp %d' % (test_data_id, alg, N, samp)))
                npz = np.load(('results/%s_%s_N_%d_s_%d.npz' % (alg, test_data_id, N, samp)))
                W = npz['W']
                fxV = npz['fxV']
                (fxV, converged) = rfx.refine_fxpts_capped(W, fxV)
                margin = rfx.estimate_forward_error(W, fxV)
                f = (np.tanh(W.dot(fxV)) - fxV)
                re = np.fabs((f / margin))
                (re_fx, re_un) = (re[:, converged].max(axis=0), re[:, (~ converged)].max(axis=0))
                re_fx = re_fx[(re_fx > 0)]
                (f_fx, f_un) = (np.fabs(f[:, converged]).max(axis=0), np.fabs(f[:, (~ converged)]).max(axis=0))
                f_fx = f_fx[(f_fx > 0)]
                re_npz = {}
                re_npz['f_fx'] = f_fx
                re_npz['f_un'] = f_un
                re_npz['re_fx'] = re_fx
                re_npz['re_un'] = re_un
                fe.save_npz_file(('results/%s_re_%s_N_%d_s_%d.npz' % (alg, test_data_id, N, samp)), **re_npz)