https://github.com/maxreciprocate/dumbcoder
Finding DSL for the data in the slowest way possible
https://github.com/maxreciprocate/dumbcoder
program-induction
Last synced: 3 months ago
JSON representation
Finding DSL for the data in the slowest way possible
- Host: GitHub
- URL: https://github.com/maxreciprocate/dumbcoder
- Owner: maxreciprocate
- Created: 2021-07-16T20:51:07.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-08-16T19:31:38.000Z (almost 4 years ago)
- Last Synced: 2025-01-08T02:46:07.702Z (5 months ago)
- Topics: program-induction
- Language: Python
- Homepage:
- Size: 26.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
This is a dumbed down version of the [dreamcoder](https://github.com/ellisk42/ec)
For demonstration let's induce a simple program for some string X using the set of expressions D
```python
>>> X = '10001000100010001000'
>>> D = Deltas([
Delta('0', str),
Delta('1', str),
Delta(2, int),
Delta(3, int),
Delta(add, int, [int, int], repr='+'), # 2 + 3 = 5
Delta(mul, str, [str, int], repr='*'), # '0' * 2 = '00'
Delta(add, str, [str, str], repr='u'), # '1' + '0' = '10'
])
>>> Z = ECD(X, D)
>>> Z[X]
(* '1000' (+ 2 3))
>>> Z[X]()
'10001000100010001000'
```ECD extends the starting DSL D with new expressions, in this case it invented a '1000' since there are a lot of these in X
```python
>>> D['1000'].hiddentail
(u '1' (* '0' 3))
>>> D['1000']()
'1000'
```ECD stands for explore, compress and dream - three stages of the algorithm: finding X by probabilistically enumerating expressions from DSL, compressing found representations and then training recognition model using those for the next enumeration cycle.