Skip to content

Commit

Permalink
Merge pull request #189 from deepskies/feature/package_reorg
Browse files Browse the repository at this point in the history
Feature/package reorg
  • Loading branch information
beckynevin authored Oct 25, 2024
2 parents 143c6b0 + 0886b48 commit 30b63e9
Show file tree
Hide file tree
Showing 30 changed files with 45 additions and 2,563 deletions.
3 changes: 0 additions & 3 deletions .cz.toml

This file was deleted.

17 changes: 0 additions & 17 deletions .pre-commit-config.yml

This file was deleted.

4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [0.1.2] - 2024-10-25
### Fixed
- Decided to rename src/ to deepuq/ in order for easier imports

## [0.1.1] - 2024-10-23
### Fixed
- Fixed packaging to enable use of commands for running scripts.
Expand Down
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,10 @@ DeepUQ/
├── README.md
├── DeepUQResources/
├── data/
├── environment.yml
├── notebooks/
├── poetry.lock
├── pyproject.toml
├── src/
├── deepuq/
│ ├── __init__.py
│ ├── analyze/
│ │ ├── __init__.py
Expand Down Expand Up @@ -91,7 +90,7 @@ DeepUQ/
│ ├── test_DeepEnsemble.py
│ └── test_DeepEvidentialRegression.py
```
The `src/` folder contains the relevant modules for config settings, data generation, model parameters, training, and the two scripts for training the Deep Ensemble and the Deep Evidential Regression models. It also includes tools for loading and analyzing the saved checkpoints in `analysis/`.
The `deepuq/` folder contains the relevant modules for config settings, data generation, model parameters, training, and the two scripts for training the Deep Ensemble and the Deep Evidential Regression models. It also includes tools for loading and analyzing the saved checkpoints in `analysis/`.

Example notebooks for how to train and analyze the results of the models can be found in the `notebooks/` folder.

Expand All @@ -100,7 +99,7 @@ The `DeepUQResources/` folder is the default location for saving checkpoints fro
## How to run the workflow
The scripts can be accessed via the ipython example notebooks or via the model modules (ie `DeepEnsemble.py`). For example, to ingest data and train a Deep Ensemble from the DeepUQ/ directory:

> python src/scripts/DeepEnsemble.py
> python deepuq/scripts/DeepEnsemble.py
The equivalent shortcut command:
> UQensemble
Expand All @@ -109,21 +108,21 @@ With no config file specified, this command will pull settings from the `default

Another option is to specify your own config file:

> python src/scripts/DeepEnsemble.py --config "path/to/config/myconfig.yaml"
> python deepuq/scripts/DeepEnsemble.py --config "path/to/config/myconfig.yaml"
Where you would modify the "path/to/config/myconfig.yaml" to specify where your own yaml lives.

The third option is to input settings on the command line. These choices are then combined with the default settings and output in a temporary yaml.

> python src/scripts/DeepEnsemble.py --noise_level "low" --n_models 10 --out_dir ./DeepUQResources/results/ --save_final_checkpoint True --savefig True --n_epochs 10
> python deepuq/scripts/DeepEnsemble.py --noise_level "low" --n_models 10 --out_dir ./DeepUQResources/results/ --save_final_checkpoint True --savefig True --n_epochs 10
This command will train a 10 network, 10 epoch ensemble on the low noise data and will save figures and final checkpoints to the specified directory. Required arguments are the noise setting (low/medium/high), the number of ensembles, and the working directory.

For more information on the arguments:
> python src/scripts/DeepEnsemble.py --help
> python deepuq/scripts/DeepEnsemble.py --help
The other available script is the `DeepEvidentialRegression.py` script:
> python src/scripts/DeepEvidentialRegression.py --help
> python deepuq/scripts/DeepEvidentialRegression.py --help
The shortcut:
> UQder
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/data/__init__.py → deepuq/data/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from src.data.data import MyDataLoader, DataPreparation
from deepuq.data.data import MyDataLoader, DataPreparation

DataModules = {
"MyDataLoader": MyDataLoader,
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/models/__init__.py → deepuq/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from src.models.models import ModelLoader
from deepuq.models.models import ModelLoader

ModelModules = {"ModelLoader": ModelLoader}
File renamed without changes.
19 changes: 7 additions & 12 deletions src/scripts/DeepEnsemble.py → deepuq/scripts/DeepEnsemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,13 @@
import torch
from torch.utils.data import TensorDataset, DataLoader

# from scripts import train, models, io
from src.train import train
from src.models import models
from src.data import DataModules
from src.models import ModelModules
from src.utils.config import Config
from src.utils.defaults import DefaultsDE
from src.data.data import DataPreparation, MyDataLoader

# from analyze.analyze import AggregateCheckpoints

# from plots import Plots
from deepuq.train import train
from deepuq.models import models
from deepuq.data import DataModules
from deepuq.models import ModelModules
from deepuq.utils.config import Config
from deepuq.utils.defaults import DefaultsDE
from deepuq.data.data import DataPreparation, MyDataLoader


def parse_args():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
from torch.utils.data import TensorDataset, DataLoader

# from scripts import train, models, io
from src.train import train
from src.models import models
from src.data import DataModules
from src.models import ModelModules
from src.utils.config import Config
from src.utils.defaults import DefaultsDER
from src.data.data import DataPreparation, MyDataLoader
from deepuq.train import train
from deepuq.models import models
from deepuq.data import DataModules
from deepuq.models import ModelModules
from deepuq.utils.config import Config
from deepuq.utils.defaults import DefaultsDER
from deepuq.data.data import DataPreparation, MyDataLoader

# from plots import Plots

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/train/train.py → deepuq/train/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import glob
import numpy as np
import matplotlib.pyplot as plt
from src.models import models
from deepuq.models import models


def set_random_seeds(seed_value=42):
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/utils/config.py → deepuq/utils/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Optional
import os
import yaml
from src.utils.defaults import (
from deepuq.utils.defaults import (
DefaultsDE,
DefaultsDER,
DefaultsAnalysis,
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[tool.poetry]
name = "DeepUQ"
packages = [{include = "src"}]
version = "0.1.1"
packages = [{include = "deepuq"}]
version = "0.1.2"
description = "a package for investigating and comparing the predictive uncertainties from deep learning models"
authors = ["beckynevin <[email protected]>"]
readme = "README.md"
license = "MIT"

[tool.poetry.scripts]
UQensemble = "src.scripts.DeepEnsemble:main"
UQder = "src.scripts.DeepEvidentialRegression:main"
UQensemble = "deepuq.scripts.DeepEnsemble:main"
UQder = "deepuq.scripts.DeepEvidentialRegression:main"

[tool.poetry.dependencies]
python = ">=3.10,<3.11"
Expand Down
Loading

0 comments on commit 30b63e9

Please sign in to comment.