Add files via upload
This commit is contained in:
parent
1c7765c961
commit
8f1cbc7a7e
4 changed files with 96 additions and 76 deletions
|
|
@ -73,6 +73,7 @@ def add_bf_on_numbers_on_pareto(pathdir, filename, PA, math_expr):
|
|||
# Do bf on one parameter at a time
|
||||
bf_on_numbers_expr = []
|
||||
for w in range(len(eq_numbers)):
|
||||
try:
|
||||
param_dict = {}
|
||||
unsnapped_param_dict = {'p':1}
|
||||
eq_ = unsnap_recur(expr,param_dict,unsnapped_param_dict)
|
||||
|
|
@ -96,6 +97,9 @@ def add_bf_on_numbers_on_pareto(pathdir, filename, PA, math_expr):
|
|||
jj = jj + 1
|
||||
|
||||
bf_on_numbers_expr = bf_on_numbers_expr + [eq]
|
||||
except:
|
||||
continue
|
||||
|
||||
for i in range(len(bf_on_numbers_expr)):
|
||||
try:
|
||||
# Calculate the error of the new, snapped expression
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ def add_snap_expr_on_pareto(pathdir, filename, math_expr, PA, DR_file=""):
|
|||
# Do integer snap one parameter at a time
|
||||
integer_snapped_expr = []
|
||||
for w in range(len(eq_numbers)):
|
||||
try:
|
||||
param_dict = {}
|
||||
unsnapped_param_dict = {'p':1}
|
||||
eq = unsnap_recur(expr,param_dict,unsnapped_param_dict)
|
||||
|
|
@ -91,6 +92,8 @@ def add_snap_expr_on_pareto(pathdir, filename, math_expr, PA, DR_file=""):
|
|||
eq = eq.subs(parm, eq_numbers[jj])
|
||||
jj = jj + 1
|
||||
integer_snapped_expr = integer_snapped_expr + [eq]
|
||||
except:
|
||||
continue
|
||||
|
||||
# Get the numbers appearing in the expression
|
||||
is_atomic_number = lambda expr: expr.is_Atom and expr.is_number
|
||||
|
|
@ -99,6 +102,7 @@ def add_snap_expr_on_pareto(pathdir, filename, math_expr, PA, DR_file=""):
|
|||
# Do zero snap one parameter at a time
|
||||
zero_snapped_expr = []
|
||||
for w in range(len(eq_numbers)):
|
||||
try:
|
||||
param_dict = {}
|
||||
unsnapped_param_dict = {'p':1}
|
||||
eq = unsnap_recur(expr,param_dict,unsnapped_param_dict)
|
||||
|
|
@ -111,6 +115,8 @@ def add_snap_expr_on_pareto(pathdir, filename, math_expr, PA, DR_file=""):
|
|||
eq = eq.subs(parm, eq_numbers[jj])
|
||||
jj = jj + 1
|
||||
zero_snapped_expr = zero_snapped_expr + [eq]
|
||||
except:
|
||||
continue
|
||||
|
||||
# Get the numbers appearing in the expression
|
||||
is_atomic_number = lambda expr: expr.is_Atom and expr.is_number
|
||||
|
|
@ -119,6 +125,7 @@ def add_snap_expr_on_pareto(pathdir, filename, math_expr, PA, DR_file=""):
|
|||
# Do rational snap one parameter at a time
|
||||
rational_snapped_expr = []
|
||||
for w in range(len(eq_numbers)):
|
||||
try:
|
||||
eq_numbers_snap = copy.deepcopy(eq_numbers)
|
||||
param_dict = {}
|
||||
unsnapped_param_dict = {'p':1}
|
||||
|
|
@ -136,6 +143,8 @@ def add_snap_expr_on_pareto(pathdir, filename, math_expr, PA, DR_file=""):
|
|||
eq = eq.subs(parm, eq_numbers_snap[jj])
|
||||
jj = jj + 1
|
||||
rational_snapped_expr = rational_snapped_expr + [eq]
|
||||
except:
|
||||
continue
|
||||
|
||||
snapped_expr = np.append(integer_snapped_expr,zero_snapped_expr)
|
||||
snapped_expr = np.append(snapped_expr,rational_snapped_expr)
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ def add_snap_expr_on_pareto_polyfit(pathdir, filename, math_expr, PA):
|
|||
# Do zero snap one parameter at a time
|
||||
zero_snapped_expr = []
|
||||
for w in range(len(eq_numbers)):
|
||||
try:
|
||||
param_dict = {}
|
||||
unsnapped_param_dict = {'p':1}
|
||||
eq = unsnap_recur(expr,param_dict,unsnapped_param_dict)
|
||||
|
|
@ -91,6 +92,8 @@ def add_snap_expr_on_pareto_polyfit(pathdir, filename, math_expr, PA):
|
|||
eq = eq.subs(parm, eq_numbers[jj])
|
||||
jj = jj + 1
|
||||
zero_snapped_expr = zero_snapped_expr + [eq]
|
||||
except:
|
||||
continue
|
||||
|
||||
for i in range(len(zero_snapped_expr)):
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -138,6 +138,10 @@ def final_gd(data_file, math_expr, lr = 1e-2, N_epochs = 5000):
|
|||
else:
|
||||
eq = eq.subs(parm, trainable_parameters[ii])
|
||||
complexity = complexity + get_number_DL(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:
|
||||
complexity = complexity + (n_variables+n_operations)*np.log2((n_variables+n_operations))
|
||||
ii = ii+1
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue