Skip to content

Commit

Permalink
finish
Browse files Browse the repository at this point in the history
  • Loading branch information
hyunwoongko committed Dec 18, 2019
1 parent c19810c commit ad2b684
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 19 deletions.
16 changes: 3 additions & 13 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified __pycache__/conf.cpython-36.pyc
Binary file not shown.
Binary file modified __pycache__/train.cpython-36.pyc
Binary file not shown.
4 changes: 1 addition & 3 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")

# model parameter setting
batch_size = 32
batch_size = 128
max_len = 512
d_model = 512
sinusoid = True
d_k = d_v = d_model * 4
n_layers = 6
n_heads = 8
ffn_hidden = 256
Expand Down
6 changes: 3 additions & 3 deletions train.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def train(model, iterator, optimizer, criterion, clip):
torch.nn.utils.clip_grad_norm_(model.parameters(), clip)
optimizer.step()
epoch_loss += loss.item()
print('step :', i, ' , loss :', loss.item())
print('step :', round((i/len(iterator)) * 100, 2), '% , loss :', loss.item())

return epoch_loss / len(iterator)

Expand Down Expand Up @@ -97,8 +97,8 @@ def run(total_epoch, best_loss):

if valid_loss < best_loss:
best_loss = valid_loss
torch.save(model.state_dict(), 'model.pt')
torch.save(model.state_dict(), 'model-{0}.pt'.format(valid_loss))

print(f'Epoch: {epoch + 1:02} | Time: {epoch_mins}m {epoch_secs}s')
print(f'Epoch: {step + 1} | Time: {epoch_mins}m {epoch_secs}s')
print(f'\tTrain Loss: {train_loss:.3f} | Train PPL: {math.exp(train_loss):7.3f}')
print(f'\t Val. Loss: {valid_loss:.3f} | Val. PPL: {math.exp(valid_loss):7.3f}')

0 comments on commit ad2b684

Please sign in to comment.