From 735e1d43ae5b605ee89f0243727b6be89e3ff29a Mon Sep 17 00:00:00 2001 From: Silviu Marian Udrescu Date: Sun, 10 May 2020 20:29:00 -0400 Subject: [PATCH] Add files via upload --- Code/RPN_to_pytorch.py | 4 ++-- Code/S_final_gd.py | 4 ++-- Code/S_run_bf_polyfit.py | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Code/RPN_to_pytorch.py b/Code/RPN_to_pytorch.py index e0ab887..fe49ca5 100644 --- a/Code/RPN_to_pytorch.py +++ b/Code/RPN_to_pytorch.py @@ -18,7 +18,7 @@ from sympy.abc import x,y from sympy.parsing.sympy_parser import parse_expr from sympy import Symbol, lambdify, N -from S_get_number_DL import get_number_DL +from S_get_number_DL_snapped import get_number_DL_snapped # parameters: path to data, RPN expression (obtained from bf) def RPN_to_pytorch(data_file, math_expr, lr = 1e-2, N_epochs = 500): @@ -117,7 +117,7 @@ def RPN_to_pytorch(data_file, math_expr, lr = 1e-2, N_epochs = 500): ii = ii + 1 else: eq = eq.subs(parm, trainable_parameters[ii]) - complexity = complexity + get_number_DL(trainable_parameters[ii].detach().numpy()) + complexity = complexity + get_number_DL_snapped(trainable_parameters[ii].detach().numpy()) n_variables = len(eq.free_symbols) n_operations = len(count_ops(eq,visual=True).free_symbols) if n_operations!=0 or n_variables!=0: diff --git a/Code/S_final_gd.py b/Code/S_final_gd.py index 6b907be..13e3ed1 100644 --- a/Code/S_final_gd.py +++ b/Code/S_final_gd.py @@ -18,7 +18,7 @@ from sympy.abc import x,y from sympy.parsing.sympy_parser import parse_expr from sympy import Symbol, lambdify, N -from S_get_number_DL import get_number_DL +from S_get_number_DL_snapped import get_number_DL_snapped # parameters: path to data, RPN expression (obtained from bf) def final_gd(data_file, math_expr, lr = 1e-2, N_epochs = 5000): @@ -133,7 +133,7 @@ def final_gd(data_file, math_expr, lr = 1e-2, N_epochs = 5000): ii = ii + 1 else: eq = eq.subs(parm, trainable_parameters[ii]) - complexity = complexity + get_number_DL(trainable_parameters[ii].detach().numpy()) + complexity = complexity + get_number_DL_snapped(trainable_parameters[ii].detach().numpy()) n_variables = len(eq.free_symbols) n_operations = len(count_ops(eq,visual=True).free_symbols) if n_operations!=0 or n_variables!=0: diff --git a/Code/S_run_bf_polyfit.py b/Code/S_run_bf_polyfit.py index fe689a8..ac3fc03 100644 --- a/Code/S_run_bf_polyfit.py +++ b/Code/S_run_bf_polyfit.py @@ -7,7 +7,7 @@ import numpy as np import matplotlib.pyplot as plt from S_brute_force import brute_force from S_combine_pareto import combine_pareto -from S_get_number_DL import get_number_DL +from S_get_number_DL_snapped import get_number_DL_snapped from sympy.parsing.sympy_parser import parse_expr from sympy import preorder_traversal, count_ops from S_polyfit import polyfit @@ -72,7 +72,7 @@ def run_bf_polyfit(pathdir,pathdir_transformed,filename,BF_try_time,BF_ops_file_ compl = 0 for j in numbers_expr: try: - compl = compl + get_number_DL(float(j)) + compl = compl + get_number_DL_snapped(float(j)) except: compl = compl + 1000000 @@ -150,7 +150,7 @@ def run_bf_polyfit(pathdir,pathdir_transformed,filename,BF_try_time,BF_ops_file_ compl = 0 for j in numbers_expr: try: - compl = compl + get_number_DL(float(j)) + compl = compl + get_number_DL_snapped(float(j)) except: compl = compl + 1000000 @@ -215,7 +215,7 @@ def run_bf_polyfit(pathdir,pathdir_transformed,filename,BF_try_time,BF_ops_file_ numbers_expr = [subexpression for subexpression in preorder_traversal(expr) if is_atomic_number(subexpression)] complexity = 0 for j in numbers_expr: - complexity = complexity + get_number_DL(float(j)) + complexity = complexity + get_number_DL_snapped(float(j)) try: # Add the complexity due to symbols n_variables = len(polyfit_result[0].free_symbols)