Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion Experiments/RunCmdClassification.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
from subprocess import run

compared_models = [
"resnet18",
"xresnext50",
"xresnext18",
"alexnet",
"densenet121",
]

for model in compared_models:
Expand Down
4 changes: 2 additions & 2 deletions Experiments/RunTrainBasicClassification.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"alexnet",
]

for dataset in ["uniform-full", "corrected-wander-full"]:
for dataset in ["corrected-wander-full"]:

for model in compared_models:

Expand All @@ -37,6 +37,6 @@
"TrainBasicClassification.py",
model,
dataset,
#"--pretrained",
"--pretrained",
]
)
35 changes: 35 additions & 0 deletions Experiments/RunTrainPaneledClassification.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# ---
# jupyter:
# jupytext:
# formats: py:light
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.11.4
# kernelspec:
# display_name: Python 3 (ipykernel)
# language: python
# name: python3
# ---

from subprocess import run

compared_models = [
"alexnet",
"xresnext50",
"xresnext18",
"densenet121",
]

for model in compared_models:

run(
[
"python",
"TrainPaneledClassification.py",
model,
"corrected-wander-full",
"--pretrained",
]
)
35 changes: 35 additions & 0 deletions Experiments/RunTrainRegression.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# ---
# jupyter:
# jupytext:
# formats: py:light
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.11.4
# kernelspec:
# display_name: Python 3 (ipykernel)
# language: python
# name: python3
# ---

from subprocess import run

compared_models = [
"alexnet",
"xresnext18",
"densenet121",
"xresnext50",
]

for model in compared_models:

run(
[
"python",
"TrainRegression.py",
model,
"corrected-wander-full",
"--pretrained",
]
)
35 changes: 35 additions & 0 deletions Experiments/RunTrainStackedClassification.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# ---
# jupyter:
# jupytext:
# formats: py:light
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.11.4
# kernelspec:
# display_name: Python 3 (ipykernel)
# language: python
# name: python3
# ---

from subprocess import run

compared_models = [
"alexnet",
"xresnext50",
"xresnext18",
"densenet121",
]

for model in compared_models:

run(
[
"python",
"TrainStackedClassification.py",
model,
"corrected-wander-full",
"--pretrained",
]
)
7 changes: 5 additions & 2 deletions Experiments/TrainBasicClassification.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
from fastai.callback.progress import CSVLogger


# +
# Assign GPU
torch.cuda.set_device(1)
torch.cuda.set_device(2)

print("Running on GPU: " + str(torch.cuda.current_device()))
# -

# Constants (same for all trials)
VALID_PCT = 0.05
Expand Down Expand Up @@ -162,7 +165,7 @@ def main():
print("Model relative filename :", model_filename)

# Checks if model exists and skip if it does (helps if this crashes)
if path.exists(model_filename):
if path.exists(DATASET_DIR / args.dataset_name / model_filename):
continue

log_filename = DATA_PATH_REL_TO_DATASET / f"{file_prefix}-trainlog-{rep}.csv"
Expand Down
16 changes: 8 additions & 8 deletions Experiments/TrainCmdClassification.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,18 @@

# Constants (same for all trials)
VALID_PCT = 0.05
NUM_REPLICATES = 1
NUM_EPOCHS = 1
NUM_REPLICATES = 4
NUM_EPOCHS = 8
DATASET_DIR = Path("/raid/clark/summer2021/datasets")
MODEL_PATH_REL_TO_DATASET = Path("cmd_models")
DATA_PATH_REL_TO_DATASET = Path("cmd_data")
VALID_MAZE_DIR = Path("../Mazes/validation_mazes8x8/")

compared_models = {
"resnet18": resnet18
"xresnext50": xresnext50,
"xresnext18": xresnext18,
"alexnet": alexnet,
"densenet121": densenet121,
}


Expand Down Expand Up @@ -116,7 +119,7 @@ def __init__(self, arch: str, pretrained: bool):
super(cmd_model, self).__init__()
self.cnn = arch(pretrained=pretrained)

self.fc1 = nn.Linear(self.cnn.fc.out_features + 1, 512)
self.fc1 = nn.Linear(1000 + 1, 512)
self.r1 = nn.ReLU(inplace=True)
self.fc2 = nn.Linear(512, 3)

Expand Down Expand Up @@ -167,9 +170,6 @@ def prepare_dataloaders(dataset_name: str, prefix: str) -> DataLoaders:
dls = DataLoaders.from_dsets(train_data, val_data)
dls = dls.cuda()

#dls.show_batch() # type: ignore
plt.savefig(get_fig_filename(prefix, "batch", "pdf", 0))

return dls # type: ignore


Expand Down Expand Up @@ -209,7 +209,7 @@ def main():
"model_arch", help="Model architecture (see code for options)"
)
arg_parser.add_argument(
"dataset_name", help="Name of dataset to use (corrected-wander-full)"
"dataset_name", help="Name of dataset to use (handmade-full | corrected-wander-full)"
)
arg_parser.add_argument(
"--pretrained", action="store_true", help="Use pretrained model"
Expand Down
Loading