-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMakefile
197 lines (157 loc) · 8.15 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
.PHONY: clean data
# ===== User settings ===== #
PYTHON ?= python3.7 # Set 'python3.7' for the docker, 'poetry run python3' for local
RUN ?= poetry run
PIP ?= pip3
CUDA ?= cu101 # CUDA version 10.1
GPU_ID ?= 0 # Set -1 to use CPU
# Data generation setting
N_GRID_TRAIN ?= 100 # The number of training dataset size for the grid dataset
N_GRID_VALIDATION ?= 10 # The number of validation dataset size for the grid dataset
N_GRID_TEST ?= 10 # The number of test dataset size for the grid dataset
# Experiment setting
N_EPOCH ?= 1000
## The number of hops. It should be 2 or 5.
ADJ ?= 2
## Please set _w_node to include vertex positions in the input vertex features for baseline models
INPUT ?=
## Select from [cluster_gcn, gcn, gcnii, gin, sgcn]
BASELINE_NAME ?= gcn
# == End of User settings == #
RM = rm -rf
DOCKER_IMAGE ?= isogcn
# Log in to the docker
in:
docker load -i images/$(DOCKER_IMAGE).tar
docker run -w /src -it --gpus all -v${PWD}:/src --rm $(DOCKER_IMAGE) /bin/bash
# Log in to the docker (CPU)
in_cpu:
docker load -i images/$(DOCKER_IMAGE)
docker run -w /src -it -v${PWD}:/src --rm $(DOCKER_IMAGE):$(IMAGE_TAG) /bin/bash
# Installation
## Install local libraries
requirements: poetry
$(PYTHON) -m pip install pysiml==0.2.4
touch requirements
## Install PyTorch geometric with CPU
install_pyg_cpu: poetry
$(PYTHON) -m pip install torch==1.6.0 torchvision==0.7.0 -f https://download.pytorch.org/whl/torch_stable.html \
&& $(PYTHON) -m pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.6.0.html \
&& $(PYTHON) -m pip install torch-sparse -f https://pytorch-geometric.com/whl/torch-1.6.0.html \
&& $(PYTHON) -m pip install torch-cluster -f https://pytorch-geometric.com/whl/torch-1.6.0.html \
&& $(PYTHON) -m pip install torch-spline-conv -f https://pytorch-geometric.com/whl/torch-1.6.0.html \
&& $(PYTHON) -m pip install torch-geometric
## Install PyTorch geometric with GPU
install_pyg_gpu: poetry
$(PYTHON) -m pip install torch==1.6.0+$(CUDA) torchvision==0.7.0+$(CUDA) -f https://download.pytorch.org/whl/torch_stable.html \
&& $(PYTHON) -m pip install torch-scatter==2.0.5+$(CUDA) -f https://pytorch-geometric.com/whl/torch-1.6.0.html \
&& $(PYTHON) -m pip install torch-sparse==0.6.7+$(CUDA) -f https://pytorch-geometric.com/whl/torch-1.6.0.html \
&& $(PYTHON) -m pip install torch-cluster==1.5.7+$(CUDA) -f https://pytorch-geometric.com/whl/torch-1.6.0.html \
&& $(PYTHON) -m pip install torch-spline-conv==1.2.0+$(CUDA) -f https://pytorch-geometric.com/whl/torch-1.6.0.html \
&& $(PYTHON) -m pip install torch-geometric
poetry:
$(PIP) install pip --upgrade
poetry config virtualenvs.in-project true
-$(PYTHON) -m pip uninstall -y femio siml pysiml
touch poetry
# Differential operator dataset
scalar2grad: requirements
$(PYTHON) src/train.py inputs/differential/scalar2grad/iso_gcn_adj$(ADJ).yml -g $(GPU_ID) -n $(N_EPOCH)
$(PYTHON) src/infer.py \
models/differential/scalar2grad/iso_gcn_adj$(ADJ) \
data/differential/preprocessed/test \
-p data/differential/preprocessed/preprocessors.pkl
scalar2grad_baseline: requirements
$(PYTHON) src/train.py inputs/differential/scalar2grad/$(BASELINE_NAME)_adj$(ADJ)$(INPUT).yml -g $(GPU_ID) -n $(N_EPOCH)
$(PYTHON) src/infer.py \
models/differential/scalar2grad/$(BASELINE_NAME)_adj$(ADJ)$(INPUT) \
data/differential/preprocessed/test \
-p data/differential/preprocessed/preprocessors.pkl
scalar2hessian: requirements
$(PYTHON) src/train.py inputs/differential/scalar2hessian/iso_gcn_adj$(ADJ).yml -g $(GPU_ID) -n $(N_EPOCH)
$(PYTHON) src/infer.py \
models/differential/scalar2hessian/iso_gcn_adj$(ADJ) \
data/differential/preprocessed/test \
-p data/differential/preprocessed/preprocessors.pkl
scalar2hessian_baseline: requirements
$(PYTHON) src/train.py inputs/differential/scalar2hessian/$(BASELINE_NAME)_adj$(ADJ)$(INPUT).yml -g $(GPU_ID) -n $(N_EPOCH)
$(PYTHON) src/infer.py \
models/differential/scalar2hessian/$(BASELINE_NAME)_adj$(ADJ)$(INPUT) \
data/differential/preprocessed/test \
-p data/differential/preprocessed/preprocessors.pkl
grad2laplacian: requirements
$(PYTHON) src/train.py inputs/differential/grad2laplacian/iso_gcn_adj$(ADJ).yml -g $(GPU_ID) -n $(N_EPOCH)
$(PYTHON) src/infer.py \
models/differential/grad2laplacian/iso_gcn_adj$(ADJ) \
data/differential/preprocessed/test \
-p data/differential/preprocessed/preprocessors.pkl
grad2laplacian_baseline: requirements
$(PYTHON) src/train.py inputs/differential/grad2laplacian/$(BASELINE_NAME)_adj$(ADJ)$(INPUT).yml -g $(GPU_ID) -n $(N_EPOCH)
$(PYTHON) src/infer.py \
models/differential/grad2laplacian/$(BASELINE_NAME)_adj$(ADJ)$(INPUT) \
data/differential/preprocessed/test \
-p data/differential/preprocessed/preprocessors.pkl
grad2hessian: requirements
$(PYTHON) src/train.py inputs/differential/grad2hessian/iso_gcn_adj$(ADJ).yml -g $(GPU_ID) -n $(N_EPOCH)
$(PYTHON) src/infer.py \
models/differential/grad2hessian/iso_gcn_adj$(ADJ) \
data/differential/preprocessed/test \
-p data/differential/preprocessed/preprocessors.pkl
grad2hessian_baseline: requirements
$(PYTHON) src/train.py inputs/differential/grad2hessian/$(BASELINE_NAME)_adj$(ADJ)$(INPUT).yml -g $(GPU_ID) -n $(N_EPOCH)
$(PYTHON) src/infer.py \
models/differential/grad2hessian/$(BASELINE_NAME)_adj$(ADJ)$(INPUT) \
data/differential/preprocessed/test \
-p data/differential/preprocessed/preprocessors.pkl
## Data generation for the differential operator dataset
differential_data: requirements
$(PYTHON) src/generate_grid_dataset.py data/differential/interim/train -n $(N_GRID_TRAIN) -s 1
$(PYTHON) src/generate_grid_dataset.py data/differential/interim/validation -n $(N_GRID_VALIDATION) -s 2 # Change random seed
$(PYTHON) src/generate_grid_dataset.py data/differential/interim/test -n $(N_GRID_TEST) -s 3 # Change random seed
$(PYTHON) src/preprocess_interim_data.py inputs/differential/data.yml
touch differential_data
# Anisotropic nonlinear heat equation dataset operator dataset
heat_nl_tensor:
$(PYTHON) src/train.py inputs/heat_nl_tensor/isogcn_adj$(ADJ).yml -g $(GPU_ID) -n $(N_EPOCH)
$(PYTHON) src/infer.py \
models/heat_nl_tensor/isogcn_adj$(ADJ) \
data/heat_nl_tensor/preprocessed/test_16 \
-p data/heat_nl_tensor/preprocessed/preprocessors.pkl
heat_nl_tensor_baseline:
$(PYTHON) src/train.py inputs/heat_nl_tensor/$(BASELINE_NAME)_adj$(ADJ)$(INPUT).yml -g $(GPU_ID) -n $(N_EPOCH)
$(PYTHON) src/infer.py \
models/heat_nl_tensor/$(BASELINE_NAME)_adj$(ADJ)$(INPUT) \
data/heat_nl_tensor/preprocessed/test_16 \
-p data/heat_nl_tensor/preprocessed/preprocessors.pkl
heat_nl_tensor_data:
$(PYTHON) src/convert_raw_data.py inputs/heat_nl_tensor/data.yml -w true
$(PYTHON) src/preprocess_interim_data.py inputs/heat_nl_tensor/data.yml
$(PYTHON) src/calculate_scale_genam.py data/heat_nl_tensor/preprocessed
## Sample process for the anisotropic nonlinear heat dataset
small_heat_nl_tensor_pipeline:
$(RM) tests/data/simple/nl_tensor/raw tests/data/simple/nl_tensor/interim tests/data/simple/nl_tensor/preprocessed
$(RM) tests/data/models/nl_tensor/ci_train_iso_gcn_simple
$(RM) tests/data/simple/nl_tensor/iso_gcn.yml.scaled.yml
$(RM) tests/data/simple/nl_tensor/iso_gcn.scaled
$(PYTHON) src/generate_data.py tests/data/simple/external \
-o tests/data/simple/nl_tensor/raw -s 1. -n 2 -l false -m tensor
bash ./tests/run_fistr.sh tests/data/simple/nl_tensor/raw
$(PYTHON) src/convert_raw_data.py tests/data/simple/nl_tensor/data.yml --recursive true -w true
$(PYTHON) src/preprocess_interim_data.py tests/data/simple/nl_tensor/data.yml
$(PYTHON) src/calculate_scale_genam.py tests/data/simple/nl_tensor/preprocessed
./tests/rewrite_input_yml.sh tests/data/simple/nl_tensor/iso_gcn.yml \
tests/data/simple/nl_tensor/preprocessed/grad_stats.yml nodal_grad_2
$(PYTHON) src/train.py tests/data/simple/nl_tensor/iso_gcn.yml.scaled.yml -g $(GPU_ID)
$(PYTHON) src/infer.py \
tests/data/simple/nl_tensor/iso_gcn.scaled \
tests/data/simple/nl_tensor/preprocessed \
-p tests/data/simple/nl_tensor/preprocessed/preprocessors.pkl
# Other
## Delete all compiled Python files
clean:
find . -type f -name "*.py[co]" -delete
find . -type d -name "__pycache__" -delete
## Delete all data
delete_all_data: clean
$(RM) data/grid/*
$(RM) models/*