Name | torchoutil JSON |
Version |
0.5.0
JSON |
| download |
home_page | None |
Summary | Collection of functions and modules to help development in PyTorch. |
upload_time | 2024-11-28 16:06:59 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | MIT License Copyright (c) 2024 Labbeti Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
pytorch
deep-learning
|
VCS |
|
bugtrack_url |
|
requirements |
torch
typing_extensions
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# torchoutil
<center>
<a href="https://www.python.org/">
<img alt="Python" src="https://img.shields.io/badge/-Python 3.8+-blue?style=for-the-badge&logo=python&logoColor=white">
</a>
<a href="https://pytorch.org/get-started/locally/">
<img alt="PyTorch" src="https://img.shields.io/badge/-PyTorch 1.10+-ee4c2c?style=for-the-badge&logo=pytorch&logoColor=white">
</a>
<a href="https://black.readthedocs.io/en/stable/">
<img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-black.svg?style=for-the-badge&labelColor=gray">
</a>
<a href="https://github.com/Labbeti/torchoutil/actions">
<img alt="Build" src="https://img.shields.io/github/actions/workflow/status/Labbeti/torchoutil/test.yaml?branch=main&style=for-the-badge&logo=github">
</a>
<a href='https://torchoutil.readthedocs.io/en/stable/?badge=stable'>
<img src='https://readthedocs.org/projects/torchoutil/badge/?version=stable&style=for-the-badge' alt='Documentation Status' />
</a>
Collection of functions and modules to help development in PyTorch.
</center>
## Installation
```bash
pip install torchoutil
```
The main requirement is **[PyTorch](https://pytorch.org/)**.
To check if the package is installed and show the package version, you can use the following command:
```bash
torchoutil-info
```
## Examples
`torchoutil` functions and modules can be used like `torch` ones. The default acronym for `torchoutil` is `to`.
### Label conversions
Supports **multiclass** labels conversions between probabilities, classes indices, classes names and onehot encoding.
```python
import torchoutil as to
probs = to.as_tensor([[0.9, 0.1], [0.4, 0.6]])
names = to.probs_to_name(probs, idx_to_name={0: "Cat", 1: "Dog"})
# ["Cat", "Dog"]
```
This package also supports **multilabel** labels conversions between probabilities, classes multi-indices, classes multi-names and multihot encoding.
```python
import torchoutil as to
multihot = to.as_tensor([[1, 0, 0], [0, 1, 1], [0, 0, 0]])
indices = to.multihot_to_indices(multihot)
# [[0], [1, 2], []]
```
### Typing
```python
from torchoutil import Tensor2D
x1 = torch.as_tensor([1, 2])
print(isinstance(x1, Tensor2D)) # False
x2 = torch.as_tensor([[1, 2], [3, 4]])
print(isinstance(x2, Tensor2D)) # True
```
```python
from torchoutil import SignedIntegerTensor
x1 = torch.as_tensor([1, 2], dtype=torch.int)
print(isinstance(x1, SignedIntegerTensor)) # True
x2 = torch.as_tensor([1, 2], dtype=torch.long)
print(isinstance(x2, SignedIntegerTensor)) # True
x3 = torch.as_tensor([1, 2], dtype=torch.float)
print(isinstance(x3, SignedIntegerTensor)) # False
```
### Padding
```python
import torchoutil as to
x1 = torch.rand(10, 3, 1)
x2 = to.pad_dim(x, target_length=5, dim=1, pad_value=-1)
# x2 has shape (10, 5, 1)
```
```python
import torchoutil as to
tensors = [torch.rand(10, 2), torch.rand(5, 3), torch.rand(0, 5)]
padded = to.pad_and_stack_rec(tensors, pad_value=0)
# padded has shape (10, 5)
```
### Masking
```python
import torchoutil as to
x = to.as_tensor([3, 1, 2])
mask = to.lengths_to_non_pad_mask(x, max_len=4)
# Each row i contains x[i] True values for non-padding mask
# tensor([[True, True, True, False],
# [True, False, False, False],
# [True, True, False, False]])
```
```python
import torchoutil as to
x = to.as_tensor([1, 2, 3, 4])
mask = to.as_tensor([True, True, False, False])
result = to.masked_mean(x, mask)
# result contains the mean of the values marked as True: 1.5
```
### Others tensors manipulations!
```python
import torchoutil as to
x = to.as_tensor([1, 2, 3, 4])
result = to.insert_at_indices(x, indices=[0, 2], values=5)
# result contains tensor with inserted values: tensor([5, 1, 2, 5, 3, 4])
```
```python
import torchoutil as to
perm = to.randperm(10)
inv_perm = to.get_inverse_perm(perm)
x1 = to.rand(10)
x2 = x1[perm]
x3 = x2[inv_perm]
# inv_perm are indices that allow us to get x3 from x2, i.e. x1 == x3 here
```
### Pre-compute datasets to pickle or HDF files
Here is an example of pre-computing spectrograms of torchaudio `SPEECHCOMMANDS` dataset, using `pack_dataset` function:
```python
from torchaudio.datasets import SPEECHCOMMANDS
from torchaudio.transforms import Spectrogram
from torchoutil import nn
from torchoutil.utils.pack import pack_dataset
speech_commands_root = "path/to/speech_commands"
packed_root = "path/to/packed_dataset"
dataset = SPEECHCOMMANDS(speech_commands_root, download=True, subset="validation")
# dataset[0] is a tuple, contains waveform and other metadata
class MyTransform(nn.Module):
def __init__(self) -> None:
super().__init__()
self.spectrogram_extractor = Spectrogram()
def forward(self, item):
waveform = item[0]
spectrogram = self.spectrogram_extractor(waveform)
return (spectrogram,) + item[1:]
pack_dataset(dataset, packed_root, MyTransform())
```
Then you can load the pre-computed dataset using `PackedDataset`:
```python
from torchoutil.utils.pack import PackedDataset
packed_root = "path/to/packed_dataset"
packed_dataset = PackedDataset(packed_root)
packed_dataset[0] # == first transformed item, i.e. transform(dataset[0])
```
<!--
## Main modules
- [IndexToName](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multiclass.html#torchoutil.nn.modules.multiclass.IndexToName): Convert multiclass indices to names.
- [IndexToOnehot](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multiclass.html#torchoutil.nn.modules.multiclass.IndexToOnehot): Convert multiclass indices to onehot encoding.
- [NameToIndex](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multiclass.html#torchoutil.nn.modules.multiclass.NameToIndex): Convert names to multiclass indices.
- [NameToOnehot](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multiclass.html#torchoutil.nn.modules.multiclass.NameToOnehot): Convert names to onehot encoding.
- [OnehotToIndex](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multiclass.html#torchoutil.nn.modules.multiclass.OnehotToIndex): Convert onehot encoding to multiclass indices.
- [OnehotToName](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multiclass.html#torchoutil.nn.modules.multiclass.OnehotToName): Convert onehot encoding to names.
- [ProbsToIndex](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multiclass.html#torchoutil.nn.modules.multiclass.ProbsToIndex): Convert probabilities to multiclass indices using a threshold.
- [ProbsToName](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multiclass.html#torchoutil.nn.modules.multiclass.ProbsToName): Convert probabilities to names using a threshold.
- [ProbsToOnehot](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multiclass.html#torchoutil.nn.modules.multiclass.ProbsToOnehot): Convert probabilities to onehot encoding using a threshold.
- [IndicesToMultihot](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multilabel.html#torchoutil.nn.modules.multilabel.IndicesToMultihot): Convert multilabel indices to names.
- [IndicesToNames](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multilabel.html#torchoutil.nn.modules.multilabel.IndicesToNames): Convert multilabel indices to multihot encoding.
- [MultihotToIndices](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multilabel.html#torchoutil.nn.modules.multilabel.MultihotToIndices): Convert multihot encoding to multilabel indices.
- [MultihotToNames](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multilabel.html#torchoutil.nn.modules.multilabel.MultihotToNames): Convert multihot encoding to names.
- [NamesToIndices](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multilabel.html#torchoutil.nn.modules.multilabel.NamesToIndices): Convert names to multilabel indices.
- [NamesToMultihot](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multilabel.html#torchoutil.nn.modules.multilabel.NamesToMultihot): Convert names to multihot encoding.
- [ProbsToIndices](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multilabel.html#torchoutil.nn.modules.multilabel.ProbsToIndices): Convert probabilities to multilabel indices using a threshold.
- [ProbsToMultihot](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multilabel.html#torchoutil.nn.modules.multilabel.ProbsToMultihot): Convert probabilities to names using a threshold.
- [ProbsToNames](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multilabel.html#torchoutil.nn.modules.multilabel.ProbsToNames): Convert probabilities to multihot encoding using a threshold.
- [LogSoftmaxMultidim](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.activation.html#torchoutil.nn.modules.activation.LogSoftmaxMultidim): Apply LogSoftmax along multiple dimensions.
- [SoftmaxMultidim](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.activation.html#torchoutil.nn.modules.activation.SoftmaxMultidim): Apply Softmax along multiple dimensions.
- [CropDim](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.crop.html#torchoutil.nn.modules.crop.CropDim): Crop a tensor along a single dimension.
- [CropDims](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.crop.html#torchoutil.nn.modules.crop.CropDims): Crop a tensor along multiple dimensions.
- [PositionalEncoding](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.layer.html#torchoutil.nn.modules.layer.PositionalEncoding): Positional encoding layer for vanilla transformers models.
- [MaskedMean](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.mask.html#torchoutil.nn.modules.mask.MaskedMean): Average non-masked element of a tensor.
- [MaskedSum](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.mask.html#torchoutil.nn.modules.mask.MaskedSum): Sum non-masked element of a tensor.
- [NumpyToTensor](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.numpy.html#torchoutil.nn.modules.numpy.NumpyToTensor): Convert numpy array or generic to tensor.
- [NumpyToTensor](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.numpy.html#torchoutil.nn.modules.numpy.TensorToNumpy): Convert tensor to numpy array.
- [NumpyToTensor](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.numpy.html#torchoutil.nn.modules.numpy.ToNumpy): Convert sequence to numpy array.
- [PadAndStackRec](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.pad.html#torchoutil.nn.modules.pad.PadAndStackRec): Pad and stack sequence to tensor.
- [PadDim](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.pad.html#torchoutil.nn.modules.pad.PadDim): Pad a tensor along a single dimension.
- [PadDims](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.pad.html#torchoutil.nn.modules.pad.PadDims): Pad a tensor along multiples dimensions.
- [RepeatInterleaveNd](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.transform.html#torchoutil.nn.modules.transform.RepeatInterleaveNd): Repeat interleave a tensor with an arbitrary number of dimensions.
from .tensor import (
FFT,
IFFT,
Abs,
Angle,
AsTensor,
Exp,
Exp2,
Imag,
Log,
Log2,
Log10,
Max,
Mean,
Min,
Normalize,
Permute,
Pow,
Real,
Repeat,
RepeatInterleave,
Reshape,
Squeeze,
TensorTo,
ToItem,
ToList,
Transpose,
Unsqueeze,
)
from .transform import (
Flatten,
Identity,
PadAndCropDim,
RepeatInterleaveNd,
ResampleNearestFreqs,
ResampleNearestRates,
ResampleNearestSteps,
Shuffled,
TransformDrop,
)
-->
## Extras requirements
`torchoutil` also provides additional modules when some specific package are already installed in your environment.
All extras can be installed with `pip install torchoutil[extras]`
- If `tensorboard` is installed, the function `load_event_file` can be used. It is useful to load manually all data contained in an tensorboard event file.
- If `numpy` is installed, the classes `NumpyToTensor` and `ToNumpy` can be used and their related function. It is meant to be used to compose dynamic transforms into `Sequential` module.
- If `h5py` is installed, the function `pack_to_hdf` and class `HDFDataset` can be used. Can be used to pack/read dataset to HDF files, and supports variable-length sequences of data.
- If `pyyaml` is installed, the functions `to_yaml` and `load_yaml` can be used.
## Contact
Maintainer:
- [Étienne Labbé](https://labbeti.github.io/) "Labbeti": labbeti.pub@gmail.com
Raw data
{
"_id": null,
"home_page": null,
"name": "torchoutil",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "\"\u00c9tienne Labb\u00e9 (Labbeti)\" <labbeti.pub@gmail.com>",
"keywords": "pytorch, deep-learning",
"author": null,
"author_email": "\"\u00c9tienne Labb\u00e9 (Labbeti)\" <labbeti.pub@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/9b/84/603c904ccbaae8eb64cad050fa61d684ae17b41e4fc0da8c01864d117f80/torchoutil-0.5.0.tar.gz",
"platform": null,
"description": "# torchoutil\n\n<center>\n\n<a href=\"https://www.python.org/\">\n <img alt=\"Python\" src=\"https://img.shields.io/badge/-Python 3.8+-blue?style=for-the-badge&logo=python&logoColor=white\">\n</a>\n<a href=\"https://pytorch.org/get-started/locally/\">\n <img alt=\"PyTorch\" src=\"https://img.shields.io/badge/-PyTorch 1.10+-ee4c2c?style=for-the-badge&logo=pytorch&logoColor=white\">\n</a>\n<a href=\"https://black.readthedocs.io/en/stable/\">\n <img alt=\"Code style: black\" src=\"https://img.shields.io/badge/code%20style-black-black.svg?style=for-the-badge&labelColor=gray\">\n</a>\n<a href=\"https://github.com/Labbeti/torchoutil/actions\">\n <img alt=\"Build\" src=\"https://img.shields.io/github/actions/workflow/status/Labbeti/torchoutil/test.yaml?branch=main&style=for-the-badge&logo=github\">\n</a>\n<a href='https://torchoutil.readthedocs.io/en/stable/?badge=stable'>\n <img src='https://readthedocs.org/projects/torchoutil/badge/?version=stable&style=for-the-badge' alt='Documentation Status' />\n</a>\n\nCollection of functions and modules to help development in PyTorch.\n\n</center>\n\n\n## Installation\n```bash\npip install torchoutil\n```\n\nThe main requirement is **[PyTorch](https://pytorch.org/)**.\n\nTo check if the package is installed and show the package version, you can use the following command:\n```bash\ntorchoutil-info\n```\n\n## Examples\n\n`torchoutil` functions and modules can be used like `torch` ones. The default acronym for `torchoutil` is `to`.\n\n### Label conversions\nSupports **multiclass** labels conversions between probabilities, classes indices, classes names and onehot encoding.\n\n```python\nimport torchoutil as to\n\nprobs = to.as_tensor([[0.9, 0.1], [0.4, 0.6]])\nnames = to.probs_to_name(probs, idx_to_name={0: \"Cat\", 1: \"Dog\"})\n# [\"Cat\", \"Dog\"]\n```\n\nThis package also supports **multilabel** labels conversions between probabilities, classes multi-indices, classes multi-names and multihot encoding.\n\n```python\nimport torchoutil as to\n\nmultihot = to.as_tensor([[1, 0, 0], [0, 1, 1], [0, 0, 0]])\nindices = to.multihot_to_indices(multihot)\n# [[0], [1, 2], []]\n```\n\n### Typing\n\n```python\nfrom torchoutil import Tensor2D\n\nx1 = torch.as_tensor([1, 2])\nprint(isinstance(x1, Tensor2D)) # False\nx2 = torch.as_tensor([[1, 2], [3, 4]])\nprint(isinstance(x2, Tensor2D)) # True\n```\n\n```python\nfrom torchoutil import SignedIntegerTensor\n\nx1 = torch.as_tensor([1, 2], dtype=torch.int)\nprint(isinstance(x1, SignedIntegerTensor)) # True\n\nx2 = torch.as_tensor([1, 2], dtype=torch.long)\nprint(isinstance(x2, SignedIntegerTensor)) # True\n\nx3 = torch.as_tensor([1, 2], dtype=torch.float)\nprint(isinstance(x3, SignedIntegerTensor)) # False\n```\n\n### Padding\n\n```python\nimport torchoutil as to\n\nx1 = torch.rand(10, 3, 1)\nx2 = to.pad_dim(x, target_length=5, dim=1, pad_value=-1)\n# x2 has shape (10, 5, 1)\n```\n\n```python\nimport torchoutil as to\n\ntensors = [torch.rand(10, 2), torch.rand(5, 3), torch.rand(0, 5)]\npadded = to.pad_and_stack_rec(tensors, pad_value=0)\n# padded has shape (10, 5)\n```\n\n### Masking\n\n```python\nimport torchoutil as to\n\nx = to.as_tensor([3, 1, 2])\nmask = to.lengths_to_non_pad_mask(x, max_len=4)\n# Each row i contains x[i] True values for non-padding mask\n# tensor([[True, True, True, False],\n# [True, False, False, False],\n# [True, True, False, False]])\n```\n\n```python\nimport torchoutil as to\n\nx = to.as_tensor([1, 2, 3, 4])\nmask = to.as_tensor([True, True, False, False])\nresult = to.masked_mean(x, mask)\n# result contains the mean of the values marked as True: 1.5\n```\n\n### Others tensors manipulations!\n\n```python\nimport torchoutil as to\n\nx = to.as_tensor([1, 2, 3, 4])\nresult = to.insert_at_indices(x, indices=[0, 2], values=5)\n# result contains tensor with inserted values: tensor([5, 1, 2, 5, 3, 4])\n```\n\n```python\nimport torchoutil as to\n\nperm = to.randperm(10)\ninv_perm = to.get_inverse_perm(perm)\n\nx1 = to.rand(10)\nx2 = x1[perm]\nx3 = x2[inv_perm]\n# inv_perm are indices that allow us to get x3 from x2, i.e. x1 == x3 here\n```\n\n### Pre-compute datasets to pickle or HDF files\n\nHere is an example of pre-computing spectrograms of torchaudio `SPEECHCOMMANDS` dataset, using `pack_dataset` function:\n\n```python\nfrom torchaudio.datasets import SPEECHCOMMANDS\nfrom torchaudio.transforms import Spectrogram\nfrom torchoutil import nn\nfrom torchoutil.utils.pack import pack_dataset\n\nspeech_commands_root = \"path/to/speech_commands\"\npacked_root = \"path/to/packed_dataset\"\n\ndataset = SPEECHCOMMANDS(speech_commands_root, download=True, subset=\"validation\")\n# dataset[0] is a tuple, contains waveform and other metadata\n\nclass MyTransform(nn.Module):\n def __init__(self) -> None:\n super().__init__()\n self.spectrogram_extractor = Spectrogram()\n\n def forward(self, item):\n waveform = item[0]\n spectrogram = self.spectrogram_extractor(waveform)\n return (spectrogram,) + item[1:]\n\npack_dataset(dataset, packed_root, MyTransform())\n```\n\nThen you can load the pre-computed dataset using `PackedDataset`:\n```python\nfrom torchoutil.utils.pack import PackedDataset\n\npacked_root = \"path/to/packed_dataset\"\npacked_dataset = PackedDataset(packed_root)\npacked_dataset[0] # == first transformed item, i.e. transform(dataset[0])\n```\n\n<!--\n## Main modules\n\n- [IndexToName](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multiclass.html#torchoutil.nn.modules.multiclass.IndexToName): Convert multiclass indices to names.\n- [IndexToOnehot](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multiclass.html#torchoutil.nn.modules.multiclass.IndexToOnehot): Convert multiclass indices to onehot encoding.\n- [NameToIndex](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multiclass.html#torchoutil.nn.modules.multiclass.NameToIndex): Convert names to multiclass indices.\n- [NameToOnehot](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multiclass.html#torchoutil.nn.modules.multiclass.NameToOnehot): Convert names to onehot encoding.\n- [OnehotToIndex](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multiclass.html#torchoutil.nn.modules.multiclass.OnehotToIndex): Convert onehot encoding to multiclass indices.\n- [OnehotToName](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multiclass.html#torchoutil.nn.modules.multiclass.OnehotToName): Convert onehot encoding to names.\n- [ProbsToIndex](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multiclass.html#torchoutil.nn.modules.multiclass.ProbsToIndex): Convert probabilities to multiclass indices using a threshold.\n- [ProbsToName](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multiclass.html#torchoutil.nn.modules.multiclass.ProbsToName): Convert probabilities to names using a threshold.\n- [ProbsToOnehot](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multiclass.html#torchoutil.nn.modules.multiclass.ProbsToOnehot): Convert probabilities to onehot encoding using a threshold.\n- [IndicesToMultihot](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multilabel.html#torchoutil.nn.modules.multilabel.IndicesToMultihot): Convert multilabel indices to names.\n- [IndicesToNames](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multilabel.html#torchoutil.nn.modules.multilabel.IndicesToNames): Convert multilabel indices to multihot encoding.\n- [MultihotToIndices](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multilabel.html#torchoutil.nn.modules.multilabel.MultihotToIndices): Convert multihot encoding to multilabel indices.\n- [MultihotToNames](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multilabel.html#torchoutil.nn.modules.multilabel.MultihotToNames): Convert multihot encoding to names.\n- [NamesToIndices](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multilabel.html#torchoutil.nn.modules.multilabel.NamesToIndices): Convert names to multilabel indices.\n- [NamesToMultihot](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multilabel.html#torchoutil.nn.modules.multilabel.NamesToMultihot): Convert names to multihot encoding.\n- [ProbsToIndices](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multilabel.html#torchoutil.nn.modules.multilabel.ProbsToIndices): Convert probabilities to multilabel indices using a threshold.\n- [ProbsToMultihot](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multilabel.html#torchoutil.nn.modules.multilabel.ProbsToMultihot): Convert probabilities to names using a threshold.\n- [ProbsToNames](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.multilabel.html#torchoutil.nn.modules.multilabel.ProbsToNames): Convert probabilities to multihot encoding using a threshold.\n\n- [LogSoftmaxMultidim](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.activation.html#torchoutil.nn.modules.activation.LogSoftmaxMultidim): Apply LogSoftmax along multiple dimensions.\n- [SoftmaxMultidim](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.activation.html#torchoutil.nn.modules.activation.SoftmaxMultidim): Apply Softmax along multiple dimensions.\n- [CropDim](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.crop.html#torchoutil.nn.modules.crop.CropDim): Crop a tensor along a single dimension.\n- [CropDims](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.crop.html#torchoutil.nn.modules.crop.CropDims): Crop a tensor along multiple dimensions.\n- [PositionalEncoding](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.layer.html#torchoutil.nn.modules.layer.PositionalEncoding): Positional encoding layer for vanilla transformers models.\n- [MaskedMean](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.mask.html#torchoutil.nn.modules.mask.MaskedMean): Average non-masked element of a tensor.\n- [MaskedSum](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.mask.html#torchoutil.nn.modules.mask.MaskedSum): Sum non-masked element of a tensor.\n- [NumpyToTensor](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.numpy.html#torchoutil.nn.modules.numpy.NumpyToTensor): Convert numpy array or generic to tensor.\n- [NumpyToTensor](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.numpy.html#torchoutil.nn.modules.numpy.TensorToNumpy): Convert tensor to numpy array.\n- [NumpyToTensor](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.numpy.html#torchoutil.nn.modules.numpy.ToNumpy): Convert sequence to numpy array.\n- [PadAndStackRec](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.pad.html#torchoutil.nn.modules.pad.PadAndStackRec): Pad and stack sequence to tensor.\n- [PadDim](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.pad.html#torchoutil.nn.modules.pad.PadDim): Pad a tensor along a single dimension.\n- [PadDims](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.pad.html#torchoutil.nn.modules.pad.PadDims): Pad a tensor along multiples dimensions.\n- [RepeatInterleaveNd](https://torchoutil.readthedocs.io/en/latest/torchoutil.nn.modules.transform.html#torchoutil.nn.modules.transform.RepeatInterleaveNd): Repeat interleave a tensor with an arbitrary number of dimensions.\n\nfrom .tensor import (\n FFT,\n IFFT,\n Abs,\n Angle,\n AsTensor,\n Exp,\n Exp2,\n Imag,\n Log,\n Log2,\n Log10,\n Max,\n Mean,\n Min,\n Normalize,\n Permute,\n Pow,\n Real,\n Repeat,\n RepeatInterleave,\n Reshape,\n Squeeze,\n TensorTo,\n ToItem,\n ToList,\n Transpose,\n Unsqueeze,\n)\nfrom .transform import (\n Flatten,\n Identity,\n PadAndCropDim,\n RepeatInterleaveNd,\n ResampleNearestFreqs,\n ResampleNearestRates,\n ResampleNearestSteps,\n Shuffled,\n TransformDrop,\n)\n-->\n\n\n## Extras requirements\n`torchoutil` also provides additional modules when some specific package are already installed in your environment.\nAll extras can be installed with `pip install torchoutil[extras]`\n\n- If `tensorboard` is installed, the function `load_event_file` can be used. It is useful to load manually all data contained in an tensorboard event file.\n- If `numpy` is installed, the classes `NumpyToTensor` and `ToNumpy` can be used and their related function. It is meant to be used to compose dynamic transforms into `Sequential` module.\n- If `h5py` is installed, the function `pack_to_hdf` and class `HDFDataset` can be used. Can be used to pack/read dataset to HDF files, and supports variable-length sequences of data.\n- If `pyyaml` is installed, the functions `to_yaml` and `load_yaml` can be used.\n\n\n## Contact\nMaintainer:\n- [\u00c9tienne Labb\u00e9](https://labbeti.github.io/) \"Labbeti\": labbeti.pub@gmail.com\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2024 Labbeti Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "Collection of functions and modules to help development in PyTorch.",
"version": "0.5.0",
"project_urls": {
"Changelog": "https://github.com/Labbeti/torchoutil/blob/main/CHANGELOG.md",
"Documentation": "https://torchoutil.readthedocs.io/",
"Homepage": "https://pypi.org/project/torchoutil/",
"Repository": "https://github.com/Labbeti/torchoutil.git",
"Tracker": "https://github.com/Labbeti/torchoutil/issues"
},
"split_keywords": [
"pytorch",
" deep-learning"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9b84603c904ccbaae8eb64cad050fa61d684ae17b41e4fc0da8c01864d117f80",
"md5": "decb37a0557d202fbb0ad874f47546e3",
"sha256": "5a88a28f375d7c92fb0fd67f72f2a739d65f77349d19350ed65d68dcc0d16830"
},
"downloads": -1,
"filename": "torchoutil-0.5.0.tar.gz",
"has_sig": false,
"md5_digest": "decb37a0557d202fbb0ad874f47546e3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 130080,
"upload_time": "2024-11-28T16:06:59",
"upload_time_iso_8601": "2024-11-28T16:06:59.292845Z",
"url": "https://files.pythonhosted.org/packages/9b/84/603c904ccbaae8eb64cad050fa61d684ae17b41e4fc0da8c01864d117f80/torchoutil-0.5.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-28 16:06:59",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Labbeti",
"github_project": "torchoutil",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "torch",
"specs": [
[
">=",
"1.10.0"
]
]
},
{
"name": "typing_extensions",
"specs": [
[
">=",
"4.10.0"
]
]
}
],
"lcname": "torchoutil"
}