Skip to content

Commit

Permalink
added documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
SubhadityaMukherjee committed Sep 30, 2024
1 parent 433958f commit 1aa4cca
Show file tree
Hide file tree
Showing 28 changed files with 3,918 additions and 893 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: ci
on:
push:
branches:
- master
- main
- simple_dataloaders
permissions:
contents: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure Git Credentials
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
- uses: actions/setup-python@v5
with:
python-version: 3.x
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- uses: actions/cache@v4
with:
key: mkdocs-material-${{ env.cache_id }}
path: .cache
restore-keys: |
mkdocs-material-
- run: pip install mkdocs-material
- run: pip install mkdocs-material-extensions
- run: pip install mkdocs-jupyter
- run: pip install mkdocs-redirects
- run: pip install mkdocs-autorefs
- run: pip install mkdocs-awesome-pages-plugin
- run: pip install mkdocstrings
- run: pip install mkdocstrings-python
- run: pip install mknotebooks
- run: mkdocs gh-deploy --force
55 changes: 45 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,58 @@ PyPi link https://pypi.org/project/openml-pytorch/
#### Usage
Import openML libraries
```python
import openml
import openml_pytorch
import openml_pytorch.layers
import torch.nn
import torch.optim

import openml_pytorch.config
import openml
import logging

from openml_pytorch.trainer import OpenMLTrainerModule
from openml_pytorch.trainer import OpenMLDataModule
from torchvision.transforms import Compose, Resize, ToPILImage, ToTensor, Lambda
import torchvision
from openml_pytorch.trainer import convert_to_rgb

```
Create a torch model
Create a pytorch model and get a task from openML
```python
model = torch.nn.Sequential(
processing_net,
features_net,
results_net
model = torchvision.models.efficientnet_b0(num_classes=200)
# Download the OpenML task for tiniest imagenet
task = openml.tasks.get_task(362127)
```
Download the task from openML and define Data and Trainer configuration
```python
transform = Compose(
[
ToPILImage(), # Convert tensor to PIL Image to ensure PIL Image operations can be applied.
Lambda(
convert_to_rgb
), # Convert PIL Image to RGB if it's not already.
Resize(
(64, 64)
), # Resize the image.
ToTensor(), # Convert the PIL Image back to a tensor.
]
)
data_module = OpenMLDataModule(
type_of_data="image",
file_dir="datasets",
filename_col="image_path",
target_mode="categorical",
target_column="Class_encoded",
batch_size = 64,
transform=transform
)
trainer = OpenMLTrainerModule(
data_module=data_module,
verbose = True,
epoch_count = 1,
)
openml_pytorch.config.trainer = trainer
```
Download the task from openML and run the model on task.
Run the model on the task
```python
task = openml.tasks.get_task(3573)
run = openml.runs.run_model_on_task(model, task, avoid_duplicate_runs=False)
run.publish()
print('URL for run: %s/run/%d' % (openml.config.server, run.run_id))
Expand Down
6 changes: 6 additions & 0 deletions docs/API reference/Callbacks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Callbacks
Callbacks module contains classes and functions for handling callback functions during an event-driven process. This makes it easier to customize the behavior of the training loop and add additional functionality to the training process without modifying the core code.

To use a callback, create a class that inherits from the Callback class and implement the necessary methods. Callbacks can be used to perform actions at different stages of the training process, such as at the beginning or end of an epoch, batch, or fitting process. Then pass the callback object to the Trainer.

::: callbacks
4 changes: 4 additions & 0 deletions docs/API reference/Custom Datasets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Custom Datasets
This module contains custom dataset classes for handling image and tabular data from OpenML in PyTorch. To add support for new data types, new classes can be added to this module.

::: custom_datasets
5 changes: 5 additions & 0 deletions docs/API reference/Metrics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Metrics
This module provides utility functions for evaluating model performance and activation functions.
It includes functions to compute the accuracy, top-k accuracy of model predictions, and the sigmoid function.

::: metrics
5 changes: 5 additions & 0 deletions docs/API reference/OpenML Connection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# OpenML Connection

This module defines the Pytorch wrapper for OpenML-python.

::: extension
10 changes: 10 additions & 0 deletions docs/API reference/Trainer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Trainer

This module provides classes and methods to facilitate the configuration, data handling, training, and evaluation of machine learning models using PyTorch and OpenML datasets. The functionalities include:
- Generation of default configurations for models.
- Handling of image and tabular data.
- Training and evaluating machine learning models.
- Exporting trained models to ONNX format.
- Managing data transformations and loaders.

::: trainer
Loading

0 comments on commit 1aa4cca

Please sign in to comment.