Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for SetTransformer++, ScheduleFree, Complexity Control. Improve stability, 2D Analysis, Small Fixes #19

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
96815df
Improve stability, 2D Analysis
psaegert Feb 19, 2025
75e95df
Merge branch 'main' into dev
psaegert Feb 19, 2025
d1054c8
Add SetTransformer++
psaegert Feb 19, 2025
366027c
Merge branch 'dev' of github.com:psaegert/flash-ansr into dev
psaegert Feb 19, 2025
7fab8db
Improve isfinite check
psaegert Feb 19, 2025
427689b
Clean up notebook, re-add force remove option
psaegert Feb 19, 2025
69c19b3
Merge branch 'dev' of github.com:psaegert/flash-ansr into dev
psaegert Feb 19, 2025
63e95ae
Fix v7.11 config
psaegert Feb 19, 2025
d795b79
Add support for schedulefree, add v11.0
psaegert Feb 19, 2025
e526d45
Remove amsgrad option from schedulefree AdamW
psaegert Feb 19, 2025
e746bac
Fix string type lr in config
psaegert Feb 19, 2025
db69826
Remove valid check for flash simplification
psaegert Feb 19, 2025
52159cc
Improve config loading for nested configs
psaegert Feb 21, 2025
da30f31
Implement preprocessing for batched generation
psaegert Feb 21, 2025
7ee7500
Add suppport for single instance preprocessing
psaegert Feb 21, 2025
411caa2
Add support for collating single data instances
psaegert Feb 22, 2025
8c20dbd
Add support for complexity control during training,
psaegert Feb 22, 2025
383e2de
Optimize copy behavior of expressions
psaegert Feb 22, 2025
99639f0
Fix saving configs recursively
psaegert Feb 24, 2025
947750e
Begin adding support for complexity in inference
psaegert Feb 24, 2025
1a450a5
Add support for complexity control in beam search
psaegert Feb 25, 2025
33b03c8
Remove profiling files
psaegert Feb 25, 2025
922a32d
Add table of contents, visual abstract, resutls to README.md
psaegert Feb 25, 2025
11c88fb
Replace markdown table with png
psaegert Feb 25, 2025
ae02dac
Improve README
psaegert Feb 25, 2025
02020ae
Fix s not capital in NeSymReS
psaegert Feb 25, 2025
3ac939e
Fix capital S in results.png
psaegert Feb 25, 2025
ac9ae79
Fiy typo in experimental/eval/simplify.py
psaegert Feb 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
/src/flash_ansr/models/encoders/deep_sets2.py
/src/flash_ansr/models/encoders/point_net.py
/src/flash_ansr/models/encoders/point_net2.py
/src/flash_ansr/models/encoders/set_transformer2.py

# Models & Data
/models
Expand All @@ -16,6 +15,9 @@ cloud.md
# Wandb
wandb

# Profiling
.prof

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
62 changes: 45 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,55 @@
<h1 align="center" style="margin-top: 0px;">🏗️Work In Progress🏗️</h1>

<h1 align="center" style="margin-top: 0px;">⚡ANSR:<br>Flash Amortized Neural Symbolic Regression</h1>

<div align="center">

[![pytest](https://github.com/psaegert/flash-ansr/actions/workflows/pytest.yml/badge.svg)](https://github.com/psaegert/flash-ansr/actions/workflows/pytest.yml)
[![quality checks](https://github.com/psaegert/flash-ansr/actions/workflows/pre-commit.yml/badge.svg)](https://github.com/psaegert/flash-ansr/actions/workflows/pre-commit.yml)
[![CodeQL Advanced](https://github.com/psaegert/flash-ansr/actions/workflows/codeql.yml/badge.svg)](https://github.com/psaegert/flash-ansr/actions/workflows/codeql.yml)
[![CodeQL Advanced](https://github.com/psaegert/flash-ansr/actions/workflows/codeql.yaml/badge.svg)](https://github.com/psaegert/flash-ansr/actions/workflows/codeql.yaml)

</div>

<!-- TODO: Visual Abstract -->

<img src="./assets/images/nsr-training.drawio.svg" width="100%">

> **⚡ANSR Training on Fully Procedurally Generated Data** Inspired by NeSymReS ([Biggio et al. 2021](https://arxiv.org/abs/2106.06427))

# Introduction

TODO

<img src="./assets/images/results.png" width="100%">

> **Model Comparison.** Up to 3 variables. Default Model Configurations (32 threads / beams).\
> Bootstrapped Median, 5p, 95p and AR-p ([Noreen 1989](https://scholar.google.com/scholar?hl=en&q=Computer-intensive+methods+for+testing+hypotheses)) values (n=1000).\
> N = 5000 ([⚡ v7.0](#usage)), 1000 ([PySR](https://github.com/MilesCranmer/PySR), [NeSymReS 100M](https://github.com/SymposiumOrganization/NeuralSymbolicRegressionThatScales?tab=readme-ov-file#pretrained-models)).\
> AMD 9950X (16C32T), RTX 4090.

# Table of Contents
- [Introduction](#introduction)
- [Table of Contents](#table-of-contents)
- [Requirements](#requirements)
- [Hardware](#hardware)
- [Software](#software)
- [Getting Started](#getting-started)
- [1. Clone the repository](#1-clone-the-repository)
- [2. Install the package](#2-install-the-package)
- [Usage](#usage)
- [Training](#training)
- [Express](#express)
- [Manual](#manual)
- [0. Prerequisites](#0-prerequisites)
- [1. Import test data](#1-import-test-data)
- [2. Generate validation data](#2-generate-validation-data)
- [3. Train the model](#3-train-the-model)
- [4. Evaluate the model](#4-evaluate-the-model)
- [4.1 Evaluate NeSymReS](#41-evaluate-nesymres)
- [4.2 Evaluate PySR](#42-evaluate-pysr)
- [Development](#development)
- [Setup](#setup)
- [Tests](#tests)
- [Citation](#citation)

# Requirements

## Hardware
Expand All @@ -37,7 +73,7 @@ cd flash-ansr

## 2. Install the package

Optional: Create a virtual environment:
Create a virtual environment (optional):

**conda:**

Expand All @@ -50,13 +86,11 @@ Then, install the package via

```sh
pip install -e .
pip install -e nsrops
pip install -e ./nsrops
```

# Usage

## Use a pre-trained model

```python
import torch
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
Expand Down Expand Up @@ -227,12 +261,12 @@ with
- `-o` the output file for results
- `-v` verbose output

#### 4.1 Evaluate NeSymRes
#### 4.1 Evaluate NeSymReS
1. Clone [NeuralSymbolicRegressionThatScales](https://github.com/SymposiumOrganization/NeuralSymbolicRegressionThatScales) to a directory of your choice.
2. Download the `100M` model as described [here](https://github.com/SymposiumOrganization/NeuralSymbolicRegressionThatScales?tab=readme-ov-file#pretrained-models)
3. Move the `100M` model into `flash-ansr/models/nesymres/`
4. Create a Python 3.10 (!) environment and install flash-ansr as in the previous steps.
5. Install NeSymRes in the same environment:
5. Install NeSymReS in the same environment:
```sh
cd NeuralSymbolicRegressionThatScales
pip install -e src/
Expand Down Expand Up @@ -264,13 +298,7 @@ pre-commit install

## Tests

Test the package with

```sh
./scripts/pytest.sh
```

for convenience.
Test the package with `./scripts/pytest.sh`. Run pylint with `./scripts/pylint.sh`.

# Citation
```bibtex
Expand All @@ -279,7 +307,7 @@ for convenience.
title = {Flash Amortized Neural Symbolic Regression},
year = 2024,
publisher = {GitHub},
version = {0.1.0},
version = {0.3.0},
url = {https://github.com/psaegert/flash-ansr}
}
```
4 changes: 4 additions & 0 deletions assets/images/nsr-training.drawio.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/results.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions configs/v10.0/dataset_train.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
skeleton_pool: './skeleton_pool_train.yaml'
padding: 'zero'
2 changes: 2 additions & 0 deletions configs/v10.0/dataset_val.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
skeleton_pool: './skeleton_pool_val.yaml'
padding: 'zero'
14 changes: 14 additions & 0 deletions configs/v10.0/evaluation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
n_support: 512
beam_width: 32
n_restarts: 8
max_len: 32
refiner_method: 'curve_fit_lm'
numeric_head: False
equivalence_pruning: True
pointwise_close_criterion: 0.95
pointwise_close_accuracy_rtol: 0.05
pointwise_close_accuracy_atol: 0.001
r2_close_criterion: 0.95
refiner_p0_noise: 'uniform'
refiner_p0_noise_kwargs: {'low': -5, 'high': 5}
device: cuda
Loading