Create trainer.py
Browse files- trainer.py +13 -40
trainer.py
CHANGED
|
@@ -1,40 +1,13 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
frame_size=CONFIG['frame_size']
|
| 15 |
-
).to(device)
|
| 16 |
-
|
| 17 |
-
optimizer = torch.optim.Adam(model.parameters(), lr=CONFIG['learning_rate'])
|
| 18 |
-
trainer = Text2VideoTrainer(model, optimizer, device)
|
| 19 |
-
|
| 20 |
-
# Add your data loading and training loop here
|
| 21 |
-
|
| 22 |
-
if __name__ == '__main__':
|
| 23 |
-
main()
|
| 24 |
-
|
| 25 |
-
class Text2VideoTrainer:
|
| 26 |
-
def __init__(self, model, optimizer, device):
|
| 27 |
-
self.model = model
|
| 28 |
-
self.optimizer = optimizer
|
| 29 |
-
self.device = device
|
| 30 |
-
|
| 31 |
-
def train_step(self, text_batch, video_batch):
|
| 32 |
-
self.optimizer.zero_grad()
|
| 33 |
-
|
| 34 |
-
generated_video = self.model(text_batch)
|
| 35 |
-
loss = F.mse_loss(generated_video, video_batch)
|
| 36 |
-
|
| 37 |
-
loss.backward()
|
| 38 |
-
self.optimizer.step()
|
| 39 |
-
|
| 40 |
-
return loss.item()
|
|
|
|
| 1 |
+
class EliteTrainer:
|
| 2 |
+
def __init__(self):
|
| 3 |
+
self.training_params = {
|
| 4 |
+
"epochs": 500,
|
| 5 |
+
"batch_size": 16,
|
| 6 |
+
"learning_rate": 2e-5,
|
| 7 |
+
"warmup_steps": 1000
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
def train(self, dataset):
|
| 11 |
+
# Advanced training pipeline
|
| 12 |
+
pass
|
| 13 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|