Skip to main content

A Wrapper for PyTorch Models

Project description

TorchWrapper

A wrapper class for a PyTorhc Model using fit and predict functions that are familiar to those who use Keras and Sklearn.

Reduces the need to write fit and evaluation functions for basic models.

Quick Start

# import the module
from torchwrapper import Wrapper

# create your module, optimizer, and criterion function
model = Model()
optimizer = torch.optim.Adam(model.parameters())
criterion = torch.nn.MSELos()

# wrap the model
model = Wrapper(model)

# train the network
model.fit(dataloader, optimizer, criterion, epochs=50)

With a trained model, you can predict using a PyTorch dataloader:

preds = model.predict(dataloader)

This will return a numpy array of the predictions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

torchwrapper-0.1.4.tar.gz (2.6 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page