Saravanan666/pypi-org huggingface dataset:
Package: pytorch-crf
pytorch-crfConditional random field inPyTorch.This package provides an implementation ofconditional random field(CRF) in PyTorch.
This implementation borrows mostly fromAllenNLP CRF modulewith some modifications.Documentationhttps://pytorch-crf.readthedocs.io/LicenseMITContributingContributions are welcome! Please follow these instructions to install
dependencies and running the tests and linter.Installing dependenciesMake sure you setup a virtual environment with Python and PyTorch
installed. Then, install all the dependencies inrequirements.txtfile and
install this package in development mode.pip install -r requirements.txt
pip install -e .Setup pre-commit hookSimply run:ln -s ../../pre-commit.sh .git/hooks/pre-commitRunning testsRunpytestin the project root directory.Running linterRunflake8in the project root directory. This will also runmypy,
thanks toflake8-mypypackage.
Package: pytorch-dataset
Pytorch-DatasetA PyTorch Code Dataset for Cutting-Edge Fine-tuningInstallationYou can install the package using pippipinstallpytorch-datasetUsageDownloader that downloads and unzips each repository in an accountfrompytorchimportGitHubRepoDownloaderdownloader=GitHubRepoDownloader(username="lucidrains",download_dir="lucidrains_repositories")downloader.download_repositories()Processor that cleans, formats, and submits the cleaned dataset to huggingfacefrompytorchimportCodeDatasetBuildercode_builder=CodeDatasetBuilder("lucidrains_repositories")code_builder.save_dataset("lucidrains_python_code_dataset")code_builder.push_to_hub("lucidrains_python_code_dataset",organization="kye")LicenseMIT
Package: pytorch-datastream
This is a simple library for creating readable dataset pipelines and
reusing best practices for issues such as imbalanced datasets. There are
just two components to keep track of:DatasetandDatastream.Datasetis a simple mapping between an index and an example. It provides
pipelining of functions in a readable syntax originally adapted from
tensorflow 2’stf.data.Dataset.Datastreamcombines aDatasetand a sampler into a stream of examples.
It provides a simple solution to oversampling / stratification, weighted
sampling, and finally converting to atorch.utils.data.DataLoader.Installpoetry add pytorch-datastreamOr, for the old-timers:pip install pytorch-datastreamUsageThe list below is meant to showcase functions that are useful in most standard
and non-standard cases. It is not meant to be an exhaustive list. See thedocumentationfor
a more extensive list on API and usage.Dataset.from_subscriptableDataset.from_dataframeDataset.map.subset.split.cache.with_columnsDatastream.mergeDatastream.zipDatastream.map.data_loader.zip_index.update_weights_.update_example_weight_.weight.state_dict.load_state_dictMerge / stratify / oversample datastreamsThe fruit datastreams given below repeatedly yields the string of its fruit
type.>>>datastream=Datastream.merge([...(apple_datastream,2),...(pear_datastream,1),...(banana_datastream,1),...])>>>next(iter(datastream.data_loader(batch_size=8)))['apple','apple','pear','banana','apple','apple','pear','banana']Zip independently sampled datastreamsThe fruit datastreams given below repeatedly yields the string of its fruit
type.>>>datastream=Datastream.zip([...apple_datastream,...Datastream.merge([pear_datastream,banana_datastream]),...])>>>next(iter(datastream.data_loader(batch_size=4)))[('apple','pear'),('apple','banana'),('apple','pear'),('apple','banana')]More usage examplesSee thedocumentationfor more usage examples.Install from source
Package: pytorch-disentanglement-datasets
Disentanglement DatasetsA lightweight package oftorchvision-style PyTorch datasets with a focus on flexibility.Installation$ pip install pytorch-disentanglement-datasetsUsageEach dataset returns a dictionary containing at least aninputkey:>>>fromdisentanglement_datasetsimportDSprites>>>dataset=DSprites(root="./data",download=True)>>>dataset[0]{'input':tensor([[0,0,0,...,0,0,0],[0,0,0,...,0,0,0],[0,0,0,...,0,0,0],...,[0,0,0,...,0,0,0],[0,0,0,...,0,0,0],[0,0,0,...,0,0,0]],dtype=torch.uint8),'latent':tensor([1.0000,1.0000,0.5000,0.0000,0.0000,0.0000],dtype=torch.float64)}This dictionary can be transformed. For example, for self-supervised learning with augmentations you might do something like:>>>defmy_transform(item):...view1=my_random_augmentation(item["input"])...view2=my_random_augmentation(item["input"])...returnview1,view2...>>>dataset=DSprites(root="./data",download=True,transform=my_transform)>>>dataset[0](tensor([[0,0,0,...,0,0,0],[0,0,0,...,0,0,0],[0,0,0,...,0,0,0],...,[0,0,0,...,0,0,0],[0,0,0,...,0,0,0],[0,0,0,...,0,0,0]],dtype=torch.uint8),tensor([[0,0,0,...,0,0,0],[0,0,0,...,0,0,0],[0,0,0,...,0,0,0],...,[0,0,0,...,0,0,0],[0,0,0,...,0,0,0],[0,0,0,...,0,0,0]],dtype=torch.uint8))Datasets and their original sourcesDSpritesMPI3D-ToyAttributionIf this code was useful to you, please cite the original dataset (links above) and this codebase.BibTeXTODODevelopmentPull requests are welcome.See alsodisentanglement-pytorch: Variational autoencoder models for disentanglement, created as a contribution to theDisentanglement Challenge of NeurIPS 2019, along with more datasets with a different interface.disentanglement_lib: VAE models, metrics, and data for disentanglement, implemented in TensorFlow, created as a contribution to theDisentanglement Challenge of NeurIPS 2019.
Package: pytorch-distbelief
distbeliefImplementing Google's DistBelief paper.Installation/Development instructionsYou'll want to create a python3 virtualenv first by runningmake setup, after which, you should runmake install.You'll then be able to use distbelief by importing distbelieffromdistbelief.optimimportDownpourSGDoptimizer=DownpourSGD(net.parameters(),lr=0.1,n_push=5,n_pull=5,model=net)As an example, you can see our implementation running by using the script provided inexample/main.py.To run a 2-training node setup locally, open up three terminal windows, source thevenvand then runmake first,make second, andmake server.
This will begin training AlexNet on CIFAR10 locally with all default params.BenchmarkingNOTE:we graph the train/test accuracy of each node, hence node1, node2, node3. A better comparison would be to evaluate the parameter server's params and use that value.
However we can see that the accuracy between the three nodes is fairly consistent, and adding an evaluator might put too much stress on our server.We scale the learning rate of the nodes to be learning_rate/freq (.03) .We used AWS c4.xlarge instances to compare the CPU runs, and a GTX 1060 for the GPU run.DownpourSGD for PyTorchDiagramHere2and3happen concurrently.You can read more about our implementationhere.ReferencesPytorch distributed tutorialAkka implementation of distbeliefgevent actor tutorialDistBelief paperAnalysis of delayed grad problem
Package: pytorch-dni
# Decoupled Neural Interfaces Using Synthetic Gradients[![Build Status](https://travis-ci.org/ixaxaar/pytorch-dni.svg?branch=master)](https://travis-ci.org/ixaxaar/pytorch-dni) [![PyPI version](https://badge.fury.io/py/dni.svg)](https://badge.fury.io/py/pytorch-dni)<!-- START doctoc generated TOC please keep comment here to allow auto update --><!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->- [Install](#install)- [From source](#from-source)- [Architecure](#architecure)- [Usage](#usage)- [Tasks](#tasks)<!-- END doctoc generated TOC please keep comment here to allow auto update -->This is an implementation of [Decoupled Neural Interfaces using Synthetic Gradients, Jaderberg et al.](https://arxiv.org/abs/1608.05343).## Install```bashpip install pytorch-dni```### From source```git clone https://github.com/ixaxaar/pytorch-dnicd pytorch-dnipip install -r ./requirements.txtpip install -e .```## Architecure<img src="./docs/3-6.gif" />## Usage```pythonfrom dni import DNI# Custom network, can be anything extending nn.Modulenet = WhateverNetwork(**kwargs)opt = optim.Adam(net.parameters(), lr=0.001)# use DNI to optimize this networknet = DNI(net, optim=opt)# after that we go about our business as usualfor e in range(epoch):opt.zero_grad()output = net(input, *args)loss = criterion(output, target_output)loss.backward()opt.step()...```## DNI NetworksThis package ships with 3 types of DNI networks:- RNN_DNI: stacked `LSTM`s, `GRU`s or `RNN`s- Linear_DNI: 2-layer `Linear` modules- Linear_Sigmoid_DNI: 2-layer `Linear` followed by `Sigmoid`## Custom DNI NetworksCustom DNI nets can be created using the `DNI_Network` interface:```pythonclass MyDNI(DNI_Network):def __init__(self, input_size, hidden_size, output_size, **kwargs):super(MyDNI, self).__init__(input_size, hidden_size, output_size)self.net = { ... your custom net }...def forward(self, input, hidden):return self.net(input), None # return (output, hidden), hidden can be None```## TasksThe tasks included in this project are the same as those in [pytorch-dnc](https://github.com/ixaxaar/pytorch-dnc#tasks), except that they're trained here using DNI.## Notable stuff- Using a linear SG module makes the implicit assumption that loss is a quadratic function of the activations- For best performance one should adapt the SG module architecture to the loss function used. For MSE linear SG is a reasonable choice, however for log loss one should use architectures including a sigmoid applied pointwise to a linear SG
Package: pytorch-dp
pytorch-dp: Train PyTorch models with Differential Privacypytorch-dp is a library that enables training PyTorch models with differential privacy. It supports training with minimal code changes required on the client, has little impact on training performance and allows the client to online track the privacy budget expended at any given moment.PyTorch Privacy is currently a preview beta and under active development!Target audienceThis code release is aimed at two target audiences:ML practicioners will find this code a gentle introduction to training a model with differential privacy as it requires minimal code changes.Differential Privacy scientists will find this code easy to experiment and tinker with, allowing them to focus on what matters.Installationpip:pipinstallpytorch-dpFrom source:gitclonehttps://github.com/facebookresearch/pytorch-dp.gitcdpytorch-dp
pipinstall-e.Getting startedTo train your model with differential privacy, all you need to do is to declare a PrivacyEngine and attach it to your optimizer before running, eg:model=Net()optimizer=SGD(model.parameters(),lr=0.05)privacy_engine=PrivacyEngine(model,batch_size,sample_size,alphas=[1,10,100],noise_multiplier=1.3,max_grad_norm=1.0,)privacy_engine.attach(optimizer)# Now it's business as usualTheMNIST examplecontains an end to end run.ContributingSee theCONTRIBUTINGfile for how to help out.ReferencesMironov, Ilya. "Rényi differential privacy." 2017 IEEE 30th Computer Security Foundations Symposium (CSF). IEEE, 2017.Abadi, Martin, et al. "Deep learning with differential privacy." Proceedings of the 2016 ACM SIGSAC Conference on Computer and Communications Security. ACM, 2016.Mironov, Ilya, Kunal Talwar, and Li Zhang. "R'enyi Differential Privacy of the Sampled Gaussian Mechanism." arXiv preprint arXiv:1908.10530 (2019).Goodfellow, Ian. "Efficient per-example gradient computations." arXiv preprint arXiv:1510.01799 (2015).McMahan, H. Brendan, and Galen Andrew. "A general approach to adding differential privacy to iterative training procedures." arXiv preprint arXiv:1812.06210 (2018).LicenseThis code is released under Apache 2.0, as found in theLICENSEfile.
Package: pytorch-eo
Pytorch EODeep Learning for Earth Observation applications and research.Installationpip install pytorch-eoExamplesLearn by doing with ourexamples.EuroSAT.UCMercedLand Use Dataset.BigEarthNet.SEN12FLOODs.TutorialsLearn how to build with Pytorch EO with ourtutorials.Learn aboutdata loadingis Pytorch EO.Learn aboutdata augmentationis Pytorch EO.Learn how tocreate datasetswith Pytorch EO.Learn about training models with ourtasks.ChallengesPytorchEO has been used in the following challenges:EUROAVIAMission: European Students Space Hackathon, 2021.On Cloud N: Cloud Cover Detection Challenge (DrivenData, 2021).ContributingRead theCONTRIBUTINGguide.
Package: pytorch-fanatics
Pytorch_FanaticsPytorch_Fanatics is a Python library for ease of Computer Vision tasks.This contains a bunch of various tools which will help to create customized codes to train CV models.###This library includes:Dataset classLRFinderEarlyStoppingTrainerLoggerInstallationUse the package managerpipto install pytorch_fanatics.pipinstallpytorch_fanaticsUsage1)Dataset Classfrompytorch_fanatics.dataloaderimportCloaderCloader(image_path,targets,resize,transforms)# returns {'image':tensor_image,'target':tensor_labels}#Use it to load images and labels2)LRFinderfrompytorch_fanatics.utilsimportLRFinderlr_finder=LRFinder(model,train_dataloader,optimizer,device,initial_lr,final_lr,beta)#Create a objectlr_finder.find()#To find the lrlr_finder.plot()#To plot the graph (Loss V/S lr)#NOTE:#Use this only after training the model with all layers (except the last) freezed.3)EarlyStoppingfrompytorch_fanatics.utilsimportEarlyStopes=EarlyStop(patience=7,mode="max",delta=0.0001)#Create a objectes(epoch_score,model,path)ifes.early_stop=True:breakes.reset()# to reset4)Trainerfrompytorch_fanatics.trainerimportTrainerTrainer.train(model,data_loader,optimizer,device)# trains the modelscore=Trainer.evaluate(model,data_loader,device,scheduler=None,metric=metrics.accuracy_score,plot=True)#Use the score to feed for earlystop if used#plot=True specifies live plot b/w (training and validation) vs num_epochsTrainer.predict(model,data_loader,device)# returns probability of classesTrainer.get_log()#returns a DataFrame object of logs#Currently the metrics supported are f1_score,accuracy,precision,recall,roc_auc_score and log_loss#We are working on other too ..5)Loggerfrompytorch_fanatics.loggerimportLoggerLogger.save(model,optimizer,scheduler,path)# saves model,optimizer and schedulers#To load:checkpoint=Logger.load(path)#returns a dictionarymodel,optimizer,scheduler=checkpoint['model'],checkpoint['optimizer'],checkpoint['scheduler']#Helps keep track of training.It will restart from where it had stopped.NOTE(Regarding model)classResnet18(nn.Module):def__init__(self):super(Resnet18,self).__init__()self.base_model=timm.create_model('resnet18',pretrained=True,num_classes=1)defforward(self,image,targets):batch_size,_,_,_=image.shapeout=self.base_model(image)loss=nn.BCEWithLogitsLoss()(out.view(batch_size,),targets.type_as(out))returnout,loss#Since every loss function has its own format of inputs,To generalise I have created this model.Use this model(edit if required) if you are #using Trainer/LRFinder.For others your simple model will also work fine..ContributingPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.Please make sure to update tests as appropriate.LicenseMITReferencesFastAi Documentations for LRFinder.Pytorch Documentations.Abhishek Thakur Sir's Github Project wtfml(Awesome work Have a look at it too).
Package: pytorch-fast-elmo
pytorch-fast-elmoIntroductionA fast ELMo implementation with features:Lower execution overhead.The core components are reimplemented in Libtorch in order to reduce the Python execution overhead (45%speedup).A more flexible design.By redesigning the workflow, the user could extend or change the ELMo behavior easily.BenchmarkHardware:CPU: i7-7800XGPU: 1080TiOptions:Batch size: 32Warm up iterations: 20Test iterations: 1000Word length: [1, 20]Sentence length: [1, 30]Random seed: 10000ItemMean Of Durations (ms)cumtime(synchronize)%Fast ELMo (CUDA, no synchronize)31N/AAllenNLP ELMo (CUDA, no synchronize)56N/AFast ELMo (CUDA, synchronize)4726.13%AllenNLP ELMo (CUDA, synchronize)570.02%Fast ELMo (CPU)1277N/AAllenNLP ELMo (CPU)1453N/AUsagePlease installtorch==1.0.0first. Then, simply run this command to install.pipinstallpytorch-fast-elmoFastElmoshould have the same behavior as AllenNLP’sELMo.frompytorch_fast_elmoimportFastElmo,batch_to_char_idsoptions_file='/path/to/elmo_2x4096_512_2048cnn_2xhighway_options.json'weight_file='/path/to/elmo_2x4096_512_2048cnn_2xhighway_weights.hdf5'elmo=FastElmo(options_file,weight_file)sentences=[['First','sentence','.'],['Another','.']]character_ids=batch_to_ids(sentences)embeddings=elmo(character_ids)UseFastElmoWordEmbeddingif you have disabledchar_cnninbilm-tf, or have exported the Char CNN representation to a weight file.frompytorch_fast_elmoimportFastElmoWordEmbedding,load_and_build_vocab2id,batch_to_word_idsoptions_file='/path/to/elmo_2x4096_512_2048cnn_2xhighway_options.json'weight_file='/path/to/elmo_2x4096_512_2048cnn_2xhighway_weights.hdf5'vocab_file='/path/to/vocab.txt'embedding_file='/path/to/cached_elmo_embedding.hdf5'elmo=FastElmoWordEmbedding(options_file,weight_file,# Could be omitted if the embedding weight is in `weight_file`.word_embedding_weight_file=embedding_file,)vocab2id=load_and_build_vocab2id(vocab_file)sentences=[['First','sentence','.'],['Another','.']]word_ids=batch_to_word_ids(sentences,vocab2id)embeddings=elmo(word_ids)CLI commands:# Cache the Char CNN representation.fast-elmocache-char-cnn./vocab.txt./options.json./lm_weights.hdf5./lm_embd.hdf5# Export word embedding.fast-elmoexport-word-embd./vocab.txt./no-char-cnn.hdf5./embd.txtCreditsThis package was created withCookiecutterand theaudreyr/cookiecutter-pypackageproject template.History0.1.0 (2019-01-02)First release on PyPI.
Package: pytorch-fasterrcnn
Pytorch Faster RCNNFaster RCNN Fine-Tune Implementation in Pytorch.How to use ?git clone the repogit clone https://github.com/oke-aditya/pytorch_fasterrcnn.gitInstall PyTorch and torchvision for your system.Simply edit the config file to set your hyper parameters.Keep the training and validation csv file as followsNOTEDo not use target as 0 class. It is reserved as background.image_id xtl ytl xbr ybr      target
1        xmin ymin xmax ymax   1
1        xmin ymin xmax ymax   2
2		 xmin ymin xmax ymax   3Simply edit the config file to set your hyper parametersRun the train.py fileFeatures: -It works for multiple class object detection.Backbones Supported: -Note that backbones are pretrained on imagenet.Following backbones are supportedvgg11, vgg13, vgg16, vgg19resnet18, resnet34, resnet50, resnet101, resnet152renext101mobilenet_v2Sample OutputsHelmet DetectorMask DetectorIf you like the implemenation or have taken an inspiration do give a star :-)
Package: pytorch-fcd
FCD_ScoreFréchet CLIP Distance Score: Fréchet CLIP Distance Score calculate Fréchet Distance based on features from CLIP image encoder.FCD measure similarity between generated images and the dataset.InstallationInstall from pip:pip install pytorch-fcdRequirements:ftfyregexnumpypillowscipytorch>=1.7.1torchvision>=0.8.2clipUsagecalculate and save statistics for datasest:pytorch-fcd --model-name "ViT-B/32" --savepath path_to_image_dataset path_to_save_filecalculate FCD score for image dataset and generated image dataset:pytorch-fcd --model-name "ViT-B/32" --paths path_to_image_dataset path_to_generated_image_datasetCitingIf you use this repository in your research, consider citing it using the following Bibtex entry:@misc{ShanYang2023FCD,author={Shan Yang},title={{pytorch-fcd: FCD Score for PyTorch}},month={Nov},year={2023},note={Version 1.0.0.dev1},howpublished={\url{https://github.com/syang-lab/FCD_Score}}}LicenseThis implementation is licensed under the Apache License 2.0.
Package: pytorchfi
PyTorchFIBackground•Usage•Code•Contributors•Citation•LicenseBackgroundPyTorchFI is a runtime perturbation tool for deep neural networks (DNNs), implemented for the popular PyTorch deep learning platform. PyTorchFI enables users to perform perturbation on weights or neurons of a DNN during runtime. It is extremely versatile for dependability and reliability research, with applications including resiliency analysis of classification networks, resiliency analysis of object detection networks, analysis of models robust to adversarial attacks, training resilient models, and for DNN interpertability.An example of a use case for PyTorchFI is to simulate an error by performaing a fault-injection on an object recognition model.Golden OutputOutput with Fault InjectionUsageDownload on PyPIhere, or take a look at our documentation atpytorchfi.dev.You can also learn more with ourinteractive demo.InstallingFrom PipInstall usingpip install pytorchfiFrom SourceDownload this repository into your project folder.ImportingImport the entire package:importpytorchfiImport a specific module:frompytorchfiimportcoreTestingpytestCodeStructureThe main source code of PyTorchFI is held inpytorchfi, which carries bothcoreanderror_models.pyimplementations.FormattingAll python code is formatted withblack.ContributorsBefore contributing, please refer to ourcontributing guidelines.Sarita V. Adve(UIUC)Neeraj Aggarwal(UIUC)Christopher W. Fletcher(UIUC)Siva Kumar Sastry Hari(NVIDIA)Abdulrahman Mahmoud(UIUC)Alex Nobbe(UIUC)Jose Rodrigo Sanchez Vicarte(UIUC)CitationView thepublished paper. If you use or reference PyTorchFI, please cite:@INPROCEEDINGS{PytorchFIMahmoudAggarwalDSML20,
author={A. {Mahmoud} and N. {Aggarwal} and A. {Nobbe} and J. R. S. {Vicarte} and S. V. {Adve} and C. W. {Fletcher} and I. {Frosio} and S. K. S. {Hari}},
booktitle={2020 50th Annual IEEE/IFIP International Conference on Dependable Systems and Networks Workshops (DSN-W)},
title={PyTorchFI: A Runtime Perturbation Tool for DNNs},
year={2020},
pages={25-31},
}Funding SourcesThis project was funded in part by theApplications Driving Architectures (ADA) Research Center, a JUMP Center co-sponsored by SRC and DARPA, and in collaboration with NVIDIA Research.LicenseNCSALicense. Copyright © 2021RSim Research Group.