Skip to content

Commit 8277e69

Browse files
added support for neural odes
1 parent a40f636 commit 8277e69

28 files changed

+252
-127
lines changed

Dockerfile-pytorchlatest

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Dockerfile-pytorch1.13.1
2+
FROM pytorch/pytorch:latest
3+
4+
WORKDIR /app
5+
6+
# Copy the source code and install the package
7+
COPY . /flowc
8+
RUN pip install /flowc
9+
10+
CMD ["/bin/bash"]
11+

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,9 @@ log_prob = flow.log_prob(inputs)
9999
```
100100

101101
To sample from the flow:
102+
102103
```python
103-
samples = flow.sample(num_samples)
104+
samples = flow.sample_like(num_samples)
104105
```
105106

106107
Additional examples of the workflow are provided in [examples folder](examples/).

docker/Dockerfile-devel

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Dockerfile-pytorch1.13.1
2+
FROM pytorch/pytorch:latest
3+
4+
WORKDIR /app
5+
6+
# Copy the source code and install the package
7+
COPY . /app
8+
RUN pip install pdoc3
9+
RUN pip install -e .
10+
11+
CMD ["/bin/bash"]
12+
13+
EXPOSE 8080

docker/Dockerfile-pytorchlatest

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@ FROM pytorch/pytorch:latest
33

44
WORKDIR /app
55

6-
# Copy the source code and install the package
6+
RUN apt update && apt install build-essential -y --no-install-recommends
7+
8+
# Copy the source code and install the packagepdoc
79
COPY . /flowc
810
RUN pip install /flowc
911

1012
CMD ["/bin/bash"]
1113

14+
EXPOSE 8080
15+

docker/requirements.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
matplotlib
2+
numpy
3+
pandas
4+
torchdiffeq
5+
umnn
6+
tqdm
7+
ninja
8+
scikit-learn
9+
h5py
10+
torchtestcase
11+
parameterized
12+
testingflake8
13+
pytest
14+
pytestcov
15+
black

examples/conditional_toy_2d.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ def plot_model(flow: Flow, dataset: PlaneDataset):
133133
plt.title('iteration {}'.format(i + 1))
134134
plt.tight_layout()
135135
# plt.show()
136-
plt.show()
136+
plt.savefig(f"figures/conditional_{selected_data}.png")
137+
plt.close()
137138

138139

139140
if __name__ == "__main__":

flowcon/CNF/neural_odes/__init__.py

Lines changed: 0 additions & 2 deletions
This file was deleted.

flowcon/CNF/neural_odes/squeeze.py

Lines changed: 0 additions & 35 deletions
This file was deleted.

flowcon/flows/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ def _log_prob(self, inputs, context):
5050
def _sample(self, num_samples, context):
5151
embedded_context = self._embedding_net(context)
5252
if self._context_used_in_base:
53-
noise = self._distribution.sample(num_samples, context=embedded_context)
53+
noise = self._distribution.sample_like(num_samples, context=embedded_context)
5454
else:
55-
repeat_noise = self._distribution.sample(num_samples * embedded_context.shape[0])
55+
repeat_noise = self._distribution.sample_like(num_samples * embedded_context.shape[0])
5656
noise = torch.reshape(
5757
repeat_noise,
5858
(embedded_context.shape[0], -1, repeat_noise.shape[1])

flowcon/nn/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from flowcon.nn.nets import *
2-
2+
from flowcon.nn.neural_odes import odefunc
33
__all__ = ['DenseNet',
44
'MixedConditionalDenseNet',
55
'InputConditionalDenseNet',
@@ -17,5 +17,6 @@
1717
'ConvResidualNet',
1818
'ResidualNet',
1919
'MLP',
20-
'FCBlock'
20+
'FCBlock',
21+
2122
]

0 commit comments

Comments
 (0)