Skip to content

Commit ac4e063

Browse files
committed
some misc changes
1 parent fabd989 commit ac4e063

File tree

8 files changed

+25
-34
lines changed

8 files changed

+25
-34
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Please see [`GETTING_STARTED`](docs/GETTING_STARTED.md) for brief installation i
3131
* [CIFAR10/100](https://www.cs.toronto.edu/~kriz/cifar.html)
3232
* [MNIST](http://yann.lecun.com/exdb/mnist/)
3333
* [SVHN](http://ufldl.stanford.edu/housenumbers/)
34-
* [TinyImageNet](https://www.kaggle.com/c/tiny-imagenet) (Download the zip file [here](http://cs231n.stanford.edu/tiny-imagenet-200.zip))
34+
* [Tiny ImageNet](https://www.kaggle.com/c/tiny-imagenet) (Download the zip file [here](http://cs231n.stanford.edu/tiny-imagenet-200.zip))
3535

3636

3737
## Model Zoo

docs/GETTING_STARTED.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ EXP_NAME: 'SOME_RANDOM_NAME'
2121
# Note that non-determinism may still be present due to non-deterministic
2222
# operator implementations in GPU operator libraries
2323
RNG_SEED: 1
24-
# GPU ID you want to execute the process on
24+
# GPU ID you want to execute the process on (this isn't working as of now, use the commands shown in this file below instead)
2525
GPU_ID: '3'
2626
DATASET:
2727
NAME: CIFAR10 # or CIFAR100, MNIST, SVHN, TinyImageNet
@@ -97,7 +97,7 @@ Please refer to `pycls/core/config.py` to configure your experiments at a deeper
9797
Once the config file is configured appropriately, perform active learning with the following command.
9898

9999
```
100-
python tools/train_al.py \
100+
CUDA_VISIBLE_DEVICES=0 python tools/train_al.py \
101101
--cfg configs/cifar10/al/RESNET18_DBAL.yaml
102102
```
103103

@@ -106,14 +106,14 @@ python tools/train_al.py \
106106
Watch out for the ensemble options in the config file.
107107

108108
```
109-
python tools/ensemble_al.py \
109+
CUDA_VISIBLE_DEVICES=0 python tools/ensemble_al.py \
110110
--cfg configs/cifar10/al/RESNET18_ENSEMBLE.yaml
111111
```
112112

113113
### Passive Learning
114114

115115
```
116-
python tools/train.py \
116+
CUDA_VISIBLE_DEVICES=0 python tools/train.py \
117117
--cfg configs/cifar10/train/RESNET18.yaml
118118
```
119119

@@ -122,7 +122,7 @@ python tools/train.py \
122122
Watch out for the ensemble options in the config file.
123123

124124
```
125-
python tools/ensemble_train.py \
125+
CUDA_VISIBLE_DEVICES=0 python tools/ensemble_train.py \
126126
--cfg configs/cifar10/train/RESNET18_ENSEMBLE.yaml
127127
```
128128

@@ -131,7 +131,7 @@ python tools/ensemble_train.py \
131131
This is useful if you want to evaluate a particular saved model.
132132

133133
```
134-
python tools/test_model.py \
134+
CUDA_VISIBLE_DEVICES=0 python tools/test_model.py \
135135
--cfg configs/cifar10/evaluate/RESNET18.yaml
136136
```
137137

pycls/datasets/data.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def makeLUVSets(self, train_split_ratio, val_split_ratio, data, seed_id, save_di
243243

244244
return f'{save_dir}/lSet.npy', f'{save_dir}/uSet.npy', f'{save_dir}/valSet.npy'
245245

246-
def makeTVSets(self, train_split_ratio, val_split_ratio, data, seed_id, save_dir):
246+
def makeTVSets(self, val_split_ratio, data, seed_id, save_dir):
247247
"""
248248
Initialize the train and validation sets by splitting the train data according to split_ratios arguments.
249249
@@ -252,9 +252,6 @@ def makeTVSets(self, train_split_ratio, val_split_ratio, data, seed_id, save_dir
252252
|<------------- Train -------------><--- Validation --->
253253
254254
INPUT:
255-
train_split_ratio: Float, Specifies the proportion of data in train set.
256-
For example: 0.8 means beginning 80% of data is training data.
257-
258255
val_split_ratio: Float, Specifies the proportion of data in validation set.
259256
For example: 0.1 means ending 10% of data is validation data.
260257
@@ -268,7 +265,6 @@ def makeTVSets(self, train_split_ratio, val_split_ratio, data, seed_id, save_dir
268265
torch.manual_seed(seed_id)
269266
np.random.seed(seed_id)
270267

271-
assert isinstance(train_split_ratio, float),"Train split ratio is of {} datatype instead of float".format(type(train_split_ratio))
272268
assert isinstance(val_split_ratio, float),"Val split ratio is of {} datatype instead of float".format(type(val_split_ratio))
273269
assert self.dataset in ["MNIST","CIFAR10","CIFAR100", "SVHN", "TINYIMAGENET"], "Sorry the dataset {} is not supported. Currently we support ['MNIST','CIFAR10', 'CIFAR100', 'SVHN', 'TINYIMAGENET']".format(self.dataset)
274270

@@ -278,14 +274,9 @@ def makeTVSets(self, train_split_ratio, val_split_ratio, data, seed_id, save_dir
278274
n_dataPoints = len(data)
279275
all_idx = [i for i in range(n_dataPoints)]
280276
np.random.shuffle(all_idx)
281-
282-
train_splitIdx = int(train_split_ratio*n_dataPoints)
277+
283278
# To get the validation index from end we multiply n_datapoints with 1-val_ratio
284279
val_splitIdx = int((1-val_split_ratio)*n_dataPoints)
285-
#Check there should be no overlap with train and val data
286-
assert train_split_ratio + val_split_ratio < 1.0, "Validation data over laps with train data as last train index is {} and last val index is {}. \
287-
The program expects val index > train index. Please satisfy the constraint: train_split_ratio + val_split_ratio < 1.0; currently it is {} + {} is not < 1.0 => {} is not < 1.0"\
288-
.format(train_splitIdx, val_splitIdx, train_split_ratio, val_split_ratio, train_split_ratio + val_split_ratio)
289280

290281
trainSet = all_idx[:val_splitIdx]
291282
valSet = all_idx[val_splitIdx:]

pycls/datasets/tiny_imagenet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class TinyImageNet(datasets.ImageFolder):
2929
"""
3030
def __init__(self, root: str, split: str = 'train', **kwargs: Any) -> None:
3131
self.root = root
32-
assert self.check_root(), "Something is wrong with the Tiny ImageNet dataset. Download the official dataset zip from http://cs231n.stanford.edu/tiny-imagenet-200.zip and unzip it inside {}.".format(self.root)
32+
assert self.check_root(), "Something is wrong with the Tiny ImageNet dataset path. Download the official dataset zip from http://cs231n.stanford.edu/tiny-imagenet-200.zip and unzip it inside {}.".format(self.root)
3333
self.split = datasets.utils.verify_str_arg(split, "split", ("train", "val"))
3434

3535
wnid_to_classes = self.load_wnid_to_classes()

tools/ensemble_al.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ def main(cfg):
109109
cfg.OUT_DIR = os.path.join(os.path.abspath('..'), cfg.OUT_DIR)
110110
if not os.path.exists(cfg.OUT_DIR):
111111
os.mkdir(cfg.OUT_DIR)
112-
# Create "DATASET" specific directory
112+
# Create "DATASET/MODEL TYPE" specific directory
113113
dataset_out_dir = os.path.join(cfg.OUT_DIR, cfg.DATASET.NAME, cfg.MODEL.TYPE)
114114
if not os.path.exists(dataset_out_dir):
115-
os.mkdir(dataset_out_dir)
115+
os.makedirs(dataset_out_dir)
116116
# Creating the experiment directory inside the dataset specific directory
117117
# all logs, labeled, unlabeled, validation sets are stroed here
118118
# E.g., output/CIFAR10/resnet18/{timestamp or cfg.EXP_NAME based on arguments passed}

tools/ensemble_train.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,13 @@ def main(cfg):
106106
cfg.OUT_DIR = os.path.join(os.path.abspath('..'), cfg.OUT_DIR)
107107
if not os.path.exists(cfg.OUT_DIR):
108108
os.mkdir(cfg.OUT_DIR)
109-
# Create "DATASET" specific directory
110-
dataset_out_dir = os.path.join(cfg.OUT_DIR, cfg.DATASET.NAME)
109+
# Create "DATASET/MODEL TYPE" specific directory
110+
dataset_out_dir = os.path.join(cfg.OUT_DIR, cfg.DATASET.NAME, cfg.MODEL.TYPE)
111111
if not os.path.exists(dataset_out_dir):
112-
os.mkdir(dataset_out_dir)
112+
os.makedirs(dataset_out_dir)
113113
# Creating the experiment directory inside the dataset specific directory
114114
# all logs, labeled, unlabeled, validation sets are stroed here
115-
# E.g., output/CIFAR10/{timestamp or cfg.EXP_NAME based on arguments passed}
115+
# E.g., output/CIFAR10/resnet18/{timestamp or cfg.EXP_NAME based on arguments passed}
116116
if cfg.EXP_NAME == 'auto':
117117
now = datetime.now()
118118
exp_dir = f'{now.year}_{now.month}_{now.day}_{now.hour}{now.minute}{now.second}'
@@ -140,8 +140,8 @@ def main(cfg):
140140
print("\nDataset {} Loaded Sucessfully.\nTotal Train Size: {} and Total Test Size: {}\n".format(cfg.DATASET.NAME, train_size, test_size))
141141
logger.info("Dataset {} Loaded Sucessfully. Total Train Size: {} and Total Test Size: {}\n".format(cfg.DATASET.NAME, train_size, test_size))
142142

143-
trainSet_path, valSet_path = data_obj.makeTVSets(train_split_ratio=cfg.ACTIVE_LEARNING.INIT_L_RATIO, \
144-
val_split_ratio=cfg.DATASET.VAL_RATIO, data=train_data, seed_id=cfg.RNG_SEED, save_dir=cfg.EXP_DIR)
143+
trainSet_path, valSet_path = data_obj.makeTVSets(val_split_ratio=cfg.DATASET.VAL_RATIO, data=train_data, \
144+
seed_id=cfg.RNG_SEED, save_dir=cfg.EXP_DIR)
145145

146146
trainSet, valSet = data_obj.loadTVPartitions(trainSetPath=trainSet_path, valSetPath=valSet_path)
147147

tools/train.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,13 @@ def main(cfg):
105105
cfg.OUT_DIR = os.path.join(os.path.abspath('..'), cfg.OUT_DIR)
106106
if not os.path.exists(cfg.OUT_DIR):
107107
os.mkdir(cfg.OUT_DIR)
108-
# Create "DATASET" specific directory
109-
dataset_out_dir = os.path.join(cfg.OUT_DIR, cfg.DATASET.NAME)
108+
# Create "DATASET/MODEL TYPE" specific directory
109+
dataset_out_dir = os.path.join(cfg.OUT_DIR, cfg.DATASET.NAME, cfg.MODEL.TYPE)
110110
if not os.path.exists(dataset_out_dir):
111-
os.mkdir(dataset_out_dir)
111+
os.makedirs(dataset_out_dir)
112112
# Creating the experiment directory inside the dataset specific directory
113113
# all logs, labeled, unlabeled, validation sets are stroed here
114-
# E.g., output/CIFAR10/{timestamp or cfg.EXP_NAME based on arguments passed}
114+
# E.g., output/CIFAR10/resnet18/{timestamp or cfg.EXP_NAME based on arguments passed}
115115
if cfg.EXP_NAME == 'auto':
116116
now = datetime.now()
117117
exp_dir = f'{now.year}_{now.month}_{now.day}_{now.hour}{now.minute}{now.second}'
@@ -139,8 +139,8 @@ def main(cfg):
139139
print("\nDataset {} Loaded Sucessfully.\nTotal Train Size: {} and Total Test Size: {}\n".format(cfg.DATASET.NAME, train_size, test_size))
140140
logger.info("Dataset {} Loaded Sucessfully. Total Train Size: {} and Total Test Size: {}\n".format(cfg.DATASET.NAME, train_size, test_size))
141141

142-
trainSet_path, valSet_path = data_obj.makeTVSets(train_split_ratio=cfg.ACTIVE_LEARNING.INIT_L_RATIO, \
143-
val_split_ratio=cfg.DATASET.VAL_RATIO, data=train_data, seed_id=cfg.RNG_SEED, save_dir=cfg.EXP_DIR)
142+
trainSet_path, valSet_path = data_obj.makeTVSets(val_split_ratio=cfg.DATASET.VAL_RATIO, data=train_data, \
143+
seed_id=cfg.RNG_SEED, save_dir=cfg.EXP_DIR)
144144

145145
trainSet, valSet = data_obj.loadTVPartitions(trainSetPath=trainSet_path, valSetPath=valSet_path)
146146

tools/train_al.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def main(cfg):
110110
cfg.OUT_DIR = os.path.join(os.path.abspath('..'), cfg.OUT_DIR)
111111
if not os.path.exists(cfg.OUT_DIR):
112112
os.mkdir(cfg.OUT_DIR)
113-
# Create "DATASET" specific directory
113+
# Create "DATASET/MODEL TYPE" specific directory
114114
dataset_out_dir = os.path.join(cfg.OUT_DIR, cfg.DATASET.NAME, cfg.MODEL.TYPE)
115115
if not os.path.exists(dataset_out_dir):
116116
os.makedirs(dataset_out_dir)

0 commit comments

Comments
 (0)