Saravanan666/pypi-org huggingface dataset:
Package: torchest
TorchestPytorch tools and utilities (Trainers, data generators, functions, and more...)TrainersOne of the most common tasks you will do in pytorch is define training loops, which is a hassle because they are almost always the same. Torchest has trainers you can use for your projectsfromtorchest.trainerimportSimpleTrainer# previous definition of model and data preparation# train_dataloader = DataLoader(train_data)# dev_dataloader = DataLoader(dev_data)# test_dataloader = DataLoader(test_data)# model = nn.Sequential(...)..."""Prepare Trainer"""loss_fn=nn.CrossEntropyLoss()learning_rate=1e-2optimizer=optim.Adam(model.parameters(),lr=learning_rate)trainer=SimpleTrainer(model,loss_fn,optimizer)"""Train"""epochs=500trainer.train(data_train=train_dataloader,data_dev=dev_dataloader,data_test=test_dataloader,epochs=epochs)Training loop progress31%|██████████████████▍      | 156/500 [00:02<00:05, 58.01epoch/s, train_accuracy=76.2, train_cost=0.238290]Trainer also saves the cost for the train, dev and test passes. You can simply calltrainer.plot_costs()to display the graph with the costsWandb visualizationTrainers supportwandbto visualize loss and acurracy as well as to save model versions. if you want to enable you have to set 2 parameters in your trainer initialization,nameandwandbtrainer=SimpleTrainer(model,loss_fn,optimizer,wandb_project_name="MyProject",wandb=True)On the first run you will have to enter your API key, which you can obtain athttps://wandb.ai/settingsData generatorsSpiral dataThis will create a 2d matrix with points in a dataplot. Ideal for testing non-linearity in your networkfromtorchest.datagenimportspiral_datagenclass_num=3X,Y=spiral_datagen(450,class_num)# 450 elements per class
Package: torchetl
TorchETLIf you're working on classification problem, with dataset that is available in their native format (jpg, bmp, etc) and have PyTorch in your arsenal, you'll most likely feel that theDatasetFolderorImageFolderis not good enough. So does vanillatorch.utils.data.Dataset. This library attempts to bridge that gap to effectively Extract, Transform, and Load your data by extendingtorch.utils.data.Dataset.Main FeaturesExtract class would partition your dataset into train, validation, and test csvTransformAndLoad class would Transform and consume your dataset efficientlyPrerequisitesPython 3.7.2 (other versions might work if type checking is supported)torchtorchvisionnumpypandasopencv-pythonsklearnOr simply download requirements.txt and fire 'pip3 install -r requirements.txt'Installingpip3 install torchetlTutorialSee tutorial/Tutorial.ipynb
Package: torch-eunn
torch_eunnThis repository contains a simple PyTorch implementation of a Tunable Efficient
Unitary Neural Network (EUNN) Cell.The implementation is loosely based on the tunable EUNN presented in this
paper:https://arxiv.org/abs/1612.05231.Installationpip install torch_eunnUsagefromtorch_eunnimportEUNN# feed forward layerfromtorch_eunnimportEURNN# recurrent unitNoteThehidden_sizeandthecapacityof the EUNN need to beeven, as explained in the section"Difference with original implementation".Examples00:Simple Tests01:Copying Task02:MNIST TaskRequirementsPyTorch>= 0.4.0:conda install pytorch -c pytorchDifference with original implementationThis implementation of the EUNN has a major difference with the original
implementation proposed inhttps://arxiv.org/abs/1612.05231, which is
outlined below.In the original implementation, the first output of the top directional coupler
of a capacity-2 sublayer skips the second layer of directional couplers
(indicated with dots in the ascii figure below) to connect to the next
capacity-2 sublayer of the EUNN. The reverse happens at the bottom, where the
first layer of the capacity-2 sublayer is skipped. This way, a(2*n+1)-dimensional unitary matrix representation is created, withnthe
number of mixing units in each capacity-1 sublayer.__  __......
    \/
  __/\____  __
          \/
  __  ____/\__
    \/
  __/\____  __
          \/
  ......__/\__For each capacity-1 sublayer withN=2*n+1inputs (Nodd), we thus haveN-1parameters (each mixing unit has 2 parameters). Thus to have a unitary matrix
representation that spans the full unitary space, one needsNcapacity-1
layersandNextraphases appended to the back of the capacity-Nsublayer to bring the total number of parameters in the unitary-matrix
representation toN**2(the total number of independent parameters in a
unitary matrix).In the implementation proposed here, the dots in each capacity-2 sublayer are
connected onto themselves (periodic boundaries). This has the implication that
for each capacity-1 sublayer withndirectional couplers, there areN=2*ninputs and as many independent parameters. This means that we just needNcapacity-1 sublayers andnoextraphases to span the full unitary space
withN**2parameters.This, however, has the implication that thehidden_size = N = 2*nof the
unitary matrix should always beeven. Also, because the forward pass is
defined per capacity-2sublayer (as opposed per capacity-1 sublayer in the
original implementation) the capacity has to beevenas well.License© Floris Laporte, 2018-2019.Made available under the MIT license.
Package: torchex
(WIP)torchex librarytorchexlibrary provides advanced Neural Network Layers. You can easily use them like using original pytorch.Installation$ pip install torchexRequirementsPytorch >= 1.0Documentationhttps://torchex.readthedocs.io/en/latest/index.htmlHow to useLazy Style Model Definitionimporttorchimporttorchex.nnasexnnnet=exnn.Linear(10)# You don't need to give the size of input for this module.# This network is equivalent to `nn.Linear(100, 10)`.x=troch.randn(10,100)y=net(x)torchex.nn listtorchex.nn.Passtorchex.nn.Flattentorchex.nn.LinearLazy styletorchex.nn.Conv1dLazy styletorchex.nn.Conv2dLazy styletorchex.nn.Conv3dLazy styletorchex.nn.Conv2dLocaltorchex.nn.GlobalAvgPool1dtorchex.nn.GlobalAvgPool2dtorchex.nn.GlobalMaxPool1dtorchex.nn.GlobalMaxPool2dtorchex.nn.MaxAvgPool2dtorch.nn.Crop2dtorch.nn.Crop3dtorch.nn.MLPConv2dtorch.nn.UpsampleConvLayertorch.nn.CordConv2dtorch.nn.DFT1dtorch.nn.DFT2dtorch.nn.PeriodicPad2dtorch.nn.PeriodicPad3dtorch.nn.Highwaytorch.nn.Inceptiontorch.nn.InceptionBNtorch.nn.IndRNNCelltorch.nn.IndRNNTanhCelltorch.nn.IndRNNReLuCelltorch.nn.IndRNNtorch.nn.GraphLineartorch.nn.GraphConvtorch.nn.SparseMMtorch.nn.GraphBatchNromtorchex.data.transformstorchex.data.transforms.PadRandomSifttorchex.data.transforms.RandomResizetorchex.data.attributefor visualizationtorchex.attribute.IntegratedGradients
Package: torchfcn
pytorch-fcnPyTorch implementation ofFully Convolutional Networks.Requirementspytorch>= 0.2.0torchvision>= 0.1.8fcn>= 6.1.5PillowscipytqdmInstallationgitclonehttps://github.com/wkentaro/pytorch-fcn.gitcdpytorch-fcn
pipinstall.# orpipinstalltorchfcnTrainingSeeVOC example.AccuracyAt10fdec9.ModelImplementationepochiterationMean IUPretrained ModelFCN32sOriginal--63.63DownloadFCN32sOurs119600062.84FCN16sOriginal--65.01DownloadFCN16sOurs119600064.91FCN8sOriginal--65.51DownloadFCN8sOurs76000065.49FCN8sAtOnceOriginal--65.40FCN8sAtOnceOurs119600064.74Visualization of validation result of FCN8s.Cite This ProjectIf you use this project in your research or wish to refer to the baseline results published in the README, please use the following BibTeX entry.@misc{pytorch-fcn2017,author={KetaroWada},title={{pytorch-fcn:PyTorchImplementationofFullyConvolutionalNetworks}},howpublished={\url{https://github.com/wkentaro/pytorch-fcn}},year={2017}}
Package: torchfcpe
TorchFCPEUseagefromtorchfcpeimportspawn_bundled_infer_modelimporttorchimportlibrosa# configure device and target hop_sizedevice='cpu'sr=16000hop_size=160# load audioaudio,sr=librosa.load('test.wav',sr=sr)audio=librosa.to_mono(audio)audio_length=len(audio)f0_target_length=(audio_length//hop_size)+1audio=torch.from_numpy(audio).float().unsqueeze(0).unsqueeze(-1).to(device)# load modelmodel=spawn_bundled_infer_model(device=device)# inferf0=model.infer(audio,sr=sr,decoder_mode='local_argmax',threshold=0.006,f0_min=80,f0_max=880,interp_uv=False,output_interp_target_length=f0_target_length,)print(f0)
Package: torch-fftconv
FFT Conv PyTorchThis is a fork of originalfft-conv-pytorch.
I made some modifications to support dilated and strided convolution, so it can be a drop-in-replacement of original PyTorchConv*dmodules andconv*dfunctions, with the same function parameters and behavior.Installpip install git+https://github.com/yoyololicon/fft-conv-pytorchExample Usageimporttorchfromtorch_fftconvimportfft_conv1d,FFTConv1d# Create dummy data.#     Data shape: (batch, channels, length)#     Kernel shape: (out_channels, in_channels, kernel_size)#     Bias shape: (out channels, )# For ordinary 1D convolution, simply set batch=1.signal=torch.randn(3,3,1024*1024)kernel=torch.randn(2,3,128)bias=torch.randn(2)# Functional execution.  (Easiest for generic use cases.)out=fft_conv1d(signal,kernel,bias=bias)# Object-oriented execution.  (Requires some extra work, since the# defined classes were designed for use in neural networks.)fft_conv=FFTConv1d(3,2,128,bias=True)fft_conv.weight=torch.nn.Parameter(kernel)fft_conv.bias=torch.nn.Parameter(bias)out=fft_conv1d(signal)BenchmarksThe best situation to useFFTConvis when using large size kernel. The following image shows that when the size of input is fixed, the fft method remains an almost constant cost among all size of kernel, regardless.For details and benchmarks on other parameters, checkthis notebook.TODOJittability.Dilated Convolution.Transposed Convolution.
Package: torch-fidelity
Evaluation of generative models such as GANs is an important part of the deep learning research.In the domain of 2D image generation, three approaches became widely spread: Inception Score(aka IS), Fréchet Inception Distance (aka FID), and Kernel Inception Distance (aka KID).These metrics, despite having a clear mathematical and algorithmic description, were initiallyimplemented in TensorFlow, and inherited a few properties of the framework itself and the codethey relied upon. These design decisions were effectively baked into the evaluation protocol andbecame an inherent part of the metrics specification. As a result, researchers wishing tocompare against state of the art in generative modeling are forced to perform evaluation usingcodebases of the original metric authors. Reimplementations of metrics in PyTorch and otherframeworks exist, but they do not provide a proper level of fidelity, thus making themunsuitable for reporting results and comparing to other methods.This software aims to provide epsilon-exact implementations of the said metrics in PyTorch, and thusremove inconveniences associated with generative models evaluation and development.Find more details and the most up-to-date information on the project webpage:https://www.github.com/toshas/torch-fidelity
Package: torchfit
TorchFitTorchFitis a bare-bones, minimalistictraining-helperforPyTorchthat exposes an easy-to-usefitmethod in the style offastaiandKeras.TorchFitis intended to be minimally-invasive with a tiny footprint and as little bloat as possible. It is well-suited to those that are new to training models in PyTorch.Usage# normal PyTorch stufftrain_loader=create_your_training_data_loader()val_loader=create_your_validation_data_loader()test_loader=create_your_test_data_loader()model=create_your_pytorch_model()# wrap model and data in Learnerimporttorchfitlearner=torchfit.Learner(model,train_loader,val_loader=val_loader)# estimate LR using Learning Rate Finderlearner.find_lr()# train using 1cycle learning rate policylearner.fit_onecycle(1e-4,3)# plot training vs. validation losslearner.plot('loss')# make predictions as easy as in Kerasy_pred=learner.predict(test_loader)# save model and reload laterlearner.save('/tmp/mymodel')learer.load('/tmp/mymodel')TorchFitTraining LoopTutorials and ExamplesQuickstart with MNIST:quickstart notebook to get you up and runningTutorial Notebook:tutorial notebook using the same model and data employed in thePyTorch text classification tutorialFeaturesLearning Rate Finderlearner.find_lr()Afitmethod for Training# Examples
learner.fit(lr, epochs)
learner.fit_onecycle(lr, epochs)
learner.fit(lr, epochs, schedulers=[scheduler])Easy-to-Execute Testing and Predictions# Examples
outputs = learner.predict(test_loader)
outputs, targets = learner.predict(test_loader, return_targets=True)

text = 'Shares of IBM rose today.'
predicted_label = learner.predict_example(text, preproc_fn=preprocess, labels=labels)Gradient Accumulationlearner.fit_onecycle(lr, 1, accumulation_steps=8)Gradient Clippinglearner.fit_onecycle(lr, 1, gradient_clip_val=1)Mixed Precision Trainingtorchfit.Learner(model, train_loader, val_loader=val_loader, use_amp=True, amp_level='O2')Multi-GPU Training and GPU SelectionTo train on first two GPUs (0 and 1):learner = torchfit.Learner(model, train_loader, val_loader=test_loader, gpus=[0,1])To train only on the second GPU, one can do either this:learner = torchfit.Learner(model, train_loader, val_loader=test_loader, gpus=[1])or this...learner = torchfit.Learner(model, train_loader, val_loader=test_loader, device='cuda:1')Resetting Weights of Modellearner.reset_weights()Saving/Loading Modellearner.save('/tmp/mymodel')
learner.load('/tmp/mymodel')InstallationAfter ensuringPyTorch is installed, installTorchFitwith:pip3 install torchfit
Package: torchfm
Factorization Machine models in PyTorchThis package provides a PyTorch implementation of factorization machine models and common datasets in CTR prediction.Available DatasetsMovieLens DatasetCriteo Display Advertising ChallengeAvazu Click-Through Rate PredictionAvailable ModelsModelReferenceLogistic RegressionFactorization MachineS Rendle, Factorization Machines, 2010.Field-aware Factorization MachineY Juan, et al. Field-aware Factorization Machines for CTR Prediction, 2015.Factorization-Supported Neural NetworkW Zhang, et al. Deep Learning over Multi-field Categorical Data - A Case Study on User Response Prediction, 2016.Wide&DeepHT Cheng, et al. Wide & Deep Learning for Recommender Systems, 2016.Attentional Factorization MachineJ Xiao, et al. Attentional Factorization Machines: Learning the Weight of Feature Interactions via Attention Networks, 2017.Neural Factorization MachineX He and TS Chua, Neural Factorization Machines for Sparse Predictive Analytics, 2017.Neural Collaborative FilteringX He, et al. Neural Collaborative Filtering, 2017.Field-aware Neural Factorization MachineL Zhang, et al. Field-aware Neural Factorization Machine for Click-Through Rate Prediction, 2019.Product Neural NetworkY Qu, et al. Product-based Neural Networks for User Response Prediction, 2016.Deep Cross NetworkR Wang, et al. Deep & Cross Network for Ad Click Predictions, 2017.DeepFMH Guo, et al. DeepFM: A Factorization-Machine based Neural Network for CTR Prediction, 2017.xDeepFMJ Lian, et al. xDeepFM: Combining Explicit and Implicit Feature Interactions for Recommender Systems, 2018.AutoInt (Automatic Feature Interaction Model)W Song, et al. AutoInt: Automatic Feature Interaction Learning via Self-Attentive Neural Networks, 2018.AFN(AdaptiveFactorizationNetwork Model)Cheng W, et al. Adaptive Factorization Network: Learning Adaptive-Order Feature Interactions, AAAI'20.Each model's AUC values are about 0.80 for criteo dataset, and about 0.78 for avazu dataset. (please seeexample code)Installationpip install torchfmAPI Documentationhttps://rixwew.github.io/pytorch-fmLicenceMIT
Package: torchfold
TorchFoldBlog post:http://near.ai/articles/2017-09-06-PyTorch-Dynamic-Batching/Analogous toTensorFlow Fold, implements dynamic batching with super simple interface.
Replace every direct call in your computation to nn module withf.add('function name', arguments).
It will construct an optimized version of computation and onf.applywill dynamically batch and execute the computation on given nn module.InstallationWe recommend using pip package manager:pip install torchfoldExamplef = torchfold.Fold()

    def dfs(node):
        if is_leaf(node):
            return f.add('leaf', node)
        else:
            prev = f.add('init')
            for child in children(node):
                prev = f.add('child', prev, child)
            return prev

    class Model(nn.Module):
        def __init__(self, ...):
            ...

        def leaf(self, leaf):
            ...

        def child(self, prev, child):
            ...

    res = dfs(my_tree)
    model = Model(...)
    f.apply(model, [[res]])
Package: torchfsdd
TorchFSDDA utility for wrapping the Free Spoken Digit Dataset into PyTorch-ready data set splits.AboutTheFree Spoken Digit Datasetis an open data set consisting of audio recordings of various individuals speaking the digits from 0-9, with 50 recordings of each digit per individual.The data set can be thought of as an audio version of the popularMNIST data setwhich consists of hand-written digits. However, the fact that the data consists of recordings of different durations makes it more challenging to deal with than the fixed-size images of MNIST.TorchFSDD aims to provide an interface to FSDD for PyTorch model development, by providing atorch.utils.data.Datasetwrapper that is ready to be used with atorch.utils.data.DataLoader.Build statusmasterdevExamplesfromtorchfsddimportTorchFSDDGenerator,TrimSilencefromtorchaudio.transformsimportMFCCfromtorchvision.transformsimportCompose# Create a transformation pipeline to apply to the recordingstransforms=Compose([TrimSilence(threshold=1e-6),MFCC(sample_rate=8e3,n_mfcc=13)])# Fetch the latest version of FSDD and initialize a generator with those filesfsdd=TorchFSDDGenerator(version='master',transforms=transforms)# Create a Torch dataset for the entire dataset from the generatorfull_set=fsdd.full()# Create two Torch datasets for a train-test split from the generatortrain_set,test_set=fsdd.train_test_split(test_size=0.1)# Create three Torch datasets for a train-validation-test split from the generatortrain_set,val_set,test_set=fsdd.train_val_test_split(test_size=0.15,val_size=0.15)A more complete example can be foundhere, showing how TorchFSDD can be used to train a neural network.InstallationYou can install TorchFSDD usingpip.pip install torchfsddNote: TorchFSDD assumes you have the following packages already installed (along with Python v3.6+).torch(>= 1.8.0)torchaudio(>= 0.8.0)Since there are many different possible configurations when installing PyTorch (e.g. CPU or GPU, CUDA version), we leave this up to the user instead of specifying particular versions to install alongside TorchFSDD.Make sure you havetorchandtorchaudioversions that arecompatible!If youreallywish to installtorchandtorchaudiotogether with TorchFSDD automatically, the following will install CPU-only versions of both dependencies.pip install torchfsdd[torch]DevelopmentPlease see thecontribution guidelinesto see installation instructions for contributing to this repository.DocumentationDocumentation for the package is available onRead The Docs.ContributorsAll contributions to this repository are greatly appreciated. Contribution guidelines can be foundhere.eonublack-puppydogTorchFSDD© 2021-2023, Edwin Onuonga - Released under theMITLicense.Authored and maintained by Edwin Onuonga.
Package: torchfuel
torchfuelBuild on top of pytorch to fuel productivity.FeaturesGeneric TrainerClassification Trainer (with cross-entropy loss)MSE TrainerAdditional utility layersBetter dataloaders (currently only for image datasets)Classification Exampleimportosimporttimefromcollectionsimportnamedtupleimporttorchimporttorch.nnasnnimporttorch.optimasoptimfromtorch.optimimportlr_schedulerfromtorchvisionimportdatasets,models,transformsfromtorchfuel.data_loaders.imageimportImageDataLoaderfromtorchfuel.trainers.classificationimportClassificationTrainerfromtorchfuel.transforms.noiseimportDropPixelNoiserdl=ImageDataLoader(train_data_folder='imgs/train',eval_data_folder='imgs/eval',pil_transformations=[transforms.RandomHorizontalFlip()]tensor_transformations=[DropPixelNoiser()],batch_size=64,imagenet_format=True,)train_dataloader,eval_dataloader,n_classes=dl.prepare()device=torch.device('cuda:0'iftorch.cuda.is_available()else'cpu')model=Model(...).to(device)optimiser=optim.SGD(model.parameters(),lr=0.01,momentum=0.9)scheduler=optim.lr_scheduler.ReduceLROnPlateau(optimiser,'min',patience=20)trainer=ClassificationTrainer(device,model,optimiser,scheduler)fitted_model=trainer.fit(epochs,train_dataloader,eval_dataloader)How to installClone repository and run:pipinstall.Optionally (not up to date):pipinstalltorchfuel
Package: torchFunctions
torchFunctions - eleka12A small package for pytorch functionsHow to use -install the latest packagein jupyter notebook -!pip install torchFunctionsin command prompt -pipinstalltorchFunctionsNow run below snippets of code in your jupyter-notebooks / python project to use pytorch defined functionsdefault use case -fromtorchFunctions.parametersimportparametersmodel="your model"parameters().count_params(model)pypi repo link -torchFunctions
Package: torchgan
TorchGANFramework for easy and efficient training of GANs based on PytorchTorchGAN is aPytorchbased framework for designing and developing Generative Adversarial Networks. This framework has been designed to provide building blocks for popular GANs and also to allow customization for cutting edge research. Using TorchGAN's modular structure allowsTrying out popular GAN models on your dataset.Plug in your new Loss Function, new Architecture, etc. with the traditional ones.Seamlessly visualize the training with a variety of logging backends.System / PyTorch Version1.81.9nightlyLinux py3.8Linux py3.9OSX py3.8OSX py3.9Windows py3.9Windows py3.9InstallationUsing pip (for stable release):$pipinstalltorchganUsing pip (for latest master):$pipinstallgit+https://github.com/torchgan/torchgan.gitFrom source:$gitclonehttps://github.com/torchgan/torchgan.git$cdtorchgan$pythonsetup.pyinstallDocumentationThe documentation is availablehereThe documentation for this package can be generated locally.$gitclonehttps://github.com/torchgan/torchgan.git$cdtorchgan/docs$pipinstall-rrequirements.txt$makehtmlNow open the corresponding file frombuilddirectory.TutorialsThetutorialsdirectory contain a set of tutorials to get you started with torchgan. These tutorials can be run using Google Colab or Binder. It is highly recommended that you follow the tutorials in the following order.Introductory Tutorials:Tutorial 1: Introduction to TorchGANTutorial 2: Custom Loss FunctionsIntermediate Tutorials:Tutorial 3: CycleGANTutorial 4: Self Attention GANAdvanced Tutorials:Tutorial 5: Adversarial AutoencoderSupporting and CitingThis software was developed as part of academic research. If you would like to help support it, please star the repository. If you use this software as part of your research, teaching, or other activities, we would be grateful if you could cite the following:@misc{pal2019torchgan,
    title={{TorchGAN: A Flexible Framework for GAN Training and Evaluation}},
    author={Avik Pal, and Aniket Das},
    year={2019},
    eprint={1909.03410},
    archivePrefix={arXiv},
    primaryClass={cs.LG}
}List of publications & submissions using TorchGAN (please open a pull request to add missing entries):Can GAN-Generated Network Traffic be used to Train Traffic Anomaly Classifiers?Ward2ICU: A Vital Signs Dataset of Inpatients from the General WardContributingWe appreciate all contributions. If you are planning to contribute 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. For more detailed guidelines head over to the official documentation.ContributorsThis package has been developed byAvik Pal (@avik-pal)Aniket Das (@Aniket1998)This project exists thanks to all the people who contribute.