nayeemrizve/OpenLDN

Using `next()` instead of `.next()` in trainloaders

cs-mshah opened this issue · 1 comments

The .next() should be changed to the following (stackoverflow):

model.train()
for batch_idx in range(args.train_iteration):
    try:
        inputs_x, targets_x, _ = next(labeled_train_iter)
    except:
        labeled_train_iter = iter(labeled_trainloader)
        inputs_x, targets_x, _ = next(labeled_train_iter)

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

It would be better to add a requirements.txt file to avoid conflicts/missing imports.
A few missing imports I encountered as compared to a standard PyTorch environment:
pip install progress
pip install tensorboardX