Skip to content

Commit

Permalink
Added landing page for torcheval (#49)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #49

Added landing page with simple example and installation instructions

Reviewed By: ninginthecloud

Differential Revision: D39712441

fbshipit-source-id: bc438a2f89d0570f9cdfe36f2ae4c3993c0d38f7
  • Loading branch information
bobakfb authored and facebook-github-bot committed Oct 3, 2022
1 parent a16002d commit c9ce95f
Showing 1 changed file with 64 additions and 4 deletions.
68 changes: 64 additions & 4 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -1,19 +1,79 @@
TorchEval
===========================================

A library that contains a rich collection of performant PyTorch model metrics, a simple interface to create new metrics, a toolkit to facilitate metric computation in distributed training and tools for PyTorch model evaluations.
A library with simple and straightforward tooling for model evalutations and a delightful user experience. At a high level TorchEval:


`Installation instructions <https://github.com/pytorch-labs/torcheval#installing-torcheval>`_
1. Contains a rich collection of high performance metric calulcations out of the box. We utilize vectorization and GPU acceleration where possible via PyTorch.
2. Integrates seemlessly with distributed training and tools using `torch.distributed <https://pytorch.org/tutorials/beginner/dist_overview.html>`_
3. Is designed with extensibility in mind: you have the freedom to easily create your own metrics and leverage our toolkit.
4. Provides tools for profiling memory and compute requirements for PyTorch based models.

TorchEval Tutorials
-------------------
.. toctree::
:maxdepth: 2
:caption: Contents:

metric_example.rst
QuickStart
===========================================

Installing
-----------------

TorchEval can be installed from PyPi via

.. code-block:: console
pip install torcheval
or from github

.. code-block:: console
git clone https://github.com/pytorch-labs/torcheval
cd torcheval
pip install -r requirements.txt
python setup.py install
Usage
-----------------

TorchEval provides two interfaces to each metric. If you are working in a single process environment, it is simplest to use metrics from the ``functional`` submodule. These can be found in ``torcheval.metrics.functional``.

.. code-block:: python
from torcheval.metrics.functional import binary_f1_score
predictions = model(inputs)
f1_score = binary_f1_score(predictions, targets)
We can use the same metric in the class based route, which provides tools that make computation simple in a multi-process settings. On a single device, you can use the class based metrics as follows:

.. code-block:: python
from torcheval.metrics import BinaryF1Score
predictions = model(inputs)
metric = BinaryF1Score()
metric.update(predictions, targets)
f1_score = metric.compute()
In a multi-process setting, the data from each process must be synchronized to compute the metric across the full dataset. To do this, simply replace ``metric.compute()`` with ``sync_and_compute(metric)``:

.. code-block:: python
from torcheval.metrics import BinaryF1Score
from torcheval.metrics.toolkit import sync_and_compute
predictions = model(inputs)
metric = BinaryF1Score()
metric.update(predictions, targets)
f1_score = sync_and_compute(metric)
Read more about the class based method in the distributed example.

Further Reading
-----------------
* Check out the guides exaplaining the compute example
* Check out the distributed example
* Check out how to make your own metric

TorchEval API
-----------------
Expand Down

0 comments on commit c9ce95f

Please sign in to comment.