You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Traceback (most recent call last):
File "main.py", line 786, in <module>
train_sl()
File "main.py", line 523, in train_sl
for ct, (tokens, doc_ids) in tqdm(enumerate(g)):
File "/home/ubuntu/anaconda3/envs/HiAGM/lib/python3.6/site-packages/tqdm/std.py", line 1185, in __iter__
for obj in iterable:
File "/home/ubuntu/workspace/kb.d2c/HiLAP/util.py", line 233, in gen_minibatch
for token, label in iterate_minibatches_order(args, tokens, labels, mini_batch_size):
File "/home/ubuntu/workspace/kb.d2c/HiLAP/util.py", line 225, in iterate_minibatches_order
if start_idx + batchsize < inputs.shape[0]:
UnboundLocalError: local variable 'start_idx' referenced before assignment
As the code below, start_idx in if loop is outside of for loop. I guess it should be inside of for loop.
def iterate_minibatches_order(args, inputs, targets, batchsize):
assert inputs.shape[0] == targets.shape[0]
if args.debug:
for _ in range(300):
yield inputs[:batchsize], targets[:batchsize]
return
indices = np.argsort([-len(doc) for doc in inputs])
for start_idx in range(0, inputs.shape[0] - batchsize + 1, batchsize):
excerpt = indices[start_idx:start_idx + batchsize]
yield inputs[excerpt], targets[excerpt]
if start_idx + batchsize < inputs.shape[0]:
excerpt = indices[start_idx + batchsize:]
yield inputs[excerpt], targets[excerpt]
The text was updated successfully, but these errors were encountered:
Hi, I found unboundlocalerror in util.py
As the code below, start_idx in if loop is outside of for loop. I guess it should be inside of for loop.
The text was updated successfully, but these errors were encountered: