repo
stringlengths
1
99
file
stringlengths
13
215
code
stringlengths
12
59.2M
file_length
int64
12
59.2M
avg_line_length
float64
3.82
1.48M
max_line_length
int64
12
2.51M
extension_type
stringclasses
1 value
byteps
byteps-master/example/mxnet/common/modelzoo.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
4,181
64.34375
123
py
byteps
byteps-master/example/mxnet/common/data_byteps.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
8,020
45.906433
110
py
byteps
byteps-master/example/keras/keras_mnist_advanced.py
from __future__ import print_function from tensorflow import keras from tensorflow.keras.datasets import mnist from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense, Dropout, Flatten from tensorflow.keras.layers import Conv2D, MaxPooling2D from tensorflow.keras.preprocessing.image imp...
5,054
38.80315
90
py
byteps
byteps-master/example/keras/keras_mnist.py
from __future__ import absolute_import, division, print_function import keras from keras.datasets import mnist from keras.models import Sequential from keras.layers import Dense, Dropout, Flatten from keras.layers import Conv2D, MaxPooling2D from keras import backend as K import math import tensorflow as tf import byte...
3,266
33.03125
90
py
byteps
byteps-master/example/keras/keras_synthetic_benchmark_tf2.py
from __future__ import absolute_import, division, print_function import argparse import os import numpy as np import timeit import tensorflow as tf import byteps.tensorflow.keras as bps from tensorflow.keras import applications tf.compat.v1.disable_eager_execution() # Benchmark settings parser = argparse.ArgumentPa...
2,891
38.616438
89
py
byteps
byteps-master/example/keras/keras_imagenet_resnet50.py
# Copyright 2019 Bytedance Inc. or its affiliates. All Rights Reserved. # Copyright 2017 Uber Technologies, Inc. All Rights Reserved. # # ResNet-50 model training using Keras and BytePS. # # This model is an example of a computation-intensive model that achieves good accuracy on an image # classification task. It brin...
8,697
46.791209
108
py
byteps
byteps-master/example/pytorch/train_imagenet_resnet50_byteps.py
from __future__ import print_function import torch import argparse import torch.backends.cudnn as cudnn import torch.nn.functional as F import torch.optim as optim import torch.utils.data.distributed from torchvision import datasets, transforms, models import byteps.torch as bps import tensorboardX import os import ma...
10,935
38.623188
90
py
byteps
byteps-master/example/pytorch/benchmark_byteps.py
from __future__ import print_function import argparse import torch.backends.cudnn as cudnn import torch.nn.functional as F import torch.optim as optim import torch.utils.data.distributed from torchvision import models import byteps.torch as bps import timeit import numpy as np import os, sys # Benchmark settings pars...
4,331
31.818182
89
py
byteps
byteps-master/example/pytorch/train_imagenet_resnet_byteps_ddp.py
# this example is adapted from the official PyTorch example: https://github.com/pytorch/examples/blob/69d2798ec7fb4f87b320a1848203da5346675b95/imagenet/main.py # example usage: # # bpslaunch python train_imagenet_resnet_byteps_ddp.py -a resnet18 --dist-url 'tcp://127.0.0.1:12345' --dist-backend 'nccl' --multiprocessin...
16,533
37.630841
211
py
byteps
byteps-master/example/pytorch/elastic_benchmark_byteps.py
from __future__ import print_function import argparse import torch.backends.cudnn as cudnn import torch.nn.functional as F import torch.optim as optim import torch.utils.data.distributed from torchvision import models import byteps.torch as bps import timeit import numpy as np import os, sys # Benchmark settings pars...
4,621
31.549296
89
py
byteps
byteps-master/example/pytorch/train_mnist_byteps.py
from __future__ import print_function import argparse import os import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from torchvision import datasets, transforms import torch.utils.data.distributed import byteps.torch as bps # Training settings parser = argparse.ArgumentParser(description=...
6,526
37.169591
88
py
byteps
byteps-master/example/pytorch/mnist-distributed.py
import os from datetime import datetime import argparse import torch.multiprocessing as mp import torchvision import torchvision.transforms as transforms import torch import torch.nn as nn import torch.distributed as dist from torch.nn.parallel import DistributedDataParallel as DDP def main(): parser = argparse.A...
3,788
32.236842
115
py
byteps
byteps-master/example/pytorch/benchmark_cross_barrier_byteps.py
from __future__ import print_function import argparse import torch.backends.cudnn as cudnn import torch.nn.functional as F import torch.optim as optim import torch.utils.data.distributed from torchvision import models import timeit import numpy as np import os import byteps.torch.cross_barrier as bps """ This example...
5,860
35.403727
119
py
byteps
byteps-master/example/pytorch/benchmark_byteps_ddp.py
from __future__ import print_function import argparse import torch.backends.cudnn as cudnn import torch.nn.functional as F import torch.optim as optim import torch.utils.data.distributed from torchvision import models import byteps.torch as bps import timeit import numpy as np import os, sys from byteps.torch.parallel...
4,433
32.089552
89
py
byteps
byteps-master/example/tensorflow/tensorflow2_keras_mnist.py
# Copyright 2020 Uber Technologies, Inc. All Rights Reserved. # Copyright 2019 Uber Technologies, Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www....
3,929
40.368421
108
py
byteps
byteps-master/example/tensorflow/synthetic_benchmark.py
from __future__ import absolute_import, division, print_function import argparse import os, sys import numpy as np import timeit import byteps.tensorflow as bps from tensorflow.keras import applications import tensorflow as tf # Benchmark settings parser = argparse.ArgumentParser(description='TensorFlow Synthetic B...
4,178
33.254098
104
py
byteps
byteps-master/example/tensorflow/tensorflow_keras_mnist.py
from __future__ import absolute_import, division, print_function from tensorflow import keras from tensorflow.keras.datasets import mnist from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense, Dropout, Flatten from tensorflow.keras.layers import Conv2D, MaxPooling2D from tensorflow.ke...
3,311
33.5
90
py
byteps
byteps-master/example/tensorflow/tensorflow2_mnist.py
import tensorflow as tf import byteps.tensorflow as bps bps.init() # BytePS: pin GPU to be used to process local rank (one GPU per process) gpus = tf.config.experimental.list_physical_devices('GPU') for gpu in gpus: tf.config.experimental.set_memory_growth(gpu, True) if gpus: tf.config.experimental.set_visibl...
2,391
33.666667
86
py
byteps
byteps-master/example/tensorflow/tensorflow2_mnist_bps_MirroredStrategy.py
import tensorflow as tf import numpy as np import json import os import sys import argparse import byteps.tensorflow as bps from byteps.tensorflow.distribute import MirroredStrategy parser = argparse.ArgumentParser(description='TensorFlow Synthetic Benchmark', formatter_class=argparse...
2,699
35
88
py
byteps
byteps-master/example/tensorflow/tensorflow_mnist.py
#!/usr/bin/env python # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, softwar...
6,554
39.96875
84
py
byteps
byteps-master/example/tensorflow/synthetic_benchmark_tf2.py
from __future__ import absolute_import, division, print_function import argparse import os import numpy as np import timeit import tensorflow as tf import byteps.tensorflow as bps from tensorflow.keras import applications # Benchmark settings parser = argparse.ArgumentParser(description='TensorFlow Synthetic Benchma...
4,311
35.542373
89
py
MnTTS
MnTTS-main/examples/tacotron2/train_tacotron2.py
# -*- coding: utf-8 -*- # Copyright 2020 Minh Nguyen (@dathudeptrai) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ...
18,412
33.807183
96
py
MnTTS
MnTTS-main/examples/fastspeech/train_fastspeech.py
# -*- coding: utf-8 -*- # Copyright 2020 Minh Nguyen (@dathudeptrai) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ...
13,591
33.762148
95
py
MnTTS
MnTTS-main/examples/fastspeech2/train_fastspeech2.py
# -*- coding: utf-8 -*- # Copyright 2020 Minh Nguyen (@dathudeptrai) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ...
14,458
33.590909
96
py
MnTTS
MnTTS-main/examples/hifigan/train_hifigan.py
# -*- coding: utf-8 -*- # Copyright 2020 TensorFlowTTS Team # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
10,464
31.101227
88
py
MnTTS
MnTTS-main/tensorflow_tts/models/base_model.py
# -*- coding: utf-8 -*- # Copyright 2020 TensorFlowTTS Team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
1,131
32.294118
74
py
MnTTS
MnTTS-main/tensorflow_tts/models/parallel_wavegan.py
# -*- coding: utf-8 -*- # Copyright 2020 The TensorFlowTTS Team and Tomoki Hayashi (@kan-bayashi) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENS...
18,663
32.508079
112
py
MnTTS
MnTTS-main/tensorflow_tts/models/melgan.py
# -*- coding: utf-8 -*- # Copyright 2020 The MelGAN Authors and Minh Nguyen (@dathudeptrai) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 ...
17,807
34.687375
106
py
MnTTS
MnTTS-main/tensorflow_tts/models/tacotron2.py
# -*- coding: utf-8 -*- # Copyright 2020 The Tacotron-2 Authors, Minh Nguyen (@dathudeptrai), Eren Gölge (@erogol) and Jae Yoo (@jaeyoo) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # ...
37,180
34.716619
112
py
MnTTS
MnTTS-main/tensorflow_tts/models/mb_melgan.py
# -*- coding: utf-8 -*- # Copyright 2020 The Multi-band MelGAN Authors , Minh Nguyen (@dathudeptrai) and Tomoki Hayashi (@kan-bayashi) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # ...
6,890
34.704663
110
py
MnTTS
MnTTS-main/tensorflow_tts/models/hifigan.py
# -*- coding: utf-8 -*- # Copyright 2020 The Hifigan Authors and TensorflowTTS Team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unl...
13,272
33.928947
91
py
MnTTS
MnTTS-main/tensorflow_tts/models/fastspeech2.py
# -*- coding: utf-8 -*- # Copyright 2020 The FastSpeech2 Authors and Minh Nguyen (@dathudeptrai) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE...
12,399
38.616613
100
py
MnTTS
MnTTS-main/tensorflow_tts/models/fastspeech.py
# -*- coding: utf-8 -*- # Copyright 2020 The FastSpeech Authors, The HuggingFace Inc. team and Minh Nguyen (@dathudeptrai) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.a...
33,971
36.372937
102
py
MnTTS
MnTTS-main/tensorflow_tts/optimizers/adamweightdecay.py
# -*- coding: utf-8 -*- # Copyright 2019 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Un...
6,854
37.511236
88
py
MnTTS
MnTTS-main/tensorflow_tts/utils/utils.py
# -*- coding: utf-8 -*- # Copyright 2019 Tomoki Hayashi # MIT License (https://opensource.org/licenses/MIT) """Utility functions.""" import fnmatch import os import re import tempfile from pathlib import Path import tensorflow as tf MODEL_FILE_NAME = "model.h5" CONFIG_FILE_NAME = "config.yml" PROCESSOR_FILE_NAME =...
3,053
30.163265
80
py
MnTTS
MnTTS-main/tensorflow_tts/utils/group_conv.py
# -*- coding: utf-8 -*- # This code is copy from https://github.com/tensorflow/tensorflow/pull/36773. """Group Convolution Modules.""" from tensorflow.python.framework import tensor_shape from tensorflow.python.keras import activations, constraints, initializers, regularizers from tensorflow.python.keras.engine.base_l...
23,944
41.989228
88
py
MnTTS
MnTTS-main/tensorflow_tts/utils/griffin_lim.py
# -*- coding: utf-8 -*- # Copyright 2020 Minh Nguyen (@dathudeptrai) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ...
6,824
39.868263
88
py
MnTTS
MnTTS-main/tensorflow_tts/utils/weight_norm.py
# -*- coding: utf-8 -*- # Copyright 2019 The TensorFlow Probability Authors and Minh Nguyen (@dathudeptrai) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licen...
7,216
38.010811
102
py
MnTTS
MnTTS-main/tensorflow_tts/losses/stft.py
# -*- coding: utf-8 -*- # Copyright 2020 Minh Nguyen (@dathudeptrai) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ...
5,179
33.533333
97
py
MnTTS
MnTTS-main/tensorflow_tts/losses/spectrogram.py
# -*- coding: utf-8 -*- # Copyright 2020 Minh Nguyen (@dathudeptrai) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ...
2,697
31.902439
83
py
MnTTS
MnTTS-main/tensorflow_tts/trainers/base_trainer.py
# -*- coding: utf-8 -*- # Copyright 2020 Minh Nguyen (@dathudeptrai) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ...
36,562
35.165183
113
py
MnTTS
MnTTS-main/test/test_fastspeech.py
# -*- coding: utf-8 -*- # Copyright 2020 Minh Nguyen (@dathudeptrai) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ...
2,995
34.247059
86
py
MnTTS
MnTTS-main/test/test_tacotron2.py
# -*- coding: utf-8 -*- # Copyright 2020 Minh Nguyen (@dathudeptrai) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ...
5,329
34.533333
87
py
MnTTS
MnTTS-main/test/test_melgan_layers.py
# -*- coding: utf-8 -*- # Copyright 2020 Minh Nguyen (@dathudeptrai) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ...
2,965
30.892473
113
py
MnTTS
MnTTS-main/test/test_fastspeech2.py
# -*- coding: utf-8 -*- # Copyright 2020 Minh Nguyen (@dathudeptrai) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ...
4,805
35.969231
88
py
tenpy
tenpy-main/doc/conf.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright 2019-2023 TeNPy Developers, GNU GPLv3 # import sys import os import inspect import sphinx_rtd_theme import io import warnings # ensure parent folder is in sys.path to allow import of tenpy REPO_PREFIX = os.path.abspath(os.path.join(os.path.dirname(__file__), '...
13,181
33.417755
151
py
silero-models
silero-models-master/hubconf.py
dependencies = ["torch"] import sys from src.silero import ( silero_stt, silero_tts, silero_te, ) __all__ = [ "silero_stt", "silero_tts", "silero_te", ] sys.path.append("src/silero")
210
11.411765
29
py
silero-models
silero-models-master/src/silero/utils.py
import os import torch import warnings import torchaudio from typing import List from itertools import groupby def read_batch(audio_paths: List[str]): return [read_audio(audio_path) for audio_path in audio_paths] def split_into_batches(lst: List[str], batch_size: i...
4,449
32.458647
93
py
silero-models
silero-models-master/src/silero/silero.py
import os import torch def silero_stt(language='en', version='latest', jit_model='jit', **kwargs): """ Silero Speech-To-Text Model(s) language (str): language of the model, now available are ['en', 'de', 'es'] Returns a model, decoder object and a set of utils ...
6,325
41.456376
147
py
silero-models
silero-models-master/src/silero/tts_utils.py
import os import re import torch import warnings def init_jit_model(model_url: str, device: torch.device = torch.device('cpu')): torch.set_grad_enabled(False) model_dir = os.path.join(os.path.dirname(__file__), "model") os.makedirs(model_dir, exist_ok=True) model_path = os.path.joi...
3,090
31.197917
101
py
flpytorch
flpytorch-main/setup.py
#!/usr/bin/env python3 import setuptools with open("README.md", "r") as fh: long_description = fh.read() setuptools.setup( name="fl_pytorch", version="0.0.1", author_email="konstantin.burlachenko@kaust.edu.sa,samuel.horvath@kaust.edu.sa,peter.richtarik@kaust.edu.sa", description="Efficient Simula...
737
29.75
112
py
flpytorch
flpytorch-main/fl_pytorch/opts.py
#!/usr/bin/env python3 import argparse import time from datetime import datetime import os import utils.gpu_utils as gpu_utils import random # Global simulation counter gSimulationCounter = 0 def parse_args(args): parser = initialise_arg_parser(args, 'FLPyTorch, running arguments.') # SERVER OPTIMIZATION P...
15,635
28.89675
124
py
flpytorch
flpytorch-main/fl_pytorch/run.py
#!/usr/bin/env python3 import os import sys import json import socket import math import signal # Import PyTorch root package import torch import torch from torch.utils.collect_env import get_pretty_env_info import numpy as np import time import copy import threading import pickle from utils import comm_socket from...
49,485
47.75468
136
py
flpytorch
flpytorch-main/fl_pytorch/gui/start.py
#!/usr/bin/env python3 # https://wiki.python.org/moin/PyQt # https://www.riverbankcomputing.com/static/Docs/PyQt5/ # Example of path to designer in Windows OS: Python38/Lib/site-packages/qt5_applications/Qt/bin/designer.exe import sys, platform, time, shutil, pickle, threading, math, socket import datetime import os...
129,627
40.801999
203
py
flpytorch
flpytorch-main/fl_pytorch/gui/generated/ConfigWidget.py
# -*- coding: utf-8 -*- # Form implementation generated from reading ui file './../forms/ConfigWidget.ui' # # Created by: PyQt5 UI code generator 5.15.4 # # WARNING: Any manual changes made to this file will be lost when pyuic5 is # run again. Do not edit this file unless you know what you are doing. from PyQt5 imp...
85,728
74.134969
436
py
flpytorch
flpytorch-main/fl_pytorch/gui/generated/LogWindow.py
# -*- coding: utf-8 -*- # Form implementation generated from reading ui file './../forms/LogWindow.ui' # # Created by: PyQt5 UI code generator 5.15.4 # # WARNING: Any manual changes made to this file will be lost when pyuic5 is # run again. Do not edit this file unless you know what you are doing. from PyQt5 import...
7,538
56.992308
224
py
flpytorch
flpytorch-main/fl_pytorch/models/wideresnet_cifar.py
#!/usr/bin/env python3 # Import PyTorch root package import torch import torch import torch.nn as nn import torch.nn.functional as F class BasicBlock(nn.Module): def __init__(self, in_planes, out_planes, stride, dropRate=0.0): super(BasicBlock, self).__init__() self.bn1 = nn.BatchNorm2d(in_planes...
4,214
38.764151
116
py
flpytorch
flpytorch-main/fl_pytorch/models/femnist.py
#!/usr/bin/env python3 """ CNN model for FEMNIST Dataset. """ from torch import nn # Import PyTorch layers, activations and more import torch.nn.functional as F class FEMNIST(nn.Module): def __init__(self, channel_1=32, channel_2=64, num_classes=62): super(FEMNIST, self).__init__() self.conv1 =...
1,029
27.611111
72
py
flpytorch
flpytorch-main/fl_pytorch/models/vgg_cifar.py
#!/usr/bin/env python3 """ VGG11/13/16/19 in Pytorch. """ import torch.nn as nn cfg = { 'VGG11': [64, 'M', 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M'], 'VGG13': [64, 64, 'M', 128, 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M'], 'VGG16': [64, 64, 'M', 128, 128, 'M', 256, 256, 256, 'M', ...
1,824
29.932203
117
py
flpytorch
flpytorch-main/fl_pytorch/models/resnet_cifarlike.py
#!/usr/bin/env python3 # From: https://github.com/kuangliu/pytorch-cifar """ResNet in PyTorch. For Pre-activation ResNet, see 'preact_resnet.py'. Reference: [1] Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun Deep Residual Learning for Image Recognition. arXiv:1512.03385 """ import torch.nn as nn # Import Py...
4,689
34
83
py
flpytorch
flpytorch-main/fl_pytorch/models/resnet_cifar.py
#!/usr/bin/env python3 # From https://github.com/akamaster/pytorch_resnet_cifar10/blob/master/resnet.py """ Properly implemented ResNet-s for CIFAR10 as described in paper [1]. The implementation and structure of this file is hugely influenced by [2] which is implemented for ImageNet and doesn't have option A for id...
4,928
32.304054
120
py
flpytorch
flpytorch-main/fl_pytorch/models/__init__.py
# ResNets from Torch Vision from torchvision.models import resnet18 as tv_resnet18 from torchvision.models import resnet34 as tv_resnet34 from torchvision.models import resnet50 as tv_resnet50 # ResNets for CIFAR Datasets from .resnet_cifar import resnet20 from .resnet_cifar import resnet32 from .resnet_cifar import r...
1,323
33.842105
68
py
flpytorch
flpytorch-main/fl_pytorch/models/rnn.py
#!/usr/bin/env python3 """ Reccurent Neural Network for Shakespeare Dataset """ # Import PyTorch root package import torch import torch import torch.nn as nn class RNN(nn.Module): def __init__(self, vocab_size=90, embedding_dim=8, hidden_dim=512, num_layers=2): super(RNN, self).__init__() # s...
1,544
29.294118
101
py
flpytorch
flpytorch-main/fl_pytorch/models/mutils.py
#!/usr/bin/env python3 # Import PyTorch root package import torch # Import PyTorch layers, activations and more # import torch.nn.functional as F from utils.logger import Logger def torch_layers_info(model: torch.nn.Module): """ Args: model (nn.Module): Neural Networ...
19,394
36.369942
264
py
flpytorch
flpytorch-main/fl_pytorch/scripts/dump_quality.py
#!/usr/bin/env python3 import math, sys, pickle, os import numpy as np import torch sys.path.append(os.path.join(os.path.dirname(__file__), "./../")) from utils import utils if __name__ == "__main__": files = sys.argv[1:] if len(files) == 0: print("# Tool for dump information about some tracking qu...
1,275
29.380952
75
py
flpytorch
flpytorch-main/fl_pytorch/scripts/extract_cmdline_from_bin.py
#!/usr/bin/env python3 import math, sys, pickle, os import numpy as np import torch sys.path.append(os.path.join(os.path.dirname(__file__), "./../")) from utils import utils if __name__ == "__main__": python = "python" files = sys.argv[1:] if len(files) == 0: print("# Tool for extracting com...
1,054
26.051282
86
py
flpytorch
flpytorch-main/fl_pytorch/scripts/extract_cmdline_from_bin_nice.py
#!/usr/bin/env python3 import math, sys, pickle, os import numpy as np import torch sys.path.append(os.path.join(os.path.dirname(__file__), "./../")) from utils import utils if __name__ == "__main__": python = "python" files = sys.argv[1:] if len(files) == 0: print("# Tool for extracting com...
1,156
27.925
142
py
flpytorch
flpytorch-main/fl_pytorch/scripts/dump_configuration.py
#!/usr/bin/env python3 import math, sys, pickle, os import numpy as np import torch sys.path.append(os.path.join(os.path.dirname(__file__), "./../")) from utils import utils if __name__ == "__main__": files = sys.argv[1:] if len(files) == 0: print("# Tool for dump information about experiments insi...
1,026
28.342857
82
py
flpytorch
flpytorch-main/fl_pytorch/scripts/prune_from_tensors.py
#!/usr/bin/env python3 import math, sys, pickle, os import numpy as np import torch import copy sys.path.append(os.path.join(os.path.dirname(__file__), "./../")) from utils import utils if __name__ == "__main__": files = sys.argv[1:] if len(files) == 0: print("# Tool for prune away any tensors from...
5,177
41.097561
139
py
flpytorch
flpytorch-main/fl_pytorch/data_preprocess/libsvm_dataset.py
from .fl_dataset import FLDataset from .read_file_cache import cacheItemThreadSafe, cacheMakeKey, cacheGetItem from utils.logger import Logger from utils import execution_context import numpy as np from torchvision.datasets.utils import download_url import os import math import torch # Train datasets URL's for train...
18,634
44.67402
307
py
flpytorch
flpytorch-main/fl_pytorch/data_preprocess/data_loader.py
#!/usr/bin/env python3 # Import PyTorch root package import torch import torch import torchvision from torchvision import transforms from .fl_datasets import FEMNIST, FLCifar100, FLCifar10, FLCifar10ByClass, Shakespeare, SHAKESPEARE_EVAL_BATCH_SIZE from .artificial_dataset import ArificialDataset from .libsvm_datase...
9,055
37.21097
119
py
flpytorch
flpytorch-main/fl_pytorch/data_preprocess/fl_dataset.py
#!/usr/bin/env python3 from torch.utils.data import Dataset class FLDataset(Dataset): """ Base class for Federated Datasets with pointers to clients. """ def set_client(self, index=None): raise NotImplementedError def load_data(self): raise NotImplementedError
301
19.133333
63
py
flpytorch
flpytorch-main/fl_pytorch/data_preprocess/h5_tff_dataset.py
#!/usr/bin/env python3 import os import h5py from .read_file_cache import cacheItemThreadUnsafe, cacheMakeKey, cacheGetItem from .fl_dataset import FLDataset from torchvision.datasets.utils import download_url from utils import execution_context TFF_DATASETS = { 'cifar100_fl': 'https://storage.googleapis.com/tff...
5,059
40.818182
166
py
flpytorch
flpytorch-main/fl_pytorch/data_preprocess/artificial_dataset.py
#!/usr/bin/env python3 from .read_file_cache import cacheItemThreadUnsafe, cacheMakeKey, cacheGetItem, cacheHasItem from .fl_dataset import FLDataset import numpy as np # Import PyTorch root package import torch import torch import math class ArificialDataset(FLDataset): """ Based FL class that loads H5 typ...
7,454
36.275
120
py
flpytorch
flpytorch-main/fl_pytorch/data_preprocess/fl_datasets/femnist.py
import os import numpy as np import torchvision from ..h5_tff_dataset import H5TFFDataset class FEMNIST(H5TFFDataset): """ Federated Extended MNIST Dataset. Clients corresponds to different person handwriting. """ def __init__(self, h5_path, train=True, client_id=None): if train: ...
1,068
30.441176
90
py
flpytorch
flpytorch-main/fl_pytorch/data_preprocess/fl_datasets/cifar10.py
from torchvision.datasets import CIFAR10 from torchvision import transforms from PIL import Image import numpy as np class FLCifar10(CIFAR10): """ CIFAR10 Dataset. num_clients clients that were allocated data_preprocess uniformly at random. """ def __init__(self, exec_ctx, args, root, train=True, ...
3,643
34.72549
136
py
flpytorch
flpytorch-main/fl_pytorch/data_preprocess/fl_datasets/cifar10_by_class.py
from torchvision.datasets import CIFAR10 from PIL import Image import numpy as np import torch class FLCifar10ByClass(CIFAR10): """ CIFAR10 Dataset. num_clients clients that were allocated data_preprocess uniformly at random. """ def __init__(self, exec_ctx, args, root, train=True, transform=None, ...
6,165
37.298137
140
py
flpytorch
flpytorch-main/fl_pytorch/data_preprocess/fl_datasets/shakespeare.py
import os import numpy as np # Import PyTorch root package import torch import torch from torch.utils.data import DataLoader from ..h5_tff_dataset import H5TFFDataset from ..fl_dataset import FLDataset SHAKESPEARE_VOCAB = list('dhlptx@DHLPTX $(,048cgkoswCGKOSW[_#\'/37;?bfjnrvzBFJNRVZ"&*.26:\naeimquyAEIMQUY]!%)-159\...
5,873
39.791667
117
py
flpytorch
flpytorch-main/fl_pytorch/fl_layers/utils.py
#!/usr/bin/env python3 # Import Tensor node in the computation graph from torch import Tensor def input_to_block_diag(x_array: Tensor) -> Tensor: pass
158
16.666667
51
py
flpytorch
flpytorch-main/fl_pytorch/utils/worker_thread.py
#!/usr/bin/env python3 # Import PyTorch root package import torch import torch import threading from . import buffer class WorkerThread(threading.Thread): """Worker thread. It's goal execute deferred functions.""" def __init__(self): threading.Thread.__init__(self) self.cmds = buffer.Buff...
3,710
32.736364
120
py
flpytorch
flpytorch-main/fl_pytorch/utils/model_funcs.py
#!/usr/bin/env python3 # Import PyTorch root package import torch import torch import random from torch import nn from torch.nn import DataParallel import time import copy import math import os import json from collections import OrderedDict import numpy as np from copy import deepcopy import pickle from torch.opt...
39,950
41.009464
195
py
flpytorch
flpytorch-main/fl_pytorch/utils/thread_pool.py
#!/usr/bin/env python3 import time # Import PyTorch root package import torch import torch from . import worker_thread from . import gpu_utils class ThreadPool: """Thread pool. Collectively execute assigned work.""" def __init__(self, number_of_workers=0): """ Constructor. Args: ...
4,898
33.020833
120
py
flpytorch
flpytorch-main/fl_pytorch/utils/execution_context.py
#!/usr/bin/env python3 import threading import random import time import numpy as np from . import thread_pool class ExecutionContext: """Private execution data. Please do not manipulate directly, only with dedicated API""" pass def initExecutionContext(): """Initialize thread specific execution cont...
2,913
48.389831
120
py
flpytorch
flpytorch-main/fl_pytorch/utils/gpu_utils.py
#!/usr/bin/env python3 # Import PyTorch root package import torch import torch from . import logger def is_target_dev_gpu(device): """ Check that target device is gpu. Args: device: integer or string. If it's integer -1 stands for CPU, and value greater then or equal to 0 is a GPU number in...
4,104
33.788136
120
py
flpytorch
flpytorch-main/fl_pytorch/utils/compressors.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Import PyTorch root package import torch import torch import math import numpy as np class CompressorType: IDENTICAL = 1 # Identical compressor LAZY_COMPRESSOR = 2 # Lazy or Bernulli compressor RANDK_COMPRESSOR = 3 # Rank-K...
20,215
36.786916
120
py
flpytorch
flpytorch-main/fl_pytorch/utils/algorithms.py
#!/usr/bin/env python3 import random import time import copy import math # Import PyTorch root package import torch import torch import numpy as np from utils import execution_context from utils import model_funcs from utils import compressors from models import mutils import utils import a...
94,490
40.736307
223
py
flpytorch
flpytorch-main/fl_pytorch/utils/fl_funcs.py
#!/usr/bin/env python3 import numpy as np # Import PyTorch root package import torch import torch from copy import deepcopy from .logger import Logger def get_sampled_clients(num_clients, args, exec_ctx): # clients are pre-sampled for deterministic participation among runs if args.client_sampling_type == "...
4,355
39.71028
137
py
flpytorch
flpytorch-main/fl_pytorch/utils/checkpointing.py
#!/usr/bin/env python3 import os # Import PyTorch root package import torch import torch import shutil import json import copy from utils.utils import get_model_str_from_obj from utils.logger import Logger from utils.utils import create_model_dir, create_metrics_dict from utils import execution_context import util...
9,225
38.259574
147
py
flpytorch
flpytorch-main/docs/generate.py
#!/usr/bin/env python3 import glob, os, subprocess # Create destantion folder for documentation if not os.path.exists("./generated"): os.makedirs("./generated") gendocs_folder = os.path.abspath("generated") print("Documentaiton will be generated in folder: ", gendocs_folder) # Get path for template folder temp...
1,394
34.769231
130
py
robust_object_detection
robust_object_detection-main/test.py
import os import torch import argparse from detectron2.config import CfgNode from detectron2.evaluation import inference_on_dataset from detectron2.utils.events import EventStorage from detectron2.utils.logger import setup_logger from src.evaluation.build import build_evaluator from src.models.build import build_mode...
2,610
41.112903
108
py
robust_object_detection
robust_object_detection-main/src/models/faster_rcnn.py
import torch from typing import Dict, List from detectron2.modeling.meta_arch.rcnn import GeneralizedRCNN from detectron2.modeling.roi_heads.fast_rcnn import fast_rcnn_inference from detectron2.modeling.meta_arch.build import META_ARCH_REGISTRY from detectron2.utils.events import get_event_storage @META_ARCH_REGISTRY...
6,342
52.302521
169
py
robust_object_detection
robust_object_detection-main/src/models/retinanet.py
import torch from typing import Dict, List from detectron2.modeling.meta_arch.build import META_ARCH_REGISTRY from detectron2.modeling.meta_arch.retinanet import RetinaNet, permute_to_N_HWA_K from detectron2.structures import Boxes, Instances from detectron2.utils.events import get_event_storage from detectron2.layers ...
6,244
46.310606
158
py
robust_object_detection
robust_object_detection-main/src/models/fcos.py
import torch from typing import Dict, List from detectron2.modeling.meta_arch.build import META_ARCH_REGISTRY from detectron2.structures import ImageList from .adet import OneStageDetector @META_ARCH_REGISTRY.register() class CustomFCOS(OneStageDetector): ''' With train_forward() and compute_losses(), we can ...
3,673
51.485714
133
py
robust_object_detection
robust_object_detection-main/src/models/build.py
import torch from detectron2.modeling import build_model as build_architecture from .faster_rcnn import CustomFasterRCNN from .retinanet import CustomRetinaNet from .fcos import CustomFCOS def build_model(cfg): ''' Wrapper around detectron's build_model() to do the backbone (or the whole model) initialization ...
2,246
50.068182
124
py
robust_object_detection
robust_object_detection-main/src/models/adet/layers/deform_conv.py
import torch from torch import nn from detectron2.layers import Conv2d class _NewEmptyTensorOp(torch.autograd.Function): @staticmethod def forward(ctx, x, new_shape): ctx.shape = x.shape return x.new_empty(new_shape) @staticmethod def backward(ctx, grad): shape = ctx.shape ...
3,988
33.094017
104
py
robust_object_detection
robust_object_detection-main/src/models/adet/layers/iou_loss.py
import torch from torch import nn class IOULoss(nn.Module): """ Intersetion Over Union (IoU) loss which supports three different IoU computations: * IoU * Linear IoU * gIoU """ def __init__(self, loc_loss_type='iou'): super(IOULoss, self).__init__() self.loc_loss_type =...
830
25.806452
58
py
robust_object_detection
robust_object_detection-main/src/models/adet/layers/naive_group_norm.py
import torch from torch.nn import Module, Parameter from torch.nn import init class NaiveGroupNorm(Module): r"""NaiveGroupNorm implements Group Normalization with the high-level matrix operations in PyTorch. It is a temporary solution to export GN by ONNX before the official GN can be exported by ONNX. Th...
2,976
41.528571
103
py
robust_object_detection
robust_object_detection-main/src/models/adet/utils/comm.py
import torch import torch.nn.functional as F import torch.distributed as dist from detectron2.utils.comm import get_world_size def reduce_sum(tensor): world_size = get_world_size() if world_size < 2: return tensor tensor = tensor.clone() dist.all_reduce(tensor, op=dist.ReduceOp.SUM) retur...
2,879
26.961165
68
py
robust_object_detection
robust_object_detection-main/src/models/adet/modeling/one_stage_detector.py
import logging from torch import nn from detectron2.modeling.meta_arch.build import META_ARCH_REGISTRY from detectron2.modeling import ProposalNetwork, GeneralizedRCNN from detectron2.utils.events import get_event_storage from detectron2.utils.logger import log_first_n from detectron2.modeling.postprocessing import de...
7,381
39.56044
100
py
robust_object_detection
robust_object_detection-main/src/models/adet/modeling/backbone/lpf.py
import torch import torch.nn.parallel import numpy as np import torch.nn as nn import torch.nn.functional as F class Downsample(nn.Module): def __init__(self, pad_type='reflect', filt_size=3, stride=2, channels=None, pad_off=0): super(Downsample, self).__init__() self.filt_size = filt_size ...
4,207
35.912281
143
py