Add files via upload
This commit is contained in:
parent
7a0d782d51
commit
a96e7f321a
10 changed files with 119 additions and 133 deletions
|
|
@ -22,8 +22,7 @@ from S_get_number_DL_snapped import get_number_DL_snapped
|
|||
from S_get_symbolic_expr_error import get_symbolic_expr_error
|
||||
|
||||
# parameters: path to data, RPN expression (obtained from bf)
|
||||
def RPN_to_pytorch(pathdir,filename, math_expr, lr = 1e-2, N_epochs = 500):
|
||||
data_file = pathdir + filename
|
||||
def RPN_to_pytorch(data, math_expr, lr = 1e-2, N_epochs = 500):
|
||||
param_dict = {}
|
||||
unsnapped_param_dict = {'p':1}
|
||||
|
||||
|
|
@ -59,10 +58,6 @@ def RPN_to_pytorch(pathdir,filename, math_expr, lr = 1e-2, N_epochs = 500):
|
|||
new_key = "{}{}{}{}{}".format(key, underscore, midfix, i, suffix)
|
||||
return new_key
|
||||
|
||||
# Load the actual data
|
||||
|
||||
data = np.loadtxt(data_file)
|
||||
|
||||
# Turn BF expression to pytorch expression
|
||||
eq = parse_expr(math_expr)
|
||||
eq = unsnap_recur(eq,param_dict,unsnapped_param_dict)
|
||||
|
|
@ -135,7 +130,7 @@ def RPN_to_pytorch(pathdir,filename, math_expr, lr = 1e-2, N_epochs = 500):
|
|||
if n_operations!=0 or n_variables!=0:
|
||||
complexity = complexity + (n_variables+n_operations)*np.log2((n_variables+n_operations))
|
||||
|
||||
error = get_symbolic_expr_error(pathdir,filename,str(eq))
|
||||
error = get_symbolic_expr_error(data,str(eq))
|
||||
return error, complexity, eq
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue