PyTorch deep learning framework
Deeppy
A flexible framework for building, training, and studying deep learning systems. Deeppy separates data, algorithms, and neural networks so each part of a pipeline can be replaced or extended independently.
Designed for experimentation
Modular by design
Swap networks, algorithms, and data pipelines without rewriting the rest of the training workflow.
Research-oriented
Keep prototypes readable while retaining the flexibility needed to test new architectures and methods.
Plotting and logging
Visualize training progress and record experiments as part of the learning workflow.
PyTorch-native
GPU execution, automatic mixed precision, and torch.compile support are available by default.
Explainability tooling
Tools for making black-box models more interpretable are planned for a future release.
Architecture at a glance
Deeppy keeps the major concerns of a learning system independent, making it possible to move from a small experiment to a more involved training setup without changing the underlying abstractions.
Models and networks
Quickstart: train a GPT model
The framework can be used to load a text corpus, construct a GPT model, train it through a learning frame, and generate text.
Load data and build the model
with open("assets/shakespeare.txt", "r", encoding="utf-8") as f:
text = f.read()
encoding = tiktoken.encoding_for_model("gpt-2")
data = GPTText(
text=text,
tokenizer=encoding,
context_size=context_size
)
model = GPT({
"vocab_size": vocab_size,
"embed_dim": embed_dim,
"num_heads": num_heads,
"num_layers": num_layers,
"context_size": context_size,
"device": device,
"criterion": nn.CrossEntropyLoss(ignore_index=-1),
})
Train the model
lf = LearnFrame(model, data)
for _ in range(epochs):
lf.optimize()
lf.plot(show_result=True, log=True)
Generate text and output
model.generate("KING RICHARD III: \n On this very beautiful day, let us")
Output
KING RICHARD III:
On this very beautiful day, let us us hear
The way of the king.
DUKE OF YORK::
I will not be avoided'd with my heart.
DUKEKE VINCENTIO:
I thank you, good father.
LLUCIO:
I thank you, good my lord; I'll to your your daughter.
KING EDWARD IV:
Now, by the jealous queen
Quickstart: train a reinforcement learning agent
Environment data, a policy network, and an algorithm can be composed into a single training loop.
Reinforcement learning agent code
env = gym.make("LunarLander-v1")
data = dp.EnvData(env, buffer_size=100000)
policy_network = {
"layers": [obs, 128, 128, act],
"blocks": [nn.Linear, nn.ReLU],
"out_act": nn.Softmax,
"weight_init": "uniform",
}
model = dp.SAC(sac_params)
lf = dp.LearningFrame(model, data)
for _ in range(epochs):
lf.collect()
lf.optimize()
lf.plot()
lf.get_anim()