Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding train.py changes #48

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
data/
Binary file added dataset/__pycache__/cifar10.cpython-38.pyc
Binary file not shown.
Binary file added dataset/__pycache__/cifar10.cpython-39.pyc
Binary file not shown.
Empty file added freeze
Empty file.
Binary file added models/__pycache__/wideresnet.cpython-38.pyc
Binary file not shown.
Binary file added models/__pycache__/wideresnet.cpython-39.pyc
Binary file not shown.
6 changes: 6 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
torch==1.4
torchvision==0.2.2
tensorboardX
progress
matplotlib
numpy
10 changes: 6 additions & 4 deletions train.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,16 +200,18 @@ def train(labeled_trainloader, unlabeled_trainloader, model, optimizer, ema_opti
model.train()
for batch_idx in range(args.train_iteration):
try:
inputs_x, targets_x = labeled_train_iter.next()
inputs_x, targets_x = next(labeled_train_iter)
except:
labeled_train_iter = iter(labeled_trainloader)
inputs_x, targets_x = labeled_train_iter.next()
inputs_x, targets_x = next(labeled_train_iter)


try:
(inputs_u, inputs_u2), _ = unlabeled_train_iter.next()
(inputs_u, inputs_u2), _ = next(unlabeled_train_iter)
except:
unlabeled_train_iter = iter(unlabeled_trainloader)
(inputs_u, inputs_u2), _ = unlabeled_train_iter.next()
(inputs_u, inputs_u2), _ = next(unlabeled_train_iter)


# measure data loading time
data_time.update(time.time() - end)
Expand Down
Binary file added utils/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file added utils/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file added utils/__pycache__/eval.cpython-38.pyc
Binary file not shown.
Binary file added utils/__pycache__/eval.cpython-39.pyc
Binary file not shown.
Binary file added utils/__pycache__/logger.cpython-38.pyc
Binary file not shown.
Binary file added utils/__pycache__/logger.cpython-39.pyc
Binary file not shown.
Binary file added utils/__pycache__/misc.cpython-38.pyc
Binary file not shown.
Binary file added utils/__pycache__/misc.cpython-39.pyc
Binary file not shown.
4 changes: 2 additions & 2 deletions utils/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ def accuracy(output, target, topk=(1,)):

res = []
for k in topk:
correct_k = correct[:k].view(-1).float().sum(0)
correct_k = correct[:k].reshape(-1).float().sum(0)
res.append(correct_k.mul_(100.0 / batch_size))
return res
return res