Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
Sichere ProgrammierungTCP vs UDP: The Two Ways to Move Data, and Why Neither Is "Better"(21.09.2026 um 09:31 Uhr)
Sichere ProgrammierungBukan Sekadar Variabel, Tapi Nyawa dari Aplikasi Kamu! 🚀(21.09.2026 um 09:36 Uhr)
Sichere ProgrammierungAI voice agent for customer service: what stops callers hanging up?(21.09.2026 um 09:42 Uhr)
Sichere ProgrammierungReading a small model's confidence instead of its prose(21.09.2026 um 09:47 Uhr)
Sichere ProgrammierungTCP vs UDP: The Two Ways to Move Data, and Why Neither Is "Better"(21.09.2026 um 09:31 Uhr)
Sichere ProgrammierungBukan Sekadar Variabel, Tapi Nyawa dari Aplikasi Kamu! 🚀(21.09.2026 um 09:36 Uhr)
Sichere ProgrammierungAI voice agent for customer service: what stops callers hanging up?(21.09.2026 um 09:42 Uhr)
Sichere ProgrammierungReading a small model's confidence instead of its prose(21.09.2026 um 09:47 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

Building LSTMs with PyTorch and Lightning AI Part 8: Setting Up a Simpler LSTM

In the previous article, we saw how easily we could continue training by adding more epochs. We also observed the improvements in the model's predictions using TensorBoard. Let's train the model one more time to bring the predictions even…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

In the previous article, we saw how easily we could continue training by adding more epochs. We also observed the improvements in the model's predictions using TensorBoard.



Let's train the model one more time to bring the predictions even closer to the desired values.



As before, we first retrieve the latest checkpoint.




path_to_best_checkpoint = trainer.checkpoint_callback.best_model_path






Next, we increase the maximum number of epochs to 5000.




trainer = L.Trainer(max_epochs=5000)






Then we resume training by calling fit() with the checkpoint.




trainer = L.Trainer(max_epochs=5000)

trainer.fit(
model,
train_dataloaders=dataloader,
ckpt_path=path_to_best_checkpoint
)






Once training is complete, we can print the predictions again.




print("\nComparing observed and predicted values")

print(
"Company A: Observed = 0, Predicted =",
model(torch.tensor([0., 0.5, 0.25, 1.])).detach()
)

print(
"Company B: Observed = 1, Predicted =",
model(torch.tensor([1., 0.5, 0.25, 1.])).detach()
)






This gives the following output:




Comparing observed and predicted values

Company A: Observed = 0, Predicted = tensor(0.0004)
Company B: Observed = 1, Predicted = tensor(0.9672)






As you can see, both predictions are now much closer to their target values.



Next, let's open TensorBoard and inspect the updated training graphs.





Notice that all of the graphs have become much flatter, indicating that the model has nearly converged.



The predictions for Company A and Company B are now very close to their target values of 0 and 1, respectively.



At this point, we have successfully trained our LSTM model.






Now let's look at an even simpler way to build an LSTM using PyTorch's built-in nn.LSTM module.



We will start by creating another class.




class LightningLSTM(L.LightningModule):
def __init__(self):
super().__init__()
self.lstm = nn.LSTM(input_size=1, hidden_size=1)






The input_size specifies the number of features in each input.



In our example, each day contains only a single feature, which is the stock price of a company.



The hidden_size specifies the number of values in the hidden state.



For this example, we use a hidden size of 1, since we ultimately want the model to predict a single value for Day 5.



Next, we will implement the forward() method, which works a little differently when using nn.LSTM. We will explore that in the next article.








AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production.



git-lrc fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.



Any feedback or contributors are welcome! It's online, source-available, and ready for anyone to use.



Give it a ⭐ star on Github

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Building LSTMs with PyTorch and Lightning AI Part 8: Setting Up a Simpler LSTM

Thematisch verwandte Begriffe: Building, LSTMs, with, PyTorch · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-94030 | A security vulnerability has been detected in SerenityOS up to 3d83e4509…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick