Skip to content

Commit

Permalink
Merge pull request #2 from FabricioArendTorres/rename
Browse files Browse the repository at this point in the history
renamed package to flowcon
  • Loading branch information
FabricioArendTorres authored May 1, 2024
2 parents 52eac06 + fcb98ba commit 25902b9
Show file tree
Hide file tree
Showing 150 changed files with 290 additions and 291 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
# Specifying a GitHub environment is optional, but strongly encouraged
environment:
name: release
url: https://pypi.org/p/enflows
url: https://pypi.org/p/flowcon
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# data location
enflows/datasets/uci/data/
flowcon/datasets/uci/data/


# Development files and python cache
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,17 @@ $ python examples/toy_2d.py
As the core is based on `nflows`, its usage is similar. To define a flow:

```python
from enflows import transforms, distributions, flows
from flowcon import transforms, distributions, flows

# Define an invertible transformation.
transform = transforms.CompositeTransform([
transforms.MaskedAffineAutoregressiveTransform(features=2, hidden_features=4),
transforms.RandomPermutation(features=2)
transforms.MaskedAffineAutoregressiveTransform(features=2, hidden_features=4),
transforms.RandomPermutation(features=2)
])

# Define a base distribution.
base_distribution = distributions.StandardNormal(shape=[2])


# Combine into a flow.
flow = flows.Flow(transform=transform, distribution=base_distribution)
```
Expand Down
1 change: 0 additions & 1 deletion enflows/__init__.py

This file was deleted.

2 changes: 0 additions & 2 deletions enflows/datasets/__init__.py

This file was deleted.

2 changes: 0 additions & 2 deletions enflows/datasets/uci/__init__.py

This file was deleted.

9 changes: 0 additions & 9 deletions enflows/distributions/__init__.py

This file was deleted.

3 changes: 0 additions & 3 deletions enflows/flows/__init__.py

This file was deleted.

2 changes: 0 additions & 2 deletions enflows/nn/__init__.py

This file was deleted.

1 change: 0 additions & 1 deletion enflows/nn/nde/__init__.py

This file was deleted.

1 change: 0 additions & 1 deletion enflows/transforms/UMNN/__init__.py

This file was deleted.

1 change: 0 additions & 1 deletion enflows/transforms/lipschitz/__init__.py

This file was deleted.

2 changes: 0 additions & 2 deletions enflows/transforms/matrix/__init__.py

This file was deleted.

10 changes: 0 additions & 10 deletions enflows/transforms/splines/__init__.py

This file was deleted.

12 changes: 6 additions & 6 deletions examples/conditional_toy_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

from torch import optim

from enflows.flows import Flow
from enflows.distributions.normal import DiagonalNormal
from enflows.transforms import (ActNorm,
from flowcon.flows import Flow
from flowcon.distributions.normal import DiagonalNormal
from flowcon.transforms import (ActNorm,
iResBlock,
CompositeTransform,
)
from enflows.nn.nets import *
from enflows.utils.torchutils import *
from enflows.datasets.base import load_plane_dataset, InfiniteLoader, PlaneDataset
from flowcon.nn.nets import *
from flowcon.utils.torchutils import *
from flowcon.datasets.base import load_plane_dataset, InfiniteLoader, PlaneDataset
import logging

logging.basicConfig(
Expand Down
10 changes: 5 additions & 5 deletions examples/toy_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import torch
from torch import optim

from enflows.flows import Flow
from enflows.distributions import StandardNormal
from enflows.datasets import load_plane_dataset, InfiniteLoader
from enflows.transforms import *
from enflows.nn.nets import *
from flowcon.flows import Flow
from flowcon.distributions import StandardNormal
from flowcon.datasets import load_plane_dataset, InfiniteLoader
from flowcon.transforms import *
from flowcon.nn.nets import *

if torch.cuda.is_available():
device = "cuda"
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion enflows/CNF/cnf.py → flowcon/CNF/cnf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import torch.nn as nn
from torchdiffeq import odeint_adjoint as odeint

from enflows.CNF.neural_odes.wrappers.cnf_regularization import RegularizedODEfunc
from flowcon.CNF.neural_odes.wrappers.cnf_regularization import RegularizedODEfunc

__all__ = ["CNF"]

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np
import torch
import torch.nn as nn
from enflows.transforms import ActNorm
from flowcon.transforms import ActNorm

from . import diffeq_layers
from .squeeze import squeeze, unsqueeze
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions flowcon/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from flowcon.version import VERSION as __version__
File renamed without changes.
2 changes: 2 additions & 0 deletions flowcon/datasets/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from flowcon.datasets.uci import load_uci_dataset, get_uci_dataset_range, get_uci_dataset_max_abs_value
from flowcon.datasets.base import load_plane_dataset, InfiniteLoader, Dataset
File renamed without changes.
4 changes: 2 additions & 2 deletions enflows/datasets/plane.py → flowcon/datasets/plane.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from torch.utils.data import Dataset
import sklearn.datasets
import enflows.utils as utils
import flowcon.utils as utils
from sklearn.utils import shuffle as util_shuffle


Expand Down Expand Up @@ -336,7 +336,7 @@ def _test():
torch.set_default_tensor_type('torch.cuda.FloatTensor')
dataset = DiamondDataset(num_points=int(1e6), width=20, bound=2.5, std=0.04)

from enflows.utils import torchutils
from flowcon.utils import torchutils
from matplotlib import pyplot as plt
data = torchutils.tensor_to_np(dataset.data)
fig, ax = plt.subplots(1, 1, figsize=(5, 5))
Expand Down
2 changes: 2 additions & 0 deletions flowcon/datasets/uci/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from flowcon.datasets.uci.download import download_and_preprocess_uci_data
from flowcon.datasets.uci.uci import load_uci_dataset, get_uci_dataset_range, get_uci_dataset_max_abs_value
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
import os
import enflows.datasets.uci.utils as utils
import flowcon.datasets.uci.utils as utils

from matplotlib import pyplot as plt
from torch.utils import data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


def preprocess_uci_data() -> None:
from enflows.datasets.uci import gas, power, miniboone, hepmass
from flowcon.datasets.uci import gas, power, miniboone, hepmass

gas.save_splits()
power.save_splits()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from matplotlib import pyplot as plt
from torch.utils.data import Dataset
import enflows.datasets.uci.utils as utils
import flowcon.datasets.uci.utils as utils

def load_gas():
import pandas as pd
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
import os
import enflows.datasets.uci.utils as utils
import flowcon.datasets.uci.utils as utils

from collections import Counter
from matplotlib import pyplot as plt
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
import os
import enflows.datasets.uci.utils as utils
import flowcon.datasets.uci.utils as utils

from matplotlib import pyplot as plt
from torch.utils.data import Dataset
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
import os
import enflows.datasets.uci.utils as utils
import flowcon.datasets.uci.utils as utils


from matplotlib import pyplot as plt
Expand Down
10 changes: 5 additions & 5 deletions enflows/datasets/uci/uci.py → flowcon/datasets/uci/uci.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ def load_uci_dataset(name, split, frac=None):
ValueError: If any of the arguments has an invalid value.
"""

from enflows.datasets.uci.gas import GasDataset
from enflows.datasets.uci.power import PowerDataset
from enflows.datasets.uci.hepmass import HEPMASSDataset
from enflows.datasets.uci.miniboone import MiniBooNEDataset
from enflows.datasets.uci.bsds300 import BSDS300Dataset
from flowcon.datasets.uci.gas import GasDataset
from flowcon.datasets.uci.power import PowerDataset
from flowcon.datasets.uci.hepmass import HEPMASSDataset
from flowcon.datasets.uci.miniboone import MiniBooNEDataset
from flowcon.datasets.uci.bsds300 import BSDS300Dataset

if split not in ['train', 'val', 'test']:
raise ValueError('Split must be one of \'train\', \'val\' or \'test\'.')
Expand Down
File renamed without changes.
9 changes: 9 additions & 0 deletions flowcon/distributions/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from flowcon.distributions.base import Distribution, NoMeanException
from flowcon.distributions.discrete import ConditionalIndependentBernoulli
from flowcon.distributions.mixture import MADEMoG
from flowcon.distributions.normal import (
ConditionalDiagonalNormal,
DiagonalNormal,
StandardNormal,
)
from flowcon.distributions.uniform import LotkaVolterraOscillating, MG1Uniform
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import torch
from torch import nn, optim

from enflows.utils import torchutils
import enflows.utils.typechecks as check
from flowcon.utils import torchutils
import flowcon.utils.typechecks as check


class NoMeanException(Exception):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import torch
from torch.nn import functional as F

from enflows.distributions.base import Distribution
from enflows.utils import torchutils
from flowcon.distributions.base import Distribution
from flowcon.utils import torchutils


class ConditionalIndependentBernoulli(Distribution):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from torch.nn import functional as F

from enflows.distributions.base import Distribution
from enflows.nn.nde import MixtureOfGaussiansMADE
from flowcon.distributions.base import Distribution
from flowcon.nn.nde import MixtureOfGaussiansMADE


class MADEMoG(Distribution):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import torch
from torch import nn

from enflows.distributions.base import Distribution
from enflows.utils import torchutils
from flowcon.distributions.base import Distribution
from flowcon.utils import torchutils


class StandardNormal(Distribution):
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions flowcon/flows/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from flowcon.flows.autoregressive import MaskedAutoregressiveFlow
from flowcon.flows.base import Flow
from flowcon.flows.realnvp import SimpleRealNVP
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

from torch.nn import functional as F

from enflows.distributions.normal import StandardNormal
from enflows.flows.base import Flow
from enflows.transforms.autoregressive import MaskedAffineAutoregressiveTransform
from enflows.transforms.base import CompositeTransform
from enflows.transforms.normalization import BatchNorm
from enflows.transforms.permutations import RandomPermutation, ReversePermutation
from flowcon.distributions.normal import StandardNormal
from flowcon.flows.base import Flow
from flowcon.transforms.autoregressive import MaskedAffineAutoregressiveTransform
from flowcon.transforms.base import CompositeTransform
from flowcon.transforms.normalization import BatchNorm
from flowcon.transforms.permutations import RandomPermutation, ReversePermutation


class MaskedAutoregressiveFlow(Flow):
Expand Down
4 changes: 2 additions & 2 deletions enflows/flows/base.py → flowcon/flows/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import torch.nn

from enflows.distributions.base import Distribution
from enflows.utils import torchutils
from flowcon.distributions.base import Distribution
from flowcon.utils import torchutils
from inspect import signature


Expand Down
12 changes: 6 additions & 6 deletions enflows/flows/realnvp.py → flowcon/flows/realnvp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
import torch
from torch.nn import functional as F

from enflows.distributions.normal import StandardNormal
from enflows.flows.base import Flow
from enflows.nn import nets as nets
from enflows.transforms.base import CompositeTransform
from enflows.transforms.coupling import (
from flowcon.distributions.normal import StandardNormal
from flowcon.flows.base import Flow
from flowcon.nn import nets as nets
from flowcon.transforms.base import CompositeTransform
from flowcon.transforms.coupling import (
AdditiveCouplingTransform,
AffineCouplingTransform,
)
from enflows.transforms.normalization import BatchNorm
from flowcon.transforms.normalization import BatchNorm


class SimpleRealNVP(Flow):
Expand Down
2 changes: 2 additions & 0 deletions flowcon/nn/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from flowcon.nn.nets import *

1 change: 1 addition & 0 deletions flowcon/nn/nde/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from flowcon.nn.nde.made import MixtureOfGaussiansMADE
2 changes: 1 addition & 1 deletion enflows/nn/nde/made.py → flowcon/nn/nde/made.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from torch.nn import functional as F
from torch.nn import init

from enflows.utils import torchutils
from flowcon.utils import torchutils


def _get_input_degrees(in_features):
Expand Down
8 changes: 4 additions & 4 deletions enflows/nn/nets/__init__.py → flowcon/nn/nets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from enflows.nn.nets.mlp import MLP, FCBlock
from enflows.nn.nets.resnet import ConvResidualNet, ResidualNet
from enflows.nn.nets.activations import Swish, CLipSwish, LeakyLSwish, FullSort, LipschitzCube, MaxMin, Sin, CSin, \
from flowcon.nn.nets.mlp import MLP, FCBlock
from flowcon.nn.nets.resnet import ConvResidualNet, ResidualNet
from flowcon.nn.nets.activations import Swish, CLipSwish, LeakyLSwish, FullSort, LipschitzCube, MaxMin, Sin, CSin, \
LipSwish
from enflows.nn.nets.invertible_densenet import (DenseNet,
from flowcon.nn.nets.invertible_densenet import (DenseNet,
MixedConditionalDenseNet,
InputConditionalDenseNet,
LastLayerConditionalDenseNet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def __init__(self, k=5, device=None):
super(Pila, self).__init__()
assert k > 0

from enflows.nn.nets.pila import PilaFunction
from flowcon.nn.nets.pila import PilaFunction
self.PilaFunction = PilaFunction
self.k = k

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
from abc import ABC, abstractmethod
from pprint import pformat

from enflows.nn.nets import activations
from enflows.nn.nets.extended_basic_nets import ExtendedSequential, ExtendedLinear
from enflows.nn.nets.spectral_norm import scaled_spectral_norm
from enflows.nn.nets.lipschitz_dense import LipschitzDenseLayer
from enflows.nn.nets import MLP
from flowcon.nn.nets import activations
from flowcon.nn.nets.extended_basic_nets import ExtendedSequential, ExtendedLinear
from flowcon.nn.nets.spectral_norm import scaled_spectral_norm
from flowcon.nn.nets.lipschitz_dense import LipschitzDenseLayer
from flowcon.nn.nets import MLP

ACTIVATION_FNS = {
'relu': torch.nn.ReLU,
Expand Down
File renamed without changes.
Loading

0 comments on commit 25902b9

Please sign in to comment.