I write a simple python program to compress my program dataset. I'd like to iteratively reduce my library such that I don't need to wait too long for intermediate result.
This is an example of my script.
from stitch_core import compress, rewrite
import json
import pandas as pd
import numpy as np
def process():
epoch = 100
df = pd.read_csv('dataset.csv')
programs = df['programs'].tolist()
avg_length = np.mean([len(i) for i in programs])
print('compress result avg length:',avg_length)
for i in range(epoch):
res = compress(programs, iterations=10, max_arity=2, slient=False)
# print(res)
# print(res.json)
print('-' * 100)
n_abst = len(res.abstractions)
print('total abstraction', n_abst)
print('rewrite')
programs_rewrite = rewrite(programs, res.abstractions)
programs = programs_rewrite.rewritten
print('rewrite programs', len(programs))
with open(f'output/result_epoch_{i}.json', 'w') as f:
json.dump(programs_rewrite.json, f, indent=4)
avg_length = np.mean([len(i) for i in programs])
print('compress result avg length:',avg_length)
This loop executes well in the beginning and throw error when epoch=19:
Traceback (most recent call last):
File "/home/bofei-zhang/miniconda3/envs/plcn/lib/python3.9/site-packages/stitch_core/__init__.py", line 303, in compress
res = compress_backend(
pyo3_runtime.PanicException: assertion failed: !res.contains(&format!(\" {prim} \"))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/bofei-zhang/Documents/Project/Projects/concept_learning/pl-cn/experiments/stitch_pl/process.py", line 142, in <module>
process()
File "/home/bofei-zhang/Documents/Project/Projects/concept_learning/pl-cn/experiments/stitch_pl/process.py", line 125, in process
res = compress(programs, iterations=10, max_arity=2, slient=False)
File "/home/bofei-zhang/miniconda3/envs/plcn/lib/python3.9/site-packages/stitch_core/__init__.py", line 311, in compress
raise StitchException(f"Rust backend panicked with exception: {e}")
stitch_core.StitchException: Rust backend panicked with exception: assertion failed: !res.contains(&format!(\" {prim} \"))
Please kindly advise how to address this issue.
I write a simple python program to compress my program dataset. I'd like to iteratively reduce my library such that I don't need to wait too long for intermediate result.
This is an example of my script.
This loop executes well in the beginning and throw error when
epoch=19:Please kindly advise how to address this issue.