amanmibra commited on
Commit
e59cfff
1 Parent(s): 77e643c
Files changed (3) hide show
  1. .gitignore +2 -1
  2. models/aisf/void_20230520_110446.pth +0 -0
  3. train.py +7 -2
.gitignore CHANGED
@@ -1,4 +1,5 @@
1
  data/*
2
  __pycache__/*
3
  */__pycache__/*
4
- */.ipynb_checkpoints/*
 
 
1
  data/*
2
  __pycache__/*
3
  */__pycache__/*
4
+ */.ipynb_checkpoints/*
5
+ wandb
models/aisf/void_20230520_110446.pth ADDED
Binary file (655 kB). View file
 
train.py CHANGED
@@ -1,5 +1,6 @@
1
  from datetime import datetime
2
  from tqdm import tqdm
 
3
 
4
  # torch
5
  import torch
@@ -37,6 +38,7 @@ def train(model, train_dataloader, loss_fn, optimizer, device, epochs, test_data
37
  training_acc.append(train_epoch_acc/len(train_dataloader))
38
 
39
  print("Training Loss: {:.2f}, Training Accuracy {}".format(training_loss[i], training_acc[i]))
 
40
 
41
  if test_dataloader:
42
  # test model
@@ -47,6 +49,7 @@ def train(model, train_dataloader, loss_fn, optimizer, device, epochs, test_data
47
  testing_acc.append(test_epoch_acc/len(test_dataloader))
48
 
49
  print("Testing Loss: {:.2f}, Testing Accuracy {}".format(testing_loss[i], testing_acc[i]))
 
50
 
51
  print ("-------------------------------------------- \n")
52
 
@@ -117,7 +120,7 @@ if __name__ == "__main__":
117
  n_mels=128
118
  )
119
 
120
- train_dataset = VoiceDataset(AISF_TRAIN_FILE, mel_spectrogram, device)
121
  train_dataloader = DataLoader(train_dataset, batch_size=BATCH_SIZE, shuffle=True)
122
 
123
  # construct model
@@ -130,6 +133,7 @@ if __name__ == "__main__":
130
  # optimizer = torch.optim.Adam(model.parameters(), lr=LEARNING_RATE)
131
  optimizer = torch.optim.SGD(model.parameters(), lr=LEARNING_RATE, momentum=0.9)
132
 
 
133
 
134
  # train model
135
  train(model, train_dataloader, loss_fn, optimizer, device, EPOCHS)
@@ -141,4 +145,5 @@ if __name__ == "__main__":
141
  now = now.strftime("%Y%m%d_%H%M%S")
142
  model_filename = f"models/aisf/void_{now}.pth"
143
  torch.save(model.state_dict(), model_filename)
144
- print(f"Trained void model saved at {model_filename}")
 
 
1
  from datetime import datetime
2
  from tqdm import tqdm
3
+ import wandb
4
 
5
  # torch
6
  import torch
 
38
  training_acc.append(train_epoch_acc/len(train_dataloader))
39
 
40
  print("Training Loss: {:.2f}, Training Accuracy {}".format(training_loss[i], training_acc[i]))
41
+ wandb.log({'training_loss': training_loss[i], 'training_acc': training_acc[i]})
42
 
43
  if test_dataloader:
44
  # test model
 
49
  testing_acc.append(test_epoch_acc/len(test_dataloader))
50
 
51
  print("Testing Loss: {:.2f}, Testing Accuracy {}".format(testing_loss[i], testing_acc[i]))
52
+ wandb.log({'testing_loss': testing_loss[i], 'training_acc': training_acc[i]})
53
 
54
  print ("-------------------------------------------- \n")
55
 
 
120
  n_mels=128
121
  )
122
 
123
+ train_dataset = VoiceDataset(AISF_TRAIN_FILE, mel_spectrogram, device, time_limit_in_secs=3)
124
  train_dataloader = DataLoader(train_dataset, batch_size=BATCH_SIZE, shuffle=True)
125
 
126
  # construct model
 
133
  # optimizer = torch.optim.Adam(model.parameters(), lr=LEARNING_RATE)
134
  optimizer = torch.optim.SGD(model.parameters(), lr=LEARNING_RATE, momentum=0.9)
135
 
136
+ wandb.init(project="void-train")
137
 
138
  # train model
139
  train(model, train_dataloader, loss_fn, optimizer, device, EPOCHS)
 
145
  now = now.strftime("%Y%m%d_%H%M%S")
146
  model_filename = f"models/aisf/void_{now}.pth"
147
  torch.save(model.state_dict(), model_filename)
148
+ print(f"Trained void model saved at {model_filename}")
149
+ wandb.finish()