89f2c2b125815fc11849ae110b4b561de81894d2,examples/text_classification/train.py,,train,#Any#Any#Any#,30
Before Change
progress = processed_lines / float(num_lines)
lr = lr_ * (1 - progress)
// SGD
for p in model.parameters():
p.data.add_(p.grad.data * -lr)
p.grad.detach_()
p.grad.zero_()
if processed_lines % 1024:
sys.stderr.write(
"\rProgress: {:3.0f}% lr: {:3.3f} loss: {:3.3f}".format(
progress * 100, lr, loss))
After Change
data = DataLoader(data_, batch_size=batch_size, shuffle=True,
collate_fn=generate_batch, num_workers=args.num_workers)
optimizer = torch.optim.SGD(model.parameters(), lr=lr_)
scheduler = torch.optim.lr_scheduler.StepLR(optimizer, 1, gamma=args.lr_gamma)
num_lines = num_epochs * len(data)
for epoch in range(num_epochs):
for i, (text, offsets, cls) in enumerate(data):
In pattern: SUPERPATTERN
Frequency: 4
Non-data size: 5
Instances
Project Name: pytorch/text
Commit Name: 89f2c2b125815fc11849ae110b4b561de81894d2
Time: 2019-07-31
Author: 6156351+zhangguanheng66@users.noreply.github.com
File Name: examples/text_classification/train.py
Class Name:
Method Name: train
Project Name: pytorch/tutorials
Commit Name: 3128e13109c8766eafb413f2428bba976701e929
Time: 2020-12-02
Author: 6156351+zhangguanheng66@users.noreply.github.com
File Name: beginner_source/transformer_tutorial.py
Class Name:
Method Name:
Project Name: jindongwang/transferlearning
Commit Name: 376b01c2e338ec63e638f62a76d67f6a9323e47c
Time: 2019-08-14
Author: jindongwang@outlook.com
File Name: code/deep/DeepCoral/DeepCoral.py
Class Name:
Method Name:
Project Name: pyprob/pyprob
Commit Name: 9cf91d62a1705c3837eea652c985fa0e49f8eb24
Time: 2017-04-04
Author: atilimgunes.baydin@gmail.com
File Name: compile.py
Class Name:
Method Name: