Saravanan666/pypi-org huggingface dataset:
Package: torch-cif
torch-cifA fast parallel implementation pure PyTorch implementation of"CIF: Continuous Integrate-and-Fire for End-to-End Speech Recognition"https://arxiv.org/abs/1905.11235.InstallationPyPIpipinstalltorch-cifLocallygitclonehttps://github.com/George0828Zhang/torch_cifcdtorch_cif
pythonsetup.pyinstallUsagedefcif_function(inputs:Tensor,alpha:Tensor,beta:float=1.0,tail_thres:float=0.5,padding_mask:Optional[Tensor]=None,target_lengths:Optional[Tensor]=None,eps:float=1e-4,unbound_alpha:bool=False)->Dict[str,List[Tensor]]:r""" A fast parallel implementation of continuous integrate-and-fire (CIF)https://arxiv.org/abs/1905.11235Shapes:N: batch sizeS: source (encoder) sequence lengthC: source feature dimensionT: target sequence lengthArgs:inputs (Tensor): (N, S, C) Input features to be integrated.alpha (Tensor): (N, S) Weights corresponding to each elements in theinputs. It is expected to be after sigmoid function.beta (float): the threshold used for determine firing.tail_thres (float): the threshold for determine firing for tail handling.padding_mask (Tensor, optional): (N, S) A binary mask representingpadded elements in the inputs. 1 is padding, 0 is not.target_lengths (Tensor, optional): (N,) Desired length of the targetsfor each sample in the minibatch.eps (float, optional): Epsilon to prevent underflow for divisions.Default: 1e-4unbound_alpha (bool, optional): Whether to check if 0 <= alpha <= 1.Returns -> Dict[str, List[Tensor]]: Key/values described below.cif_out: (N, T, C) The output integrated from the source.cif_lengths: (N,) The output length for each element in batch.alpha_sum: (N,) The sum of alpha for each element in batch.Can be used to compute the quantity loss.delays: (N, T) The expected delay (in terms of source tokens) foreach target tokens in the batch.tail_weights: (N,) During inference, return the tail.scaled_alpha: (N, S) alpha after applying weight scaling.cumsum_alpha: (N, S) cumsum of alpha after scaling.right_indices: (N, S) right scatter indices, or floor(cumsum(alpha)).right_weights: (N, S) right scatter weights.left_indices: (N, S) left scatter indices.left_weights: (N, S) left scatter weights."""NoteThis implementation usescumsumandfloorto determine the firing positions, and usescatterto merge the weighted source features. The figure below demonstrates this concept usingscaledweight sequence(0.4, 1.8, 1.2, 1.2, 1.4)Runing test requirespip install hypothesis expecttest.Ifbeta != 1, our implementation slightly differ from Algorithm 1 in the paper[1]:When a boundary is located, the original algorithm add the last feature to the current integration with weight1 - accumulation(line 11 in Algorithm 1), which causes negative weights in next integration whenalpha < 1 - accumulation.We usebeta - accumulation, which means the weight in next integrationalpha - (beta - accumulation)is always positive.Feel free to contact me if there are bugs in the code.ReferencesCIF: Continuous Integrate-and-Fire for End-to-End Speech RecognitionExploring Continuous Integrate-and-Fire for Adaptive Simultaneous Speech Translation
Package: torch-clip
TorchClippedOptimizerstorch-clipa library to improve optimization methods by clipping off heavy-tailed gradient. This makes it possible to increase the accuracy and speed of convergence during the training of neural networks on a specific number of tasks.Installationyou can install our library using pip:pip install torch-clipnumpy~=1.20.0
torch~=1.11.0+cu113
matplotlib~=3.4.3
tqdm~=4.62.3What do you need us for?In the last few years, for various neural network training models (for example, BERT + CoLA), it has been found that in the case of "large stochastic gradients", it is advantageous to use special clipping (clipping/normalization) of the batched gradient. Since all modern machine learning, one way or another, ultimately boils down to stochastic optimization problems, the question of exactly how to "clip" large values of batched gradients plays a key role in the development of effective numerical training methods for a large class of models. This repository implements optimizers for the pytorch library with different clipping methods.Our repositoryThe source code and research results can be found at the link:https://github.com/EugGolovanov/TorchClippedOptimizersUse exampleYou can use our optimizers as well as all the standard optimizers from the pytorch libraryfromtorch_clip.optimizersimportClippedSGDoptimizer=ClippedSGD(model.parameters(),lr=5e-2,momentum=0.9,clipping_type="layer_wise",clipping_level=1)loss=my_loss_functionforepochinrange(EPOCHS):fori,datainenumerate(train_loader,0):outputs=net(inputs)loss=criterion(outputs,labels)loss.backward()optimizer.step()optimizer.zero_grad()Use example (with restarts)fromtorch_clip.optimizersimportClippedSGDfromtorch_clip.restarterimportRestarterfromtorch_clip.optimizers_collectorimportOptimizerProperties,ModelProperties,RestartPropertiesloss=my_loss_functionmodel=my_model_objectoptimizer_props=OptimizerProperties(ClippedSGD,lr=5e-2,momentum=0.9,clipping_type="layer_wise",clipping_level=1)restarter=Restarter(optimizer_properties=optimizer_props,first_restart_steps_cnt=50,restart_coeff=1.25,max_steps_cnt=2000)optimizer=optimizer_props.optimizer_class(model.parameters(),**optimizer_props.optimizer_kwargs)forepochinrange(EPOCHS):fori,datainenumerate(train_loader,0):outputs=model(inputs)loss=criterion(outputs,labels)loss.backward()optimizer.step()optimizer.zero_grad()restarter.add_coords(model.parameters())optimizers=restarter.make_restart(net,optimizer)
Package: torchcluster
Documentation|Torchcluster is a python package for cluster analysis. The speed of the
clustering algorithm has been effectively improved with the Pytorch
backend. We are also working on test datasets and visualization tools.
Related work is coming in the next release.System requirementstorchcluster should work onall Linux distributions no earlier than Ubuntu 16.04macOS XWindows 10torchcluster also requires Python 3.5 or later. Python 2 support is
coming.Right now, torchcluster works onPyTorch0.4.1.InstallationUsing pippip install torchclusterUsing anacondaconda install -c tczhangzhi torchclusterHow torchcluster looks likeDefine a dataset generator and generate a dataset:from torchcluster.dataset.simple import SimpleDataset

dataset_factory = SimpleDataset(2, feature=2, sigma=2, device=device)
dataset = dataset_factory(100)Configuring a clustering algorithm and get your result:from torchcluster.zoo.spectrum import SpectrumClustering

cluster = SpectrumClustering(2)
result, _ = cluster(dataset)You can also cluster your own data sets. The dataset should be a tensor
of n by m, where n is the number of data points in the dataset and m is
the dimension of each data point:dataset = torch.cat([torch.randn(500,2) + torch.Tensor([-2,-3]), torch.randn(500,2) + torch.Tensor([2,1])])Use spectral clustering to get the following results:tensor([0, 0, ..., 1, 1])LicenseMITCopyright (c) 2019-present, Zhang Zhi
Package: torchcnnbuilder
TorchCNNBuilderTorchCNNBuilderis an open-source framework for the automatic creation of CNN architectures. This framework should first of all help researchers in the applicability of CNN models for a huge range of tasks, taking over most of the writing of the architecture code. This framework is distributed under the 3-Clause BSD license. All the functionality is written only usingpytorch(no third-party dependencies)InstallationThe simplest way to install framework is usingpip:pip install torchcnnbuilderUsage examplesThe basic structure of the framework is presented below. Each subdirectory has its own example of using the appropriate available functionality. You can check<directory>_examples.ipynbfiles in order to see the ways to use the proposed toolkit. In short, there is the following functionality:the ability to calculate the size of tensors after (transposed) convolutional layerspreprocessing an n-dimensional time series inTensorDatasetautomatic creation of (transposed) convolutional sequencesautomatic creation of (transposed) convolutional layers and (transposed) blocks from convolutional layersThe structure of the main part of the package:├── examples
│ ├── builder_examples.ipynb
│ ├── preprocess_examples.ipynb
│ ├── models_examples.ipynb
│ └── tools                     # additional functions for the examples
└── torchcnnbuilder
    ├── preprocess
    │ └── time_series.py
    ├── builder.py
    └── models.pyInitially, the library was created to help predict n-dimensional time series(geodata), so there is a corresponding functionality and templates of predictive models(likeForecasterBase)SourcesForecasting of Sea Ice Concentration using CNN, PDE discovery and Bayesian NetworksSurrogate Modelling for Sea Ice Concentration using Lightweight Neural Ensemble
Package: torch-complex
pytorch_complexA temporal python class for PyTorch-ComplexTensorWhat is this?A Python class to perform asComplexTensorin PyTorch: Nothing except for the following,classComplexTensor:def__init__(self,...):self.real=torch.Tensor(...)self.imag=torch.Tensor(...)Why?PyTorch is great DNN Python library, except that it doesn't supportComplexTensorin Python level.https://github.com/pytorch/pytorch/issues/755I'm looking forward to the completion, but I needComplexTensorfor now.
I created this cheap module for the temporal replacement of it. Thus, I'll throw away this project as soon asComplexTensoris completely supported!RequirementsPython>=3.6
PyTorch>=1.0Installpip install torch_complexHow to useBasic mathematical operationimportnumpyasnpfromtorch_complex.tensorimportComplexTensorreal=np.random.randn(3,10,10)imag=np.random.randn(3,10,10)x=ComplexTensor(real,imag)x.numpy()x+xx*xx-xx/xx**1.5x@x# Batch-matmulx.conj()x.inverse()# Batch-inverseAll are implemented with combinations of computation ofRealTensorin python level, thus the speed　is not good enough.Functionalimporttorch_complex.functionalasFF.cat([x,x])F.stack([x,x])F.matmul(x,x)# Same as x @ xF.einsum('bij,bjk,bkl->bil',[x,x,x])For DNNAlmost all methods thattorch.Tensorhas are implemented.x.cuda()x.cpu()(x+x).sum().backward()
Package: torchconfig
TorchConfigTorchConfigis a Python package that simplifies configuring PyTorch.Suppose that you want to test multiple optimizers to find which optimizer works best with your model. Here is one way you could achieve this:ifCONFIG["optimizer_name"]=="SGD":optimizer=optim.SGD(net.parameters(),lr=CONFIG["optimizer_lr"],momentum=CONFIG["optimizer_momentum"],dampening=CONFIG["optimizer_dampening"],weight_decay=CONFIG["optimizer_weight_decay"],nesterov=CONFIG["optimizer_nesterov"],)...elifCONFIG["optimizer_name"]=="Adam":optimizer=optim.Adam(net.parameters(),lr=CONFIG["optimizer_lr"],betas=CONFIG["optimizer_betas"],eps=CONFIG["optimizer_eps"],weight_decay=CONFIG["optimizer_weight_decay"],amsgrad=CONFIG["optimizer_amsgrad"],)}With TorchConfig, this is just one line!optimizer=torchconfig.get_optimizer_from_dict(net.parameters(),CONFIG)Installationpip install torchconfigHow to UseYou can specify anyoptimizerorlr_schedulerby specifying its name through a dictionary key-value pair or an argument.optimizer_config={"name":"SGD","lr":0.1}optimizer=torchconfig.get_optimizer_from_args(net.parameters(),name="SGD",lr=0.1)# oroptimizer=torchconfig.get_optimizer_from_args(net.parameters(),**optimizer_config)# oroptimizer=torchconfig.get_optimizer_from_dict(net.parameters(),optimizer_config)lr_scheduler_config={"name":"CyclicLR","base_lr":0.01,"max_lr":1}lr_scheduler=torchconfig.get_lr_scheduler_from_args(optimizer,**CONFIG["lr_scheduler"])# orlr_scheduler=torchconfig.get_lr_scheduler_from_args(optimizer,name="CyclicLR",base_lr=0.01,max_lr=1)# orlr_scheduler=torchconfig.get_lr_scheduler_from_dict(optimizer,CONFIG["lr_scheduler"])
Package: torch-constrained
torch_constrainedSteps for developmentPython >= 3.81) Clone the repository with the ssh linkgit clone git@github.com:manuel-delverme/constrained_optimization.git2)venvand requirement installationinstall torch manually for your cuda driver https://pytorch.org/get-started/locally/

python -m venv venv
source venv/bin/activate
pip install -r requirements-dev.txt3) Enable flake for good code checkingpre-commit install
git config --bool flake8.strict trueStyle guideshttps://google.github.io/styleguide/pyguide.htmlhttps://www.python.org/dev/peps/pep-0008/
Package: torchcontentarea
Torch Content AreaA PyTorch tool kit for estimating the circular content area in endoscopic footage. This implementation is released alongside our publication:Rapid and robust endoscopic content area estimation: A lean GPU-based pipeline and curated benchmark dataset,Charlie Budd, Luis C. Garcia-Peraza-Herrera, Martin Huber, Sebastien Ourselin, Tom Vercauteren.[arXiv]If you make use of this work, please cite the paper.InstallationTo install the latest version, simply run...pip install torchcontentareaUsagefromtorchvision.ioimportread_imagefromtorchcontentareaimportestimate_area,get_points,fit_area# Image in NCHW format, byte/uint8 type is expectedimage=read_image("my_image.png").unsqueeze(0)# Either directly estimate area from image...area=estimate_area(image,strip_count=16)# ...or get the set of points and then fit the area.points=get_points(image,strip_count=16)area=fit_area(points,image.shape[2:4])PerformancePerformance is measured against the CholecECA subset of theEndoscopic Content Area (ECA) dataset.Performance Results (handcrafted cpu)...Avg Time (Intel(R) Xeon(R) CPU E5-1650 v3 @ 3.50GHz): 2.501msAvg Error (Hausdorff Distance): 3.535Miss Rate (Error > 15): 2.1%Bad Miss Rate (Error > 25): 1.0%Performance Results (learned cpu)...Avg Time (Intel(R) Xeon(R) CPU E5-1650 v3 @ 3.50GHz): 4.662msAvg Error (Hausdorff Distance): 4.388Miss Rate (Error > 15): 2.6%Bad Miss Rate (Error > 25): 1.4%Performance Results (handcrafted cuda)...Avg Time (NVIDIA GeForce GTX 980 Ti): 0.171msAvg Error (Hausdorff Distance): 4.289Miss Rate (Error > 15): 2.4%Bad Miss Rate (Error > 25): 1.3%Performance Results (learned cuda)...Avg Time (NVIDIA GeForce GTX 980 Ti): 1.349msAvg Error (Hausdorff Distance): 4.641Miss Rate (Error > 15): 2.6%Bad Miss Rate (Error > 25): 1.3%
Package: torchconvview
torchconvviewA library for PyTorch convolution layer visualizations via matplotlib plots.InstallationTo install published releases from PyPi execute:pipinstalltorchconvviewTo update torchconvquality to the latest available version, add the--upgradeflag to the above commands.If you want the latest (potentially unstable) features you can also directly install from the github main branch:pipinstallgit+https://github.com/paulgavrikov/torchconvviewUsagefromtorchconvvisionimportplot_conv,plot_conv_rgb,PCAViewimportmatplotlib.pyplotasplt# Replace this with your own model. As an example,# we will use an ImageNet pretrained ResNet-18.importtorchvisionmodel=torchvision.models.resnet18(pretrained=True)GeneralAllplot_...functions return a tuple of the matplotlib figure and axes which allow you to customize the plot to your needs. Also most of these functions accept theimg_scaleargument which allows you to specify a multiplier to the resolution.Visualize kernels in the convolution layersJust pass the convolution weight as tensor or numpy intoplot_convand you'll get a matplotlib figure of the kernels! Each column is one channel/filter, i.e. this stack of kernels generates a feature-map from all input maps.plot_conv(model.layer1[1].conv2.weight)plt.show()Visualize the first layerIf you have a convolution layer with RGB input (e.g. often the first layer), the you can visualize entire filters. This function maps all kernels to their respective color. Note that this only work on convolution layers with 3 input channels and only produces meaningfull results if these channels are R, G, B feature-maps!plot_conv_rgb(model.conv1.weight)plt.show()PCA of convolution weightsYou can also compute the eigenimages/basis vectors of the kernels by using thePCAViewclass. Under the hood it will do a PCA for you. Note, that currently this requires thescikit-learnmodule.pcaview=PCAView(model.conv1.weight)pcaview.plot_conv()plt.show()And to get a handy barplot of the explained variance ratio:pcaview.plot_variance_ratio()plt.show()CitationPlease consider citing our publication if this libary was helpfull to you.@InProceedings{Gavrikov_2022_CVPR,
    author    = {Gavrikov, Paul and Keuper, Janis},
    title     = {CNN Filter DB: An Empirical Investigation of Trained Convolutional Filters},
    booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
    month     = {June},
    year      = {2022},
    pages     = {19066-19076}
}LegalThis work is licensed under aCreative Commons Attribution-ShareAlike 4.0 International License.Funded by the Ministry for Science, Research and Arts, Baden-Wuerttemberg, Germany Grant 32-7545.20/45/1 (Q-AMeLiA).
Package: torchcpd
Torch-CPDPytorch Implementation of the Coherent Point Drift Algorithm.IntroductionThis is a PyTorch re-implementation of the excellentpycpdpackage, which implements theCoherent Point Drift (CPD)algorithm. Only Rigid and Deformable Registration and currently implemented. The default is to use CUDA to speed up computation, which is significantly faster than pure Numpy. Refer to thepycpdpackage for examples of how to use CPD for registration.InstallationInstall from PyPIYou should install torch separately, follow instructions athttps://pytorch.org/get-started/locally/pipinstalltorchcpdInstallation from Sourcegitclonehttps://github.com/ramtingh/torchcpd.git$HOME/torchcpdInstall the package:pipinstall.
Package: torchcrepeV2
TorchCrepeV2My own version ofcrepein PyTorch, SOTA pitch tracking tool. Releasing as pip package for ease of usage.Onlyfullversion of model is supported.Similar project:https://github.com/maxrmorrison/torchcrepeUsagepip install torchcrepeV2fromtorchcrepeV2importTorchCrepePredictorimportlibrosaimportnumpyasnpimportmatplotlib.pyplotasplty,sr=librosa.load("some_audio.wav",sr=16000)torch_crepe=TorchCrepePredictor(device="cuda")# all arguments are aligned with original crepe implementationf=torch_crepe.predict(audio=y,sr=sr,viterbi=True,center=True,step_size=10)# can add some post-processingblock_size=100length=y.shape[0]//100iff.shape[-1]!=length:f=np.interp(np.linspace(0,1,length,endpoint=False),np.linspace(0,1,f.shape[-1],endpoint=False),f,)plt.plot(f,label='torchcrepe')plt.show()ResultsTracked pitch nearly identical as compared tocrepe.TODOAdd unit tests
Package: torchcsv
torchcsvAn PyTorch Dataset subclass for handling numerical data too large to fit in local memory.InstallationTo install, runpip install torchcsv.UsageTheCSVDatasetclass inherits fromtorch.Datasetlike we always do with custom Dataset classes. However, rather than reading the entire data and label.csvinto memory, we make two assumptions:The dataset is too large to fit in local memoryThe labels are contained in a separate file. If this isn't the case, consider usingDaskto obtain the column of interest, and then continue.So, we initialize theCSVDatasetobject asfromtorchcsvimportCSVDatasetdata=CSVDataset(datafile='path/to/datafile.csv',labelfile='path/to/labelfile.csv',target_label='Animal Type',# Column name containing targets in labelfile.csv# indices=idx_list # Optionally, pass a list of purely numeric indices to use instead of the entire indices of the labelfile)For example, getting a 16.3k dimensional sample takes>%%time>test[1]CPUtimes:user5.99ms,sys:576µs,total:6.56msWalltime:6.19ms(tensor([0.,0.,0.,...,0.,0.,0.]),16)Now, we can use this like a regular PyTorch Dataset, but without having to worry about memory issues!For example,fromtorch.utils.dataimportDataloaderdata=DataLoader(data,batch_size=4,num_workers=0)Gives us that%%timenext(iter(test))CPUtimes:user25.6ms,sys:20.8ms,total:46.4msWalltime:76.9ms[tensor([[0.0000,0.0000,0.0000,...,0.0000,0.0000,0.0000],[0.0000,0.0000,0.0000,...,0.0000,0.0000,0.0000],[0.0000,0.0000,0.0000,...,0.0000,0.0000,0.0000],[0.0000,0.0000,1.2663,...,0.0000,0.0000,0.0000]]),tensor([16,16,4,4])]So loading a minibatch of size 4 takes about a quarter of a second. TheCSVDatasetclass should be scalable, and will keep in memory what it can via thelinecachelibrary.
Package: torch-cubic-b-spline-grid
torch-cubic-b-spline-gridCubic B-spline interpolation on multidimensional grids in PyTorch.The primary goal of this package is to provide a learnable, continuous
parametrization of 1-4D spaces.This is a PyTorch implementation of the model used inWarpfor continuous deformation
fields and locally variable optical parameters in cryo-EM images. The approach is described inDimitry Tegunov's paper:Many methods in Warp are based on a continuous parametrization of 1- to
3-dimensional spaces.
This parameterization is achieved by spline interpolation between points on a coarse,
uniform grid, which is computationally efficient.
A grid extends over the entirety of each dimension that needs to be modeled.
The grid resolution is defined by the number of control points in each dimension
and is scaled according to physical constraints
(for example, the number of frames or pixels) and available signal.
The latter provides regularization to prevent overfitting of sparse data with too many
parameters.
When a parameter described by the grid is retrieved for a point in space (and time),
for example for a particle (frame), B-spline interpolation is performed at that point
on the grid.
To fit a grid’s parameters, in general, a cost function associated with the
interpolants at specific positions on the grid is optimized.
Package: torchcv
torchvisionThe torchvision package consists of popular datasets, model architectures, and common image transformations for computer vision.InstallationAnaconda:condainstalltorchcv-cpytorchpip:pipinstalltorchcvorpipinstall-ihttps://pypi.python.org/pypitorchcvFrom source:pythonsetup.pyinstallImage BackendTorchvision currently supports the following image backends:Pillow(default)Pillow-SIMD- amuch fasterdrop-in replacement for Pillow with SIMD. If installed will be used as the default.accimage- if installed can be activated by callingtorchvision.set_image_backend('accimage')DocumentationYou can find the API documentation on the pytorch website:http://pytorch.org/docs/master/torchvision/ContributingWe appreciate all contributions. If you are planning to contribute back bug-fixes, please do so without any further discussion. If you plan to contribute new features, utility functions or extensions, please first open an issue and discuss the feature with us.
Package: torchcvnn
Complex-Valued Neural Networks (CVNN) - PytorchThis is a library that usespytorchas a back-end for complex valued neural networks.It was initially developed by Victor Dhédin and Jérémie Levi during their third year project at CentraleSupélec.InstallationTo install the library, it is simple as :python -m pip install torchcvnnInstallation for developpingTo install when developping the library, within a virtual envrionment, you can :git clone git@github.com:jeremyfix/torchcvnn.git
python3 -m venv torchcvnn-venv
source torchcvnn-venv/bin/activate
python -m pip install -e torchcvnnThis will install torchcvnn in developper mode.Releasing a new versionTo trigger the pipeline for a new release, you have to tag a commit and to push
it on the main branch[main] git tag x.x.x
[main] git push --tagsThis will trigger theci-cd.ymlpipeline which builds the distribution,
release it on github and on pypi.Any commit that is not explicitely tagged with a version number does not trigger
the release ci-cd pipeline.Other projectsYou might also be interested in some other projects:Tensorflow based :cvnndeveloped by colleagues from CentraleSupélecPytorch based :cplxmodulecomplexPyTorch