Saravanan666/pypi-org huggingface dataset:
Package: torchsummaryDynamic
torchsummaryDynamicImproved tool oftorchsummaryX.torchsummaryDynamicsupport real FLOPs calculation of dynamic network or user-custom PyTorch ops.UsagepipinstalltorchsummaryDynamicandfromtorchsummaryDynamicimportsummarysummary(your_model,torch.zeros((1,3,224,224)))# orfromtorchsummaryDynamicimportsummarysummary(your_model,torch.zeros((1,3,224,224)),calc_op_types=(nn.Conv2d,nn.Linear))Args:model(Module): Model to summarizex(Tensor): Input tensor of the model with [N, C, H, W] shape dtype and device have to match to the modelcalc_op_types(Tuple): Tuple of op types to be calculatedargs, kwargs: Other arguments used inmodel.forwardfunctionExamplesCalculate Dynamic Conv2d FLOPs/paramsimporttorchimporttorch.nnasnnimporttorch.nn.functionalasFfromtorchsummaryDynamicimportsummaryclassUSConv2d(nn.Conv2d):def__init__(self,in_channels,out_channels,kernel_size,stride=1,padding=0,dilation=1,groups=1,bias=True,us=[False,False]):super(USConv2d,self).__init__(in_channels,out_channels,kernel_size,stride=stride,padding=padding,dilation=dilation,groups=groups,bias=bias)self.width_mult=Noneself.us=usdefforward(self,inputs):in_channels=inputs.shape[1]//self.groupsifself.us[0]elseself.in_channels//self.groupsout_channels=int(self.out_channels*self.width_mult)ifself.us[1]elseself.out_channelsweight=self.weight[:out_channels,:in_channels,:,:]bias=self.bias[:out_channels]ifself.biasisnotNoneelseself.biasy=F.conv2d(inputs,weight,bias,self.stride,self.padding,self.dilation,self.groups)returnymodel=nn.Sequential(USConv2d(3,32,3,us=[True,True]),)# width_mult=1.0model.apply(lambdam:setattr(m,'width_mult',1.0))summary(model,torch.zeros(1,3,224,224))# width_mult=0.5model.apply(lambdam:setattr(m,'width_mult',0.5))summary(model,torch.zeros(1,3,224,224))Output# width_mult=1.0==========================================================KernelShapeOutputShapeParamsMult-Adds
Layer0_0[3,32,3,3][1,32,222,222]89642581376----------------------------------------------------------Totals
Totalparams896Trainableparams896Non-trainableparams0Mult-Adds42581376==========================================================# width_mult=0.5==========================================================KernelShapeOutputShapeParamsMult-Adds
Layer0_0[3,32,3,3][1,16,222,222]89621290688----------------------------------------------------------Totals
Totalparams896Trainableparams896Non-trainableparams0Mult-Adds21290688==========================================================
Package: torchswarm
TorchswarmA fast implementation of Particle Swarm Optimization using PyTorchWe supportVariants of Particle Swarm OptimizationWe support for all kinds of PSOBring your own particleWe allow for getting a custom particle with a different velocity update rule,
The Class must have the following methods:__init__moveupdate_velocityHow to define your problem.Create a class by inheritingtorchswarm.functions.Functionand anevaluatemethod.classXSquare(Function):defevaluate(self,x):returnx**2Contributors:Rohan Mohapatra
Package: torchsynth
torchsynthThe fastest synth in the universe.Introductiontorchsynth is based upon traditional modular synthesis written in
pytorch. It is GPU-optional and differentiable.Most synthesizers are fast in terms of latency. torchsynth is fast
in terms of throughput. It synthesizes audio 16200x faster than
realtime (714MHz) on a single GPU. This is of particular interest
to audio ML researchers seeking large training corpora.Additionally, all synthesized audio is returned with the underlying
latent parameters used for generating the corresponding audio. This
is useful for multi-modal training regimes.DocumentationInstallationpip3 install torchsynthNote that torchsynth requires PyTorch version 1.8 or greater.ListenIf you'd like to hear torchsynth, check outsynth1K1, a dataset of
1024 4-second sounds rendered from theVoicesynthesizer, or listenon SoundCloud.CitationIf you use this work in your research, please cite:@inproceedings{turian2021torchsynth,
	title        = {One Billion Audio Sounds from {GPU}-enabled Modular Synthesis},
	author       = {Joseph Turian and Jordie Shier and George Tzanetakis and Kirk McNally and Max Henry},
	year         = 2021,
	month        = Sep,
	booktitle    = {Proceedings of the 23rd International Conference on Digital Audio Effects (DAFx2020)},
	location     = {Vienna, Austria}
}
Package: torchtable
torchtableTorchtable is a library for handling tabular datasets in PyTorch. It is heavily inspired by torchtext and uses a similar API but without some of the limitations (e.g. only one field per column).
Torchtable aims to besimple to useandeasily extensible.
It provides sensible defaults while allowing the user to define their own custom pipelines, putting all of this behind an intuitive interface.InstallationInstall via pip.$ pip install torchtableDocumentationDocumentation is a work in progress, but the current docs can be readhere.
In addition, you can read the notebooks in the examples directory or dev_nb directory to learn more.UsageTorchtable uses a declarative API similar to torchtext.
Here is an example of how you might handle an imaginary dataset where you are supposed to predict the price of some product.>>>train=TabularDataset.from_csv('data/train.csv',...fields={'seller_id':CategoricalField(min_freq=3),...'timestamp':[DayofWeekField(),HourField()],...'price':NumericalField(fill_missing="median",is_target=True)...})...See the examples directory for more examples.TODOAdd more modelsImplement default field selectionImplement text field/operationsImplement swap noiseImplement input/output validation
Package: torch-tda
Torch-TDAAutomatic differentiation for topological data analysis.This package provides utilities for using constructions in topological data analysis
with automatic differentiation.  It wraps functionality fromBATSfor persistent homologypersimfor computations comparing persistence diagramstopologylayerfor polynomial features of barcodesThe design is inspired by and draws fromtopologylayer.  Key differences are thattorch-tdausesbatsfor faster topological computations, and the two packages have different feature sets.Here is thedocumentation and examples.UsePackage installation provides a package under thetorch_tdanamespace.  Functionality is primarily undertorch_tda.nn, which provides several PyTorch layers.importtorch_tdaInstallationFirst, it is recommended to set up a conda environmentconda create -n bats
conda activate batsIf you are installingtorch_tdafrom the development version, please install the development version of BATS.py, install it from source.Otherwise, you can use the latest release of BATS.pypip install bats-tdaAttension: please use Linux OS to installbats-tdafor now and the support for Mac OS will come soon.Now, you can setup withsetup.pypython setup.py installDocumentationIf you want to contribute to the documenation, you can add some jupyter notebooks to thedocs/examplesfolder and then generate documentation using Sphinxcd docs
pip install -r requirements.txt
make html
xdg-open _build/html/index.html # or just open this file
Package: torch-template
torch_templateA python package for commonly used pytorch models, data loaders and utils.InstallationFor pippipinstalltorch-templateFor sourceClone the repo, cd into it and runpip install .command.gitclonehttps://github.com/misads/torch_template.gitcdtorch_template
pipinstall.For condasource~/anaconda3/bin/activate
condaactivate<env>
pythonsetup.pyinstallA configure filetorch_template.egg-infowill be generated in the repo directory. Copytorch_templateandtorch_template.egg-infoto yoursite-packagesfolder.UsageTest if the package is successfully installed:importtorch_templateasttfromtorch_templateimporttorch_utilsRun:#!-bashtt-newEnter your repo name, then a python project template will be created.DocumentationThe documentation webpage can be found herehttps://torch-template.readthedocs.io/en/latest/.File structureFile structure.├── network│     ├── base_model.py     :Define models, losses and parameter updating│     ├── norm.py           :Normalizations│     └── weights_init.py   :weights init│├── dataloader/             :Define Dataloaders├── model_zoo               :Commonly used models└── utils└── torch_utils.py    :PyTorch utils
Package: torchtemplates
Torch TemplatesThe file structure is vastly inspired frommadewithml.comand many Kaggle Kernels from top kagglers.Till now, this would create a package for you with thesetup.pyand therequirements.txt.TODO:Add TODO for hyperparameter tuning.File structure- src
    - config
        - config.py
    - project_name
        - main.py
        - dataset.py
        - model.py
        - train.py
        - utils.py
        - hyparam.py (need to add...)
    - README.md
    - requirements.txtHow to use?InstallpipinstalltorchtemplatesCommandstorchtemplates--helpinittorchtemplatesinitnew-pipelinetorchtemplatesnew-pipelineimagetesting
Package: torch-tensornet
TensorNet is a high-level deep learning library built on top of PyTorch.InstallationYou can use pip to install tensornetpip install torch-tensornetIf you want to get the latest version of the code before it is released on PyPI you can install the library from GitHubpip install git+https://github.com/shan18/TensorNet.git#egg=torch-tensornetDocumentationDocumentation is available at:https://tensornet.readthedocs.io/en/latest/How to UseFor examples on how to use TensorNet, refer to theexamplesdirectory.DependenciesTensorNet has the following third-party dependenciestorchtorchvisiontorchsummarytqdmmatplotlibalbumentationsopencv-pythonContact/Getting HelpIf you need any help or want to report a bug, raise an issue in the repo.
Package: torch-tensor-type
Torch Tensor TypesThis package is a Quality of Life improvement when prototyping and processing Tensor objects from the pyTorch library.
The TensorType class is a Pipeline for preprocessing tensors automatically, and include multiple utility methods.my_TensorType<<myDataYou can add TensorTypes together to have a longer preprocessing pipeline.myTensorType + myOtherTensorTypeFor example, this codefake_image=model(torch.unsqueeze(real_image,0).cuda()).cpu().detach().numpy()[0]can be replaced byfake_image=SingleDisplayableImage<<model(ModelInputFormat<<real_image)The list of arguments to the constructor is:TensorType:__init__(shape=None,transforms=[],torch_methods=[],to_batch=False,device=None,from_single_value=False,random_values=False,to_numpy=False,detach=False):All of these should be pretty telling by their name, if you know pyTorch.TensorType.shape: the input will be viewed as this shapeTensorType.transforms: a list of functions that will be applied at the endTensorType.torch_methods: a list of method names that will be called on the tensor i.e"mean" => tensor.mean()TorchType.to_batch: will unsqueeze the data into a batch with a single sampleTorchType.device: transfers the tensor to a deviceTorchType.from_single_value: creates a uniform tensor from a single valueTorchType.random_values: creates a tensor fromtorch.randTensorType.to_numpy: outputs a numpy arrayTensorType.detach: detachs the tensor from the graphSyntaxfromTTTimportTensorTypeasTT# Creates a uniform image tensor pipelinemyTensorType=TT(shape=(3,224,224),from_single_value=True)# A black imagedata=myTensorType<<0# "myTensorType" will parse first, then the other TTmyDisplayableImage=myTensorType+TT(to_numpy=True,transforms=[np.transpose])# A white image ready to displaymyDisplayableImage<<1
Package: torchtest
= torchtestA Tiny Test Suite for pytorch based Machine Learning models, inspired by https://github.com/Thenerdstation/mltest/blob/master/mltest/mltest.py[mltest].Chase Roberts lists out 4 basic tests in his https://medium.com/@keeper6928/mltest-automatically-test-neural-network-models-in-one-function-call-eb6f1fa5019d[medium post] about mltest.torchtest is mostly a pytorch port of mltest(which was written for tensorflow).== Installation[source, bash]----pip install --upgrade torchtest----== Tests[source, python]----# imports for examplesimport torchimport torch.nn as nnimport torch.nn.functional as Ffrom torch.autograd import Variable----=== Variables Change[source, python]----from torchtest import assert_vars_changeinputs = Variable(torch.randn(20, 20))targets = Variable(torch.randint(0, 2, (20,))).long()batch = [inputs, targets]model = nn.Linear(20, 2)# what are the variables?print('Our list of parameters', [ np[0] for np in model.named_parameters() ])# do they change after a training step?#  let's run a train step and seeassert_vars_change(model=model,loss_fn=F.cross_entropy,optim=torch.optim.Adam(model.parameters()),batch=batch)----[source, python]----""" FAILURE """# let's try to break this, so the test failsparams_to_train = [ np[1] for np in model.named_parameters() if np[0] is not 'bias' ]# run test nowassert_vars_change(model=model,loss_fn=F.cross_entropy,optim=torch.optim.Adam(params_to_train),batch=batch)# YES! bias did not change----=== Variables Don't Change[source, python]----from torchtest import assert_vars_same# What if bias is not supposed to change, by design?#  test to see if bias remains the same after trainingassert_vars_same(model=model,loss_fn=F.cross_entropy,optim=torch.optim.Adam(params_to_train),batch=batch,params=[('bias', model.bias)])# it does? good. let's move on----=== Output Range[source, python]----from torchtest import test_suite# NOTE : bias is fixed (not trainable)optim = torch.optim.Adam(params_to_train)loss_fn=F.cross_entropytest_suite(model, loss_fn, optim, batch,output_range=(-2, 2),test_output_range=True)# seems to work----[source, python]----""" FAILURE """#  let's tweak the model to fail the testmodel.bias = nn.Parameter(2 + torch.randn(2, ))test_suite(model,loss_fn, optim, batch,output_range=(-1, 1),test_output_range=True)# as expected, it fails; yay!----=== NaN Tensors[source, python]----""" FAILURE """model.bias = nn.Parameter(float('NaN') * torch.randn(2, ))test_suite(model,loss_fn, optim, batch,test_nan_vals=True)----=== Inf Tensors[source, python]----""" FAILURE """model.bias = nn.Parameter(float('Inf') * torch.randn(2, ))test_suite(model,loss_fn, optim, batch,test_inf_vals=True)----
Package: torch-testing
# Torch TestingA collection of assertion methods to compare PyTorch Tensors in tests.Currently all assertion methods are provided by converting the tensors to numpy arrays and feeding them into an appropriate `numpy.testing` method. That way, on failure, detailed information is provided as to why the test failed.Last tested with **Python 3.6.4 :: Anaconda, Inc.** and **PyTorch 0.4**.## InstallationYou can install this package using `pip`:```pypip install torch_testing```## Usage exampleYou can assert the equality of two `torch.tensor`s like```pyimport unittestimport torchimport torch_testing as ttclass TestSomeClass(unittest.TestCase):def test_some_method(self):a = torch.tensor([1, 2])b = torch.tensor([1, 2])tt.assert_equal(a, b)if __name__ == '__main__':unittest.main()```## Assertion methods### `assert_equal(actual, expected, **kwargs)`Currently this assertion method is provided by converting the tensors to `numpy` arrays using `tensor.numpy()` and feeding them to [numpy.testing.assert_equal](https://docs.scipy.org/doc/numpy/reference/generated/numpy.testing.assert_equal.html#numpy.testing.assert_equal).### `assert_allclose(actual, expected, rtol=1e-07, atol=0, equal_nan=True, **kwargs)`Currently this assertion method is provided by converting the tensors to `numpy` arrays using `tensor.numpy()` and feeding them to [numpy.testing.assert_allclose](https://docs.scipy.org/doc/numpy/reference/generated/numpy.testing.assert_allclose.html#numpy.testing.assert_allclose).### `assert_within(tensor, min_val, max_val, rtol=0)`Ensures that all values of the given `tensor` are greater than or equal to `min_val` and less than or equal to `max_val`. Allows to specify a relative tolerance `rtol`, which behaves as in [numpy.testing.assert_allclose](https://docs.scipy.org/doc/numpy/reference/generated/numpy.testing.assert_allclose.html#numpy.testing.assert_allclose).*NOTE: Uses `assert_allclose` under the hood, hence the fail message might currently be a little confusing.*## Development*Unless noted otherwise, all commands are expected to be executed from the root directory of this repository.*### Building the package for local developmentTo make the package available locally while making sure changes to the files are reflected immediately, run```shpip install -e .```### Test suiteRun all tests using```shpython -m unittest discover tests```
Package: torch_text_similarity
torch-text-similarityImplementations of models and metrics for semantic text similarity.
Includes fine-tuning and prediction of models. Thanks for the elegent
implementations of @Andriy Mulyar, who has published a lot of useful
codes.InstallationInstall with pip:pip install torch-text-similarityUseMaps batches of sentence pairs to real-valued scores in the range [0,5]importtorchfromtorch_text_similarityimportTextSimilarityLearnerfromtorch_text_similarity.dataimporttrain_eval_sts_a_datasetlearner=TextSimilarityLearner(batch_size=10,model_name='web-bert-similarity',loss_func=torch.nn.MSELoss(),learning_rate=5e-5,weight_decay=0,device=torch.device('cuda:0'))train_dataset,eval_dataset=train_eval_sts_a_dataset(learner.bert_tokenizer,path='./data/train.csv')learner.load_train_data(train_dataset)learner.train(epoch=1)predictions=learner.predict([('The patient is sick.','Grass is green.'),('A prescription of acetaminophen 325 mg was given.',' The patient was given Tylenol.')])print(predictions)Make submission to a semantic text similarity competitionimporttorchimportpandasaspdfromtorch_text_similarityimportTextSimilarityLearnerfromtorch_text_similarity.dataimporttrain_eval_sts_a_datasetlearner=TextSimilarityLearner(batch_size=10,model_name='web-bert-similarity',loss_func=torch.nn.MSELoss(),learning_rate=5e-5,weight_decay=0,device=torch.device('cuda:0'))train_dataset,eval_dataset=train_eval_sts_a_dataset(learner.bert_tokenizer,path='/home/temp/Data/kaggle/data/train.csv')learner.load_train_data(train_dataset)learner.train(epoch=1)test_data=pd.read_csv('./data/test.csv')preds_list=[]fori,rowintest_data.iterrows():text_a=row['text_a']text_b=row['text_b']preds=learner.predict([(text_a,text_b)])[0]preds_list.append(preds)submission=pd.DataFrame({"id":range(len(preds_list)),"label":preds_list})submission.to_csv('./submission.csv',index=False,header=False)Moreexamples.InstallationThe data sets in the examples can be found in Google Cloud Drive:train.csvtest.csvsts-train.csvsts-test.csvsts-dev.csv
Package: torch-time-stretch
Torch Time StretchTime-stretch audio clips quickly with PyTorch (CUDA supported)! Additional utilities for searching efficient transformations are included.View on PyPI/View DocumentationAboutThis package includes two main features:Time-stretch audio clips quickly using PyTorch (with CUDA support)Calculate efficient time-stretch targets (useful for augmentation, where speed is more important than precise time-stretches)Also check outtorch-pitch-shift, a sister project for pitch-shifting.Installationpipinstalltorch-time-stretchUsageExampleCheck outexample.pyto seetorch-time-stretchin action!DocumentationSee thedocumentation pagefor detailed documentation!ContributingPlease feel free to submit issues or pull requests!
Package: torchtnt
TNTTNTis a library for PyTorchtrainingtools and utilities.InstallationTNT can be installed with pip:pip install torchtntOr, alternatively, via conda:conda install -c conda-forge torchtntIf you run into issues, make sure that Pytorch is installed first.You can also install the latest version from master. Just run:pip install git+https://github.com/pytorch/tnt.git@masterTo update to the latest version from master:pip install --upgrade git+https://github.com/pytorch/tnt.git@master
Package: torchtnt-nightly
TNTTNTis a library for PyTorchtrainingtools and utilities.InstallationTNT can be installed with pip:pip install torchtntOr, alternatively, via conda:conda install -c conda-forge torchtntIf you run into issues, make sure that Pytorch is installed first.You can also install the latest version from master. Just run:pip install git+https://github.com/pytorch/tnt.git@masterTo update to the latest version from master:pip install --upgrade git+https://github.com/pytorch/tnt.git@master
Package: torchtoolkit
TorchToolkitHi 👋, this is a small Python package containing useful functions to use with PyTorch.
It includesutilities,metricsandsamplingmethods to use during and after training a model.Feel free to use it, take the code for your projects, and raise an issue if you have question or a pull request if you want to contribute.pipinstalltorchtoolkitIt requires Python 3.8 or above.Simplest example:fromtorchtoolkit.metricsimportAccuracyfromtorchimportrandint,randnfrompathlibimportPathacc=Accuracy(mode='top_k',top_kp=5)for_inrange(10):res=randn((16,32))expected=randint(0,32,(16,))acc(res,expected)# saving resultsacc.save(Path('path','to','save','file.csv'))acc.analyze()I built it for my own usage, so you won't find documentation besides the docstring.
Package: torch-tools
ReadmeA library of helpers for PyTorch.Michaël Gharbi <mgharbi@adobe.com>InstallationFrom pip:pip installtorch-toolsFrom source:python setup.py installQuickstartTo quickly get up and running, use our repo initialization script. In your command line, simple run:ttools.newThis will prompt you to give a name to your new project, and create the
necessary files and folders for you.DocumentationThe documentation webpage can be foundhere https://torch-tools.readthedocs.io/en/latest/DemoFor a simple demo, look at the MNIST example inexamples/train_mnist.py:python examples/train_mnist.py data outContributorsDima Smirnov implemented the tensorboard hooks and callbacks.