Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add history loss #70

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

khuyentran1401
Copy link

@khuyentran1401 khuyentran1401 commented Aug 11, 2021

Add history loss so that users can get the average loss of each epoch and plot these losses. Here is an example:

from pts.model.deepar import DeepAREstimator
from pts import Trainer
import torch

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

trainer = Trainer(epochs=10, device=device)
estimator = DeepAREstimator(freq="5min",
                            prediction_length=12,
                            input_size=19,
                            trainer=trainer)
predictor = estimator.train(training_data=training_data, num_workers=7)

print(trainer.training_loss)

Output:

[4.835213756561279,
 4.153376088142395,
 4.0568355321884155,
 4.018129272460937,
 3.988181219100952,
 3.9771962928771973,
 3.9635843515396116,
 3.9477042865753176,
 3.9390473127365113,
 3.9344323682785034]
import matplotlib.pyplot as plt 
plt.plot(trainer.training_loss)

Screen Shot 2021-08-11 at 11 26 15 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant