Tinygrad Lightning - WIP
Pytorch Lightning clone for tinygrad. Easy data loading, training, logging and checkpointing.
Example
import tinygrad_lightning as pl
### model ###
class TinyBobNet(pl.LightningModule):
def __init__(self, filters=64):
self.model = ResNet18(num_classes=10)
def forward(self, input: Tensor):
return self.model(input)
def configure_optimizers(self):
return optim.SGD(optim.get_parameters(self), lr=5e-3, momentum=0.9)
def training_step(self, train_batch, batch_idx):
x, y = train_batch
for image in x:
self.log_image("inputs", image)
out = self.forward(x)
cat = np.argmax(out.cpu().numpy(), axis=-1)
accuracy = (cat == y).mean()
loss = sparse_categorical_crossentropy(out, y)
loss_value = loss.detach().cpu().numpy()
# automatically logs to train/loss, ...
self.log("loss", loss_value.mean())
self.log("accuracy", accuracy)
return loss
def validation_step(self, val_batch, val_idx):
x, y = val_batch
out = self.forward(x)
cat = np.argmax(out.cpu().numpy(), axis=-1)
accuracy = (cat == y).mean()
loss = sparse_categorical_crossentropy(out, y)
loss_value = loss.detach().cpu().numpy()
# automatically logs to val/loss, ...
self.log("loss", loss_value.mean())
self.log("accuracy", accuracy)
return loss
batch_size = 4
test_ds = MnistDataset(variant='test') # same as torch dataset
train_loader = pl.DataLoader(train_ds, batch_size, workers=1, shuffle=True)
# define your model
model = TinyBobNet()
callbacks=[pl.TQDMProgressBar(refresh_rate=10), pl.TensorboardLogger("./logdir")]
trainer = pl.Trainer(model, train_loader=train_loader, callbacks=callbacks)
trainer.fit(epochs=1) # train_batches=2, val_batches=4
Metadata
Release files for tinygrad-lightning 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| tinygrad_lightning-0.0.1.tar.gz | 8.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tinygrad_lightning-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.6 kB
Release files / tinygrad_lightning-0.0.1.tar.gz
| Download URL | tinygrad_lightning-0.0.1.tar.gz |
|---|---|
| Size | 8.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
765e177141ae3d6fe71a826b601e19cb69d49b15c999a5761c9897c8cb19fff9
|
|
BLAKE2b-256 checksum How to use checksums |
bd15d0ff0ce512ad9f52ffc6d5a9b8abc1c00d5c7eedcf529272e80bd029a9a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.10
|
Release files / tinygrad_lightning-0.0.1-py3-none-any.whl
| Download URL | tinygrad_lightning-0.0.1-py3-none-any.whl |
|---|---|
| Size | 9.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4f952659e0830df3c561724dd4b75ee86496821b668ad658a6eddfa4b238be10
|
|
BLAKE2b-256 checksum How to use checksums |
2543c5046a678db116c31f977c78d6a1b374113e05955e20416fd3038e1f75e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.10
|
Security for tinygrad-lightning 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.