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
ResponseEdit
ResponseEdit-master/edit/train.py
from __future__ import division import sys sys.path.append(r'../') import numpy as np from edit.Translator import Translator import s2s import argparse import torch import torch.nn as nn from torch import cuda from torch.autograd import Variable import math import time import logging try: import ipdb except Impo...
14,874
36.002488
146
py
ResponseEdit
ResponseEdit-master/s2s/xinit.py
import math import random import torch from torch.autograd import Variable def calculate_gain(nonlinearity, param=None): """Return the recommended gain value for the given nonlinearity function. The values are as follows: ============ ========================================== nonlinearity gain ====...
13,329
35.620879
120
py
ResponseEdit
ResponseEdit-master/s2s/EditModels.py
import numpy as np import torch import torch.nn as nn from torch.autograd import Variable import s2s.modules from s2s.Models import StackedGRU from torch.nn.utils.rnn import pad_packed_sequence as unpack from torch.nn.utils.rnn import pack_padded_sequence as pack try: import ipdb except ImportError: pass cla...
14,552
41.677419
144
py
ResponseEdit
ResponseEdit-master/s2s/Beam.py
from __future__ import division # Class for managing the internals of the beam search process. # # # hyp1#-hyp1---hyp1 -hyp1 # \ / # hyp2 \-hyp2 /-hyp2#hyp2 # / \ # hyp3#-hyp3---hyp3 -hyp3 # ======================== # # Take...
5,139
31.531646
95
py
ResponseEdit
ResponseEdit-master/s2s/Dataset.py
from __future__ import division import math import random import torch from torch.autograd import Variable import s2s class Dataset(object): def __init__(self, srcData, tgtData, batchSize, cuda): self.src = srcData if tgtData: self.tgt = tgtData assert (len(self.src) == ...
9,780
38.124
117
py
ResponseEdit
ResponseEdit-master/s2s/Dict.py
import torch class Dict(object): def __init__(self, data=None, lower=False): self.idxToLabel = {} self.labelToIdx = {} self.frequencies = {} self.lower = lower # Special entries will not be pruned. self.special = [] if data is not None: if type...
3,846
28.143939
81
py
ResponseEdit
ResponseEdit-master/s2s/Translator.py
import s2s import torch.nn as nn import torch from torch.autograd import Variable try: import ipdb except ImportError: pass class Translator(object): def __init__(self, opt, model=None, dataset=None): self.opt = opt if model is None: checkpoint = torch.load(opt.model) ...
8,022
38.522167
118
py
ResponseEdit
ResponseEdit-master/s2s/Optim.py
import math import torch.optim as optim import torch.nn as nn from torch.nn.utils import clip_grad_norm_ import s2s.modules import logging logger = logging.getLogger(__name__) class Optim(object): def set_parameters(self, params): self.params = list(params) # careful: params may be a generator ...
2,848
36.986667
105
py
ResponseEdit
ResponseEdit-master/s2s/Models.py
import torch import torch.nn as nn from torch.autograd import Variable import s2s.modules from torch.nn.utils.rnn import pad_packed_sequence as unpack from torch.nn.utils.rnn import pack_padded_sequence as pack try: import ipdb except ImportError: pass class Encoder(nn.Module): def __init__(self, opt, di...
6,331
35.813953
120
py
ResponseEdit
ResponseEdit-master/s2s/modules/myRNN.py
import torch import torch.nn as nn from torch.autograd import Variable import s2s.modules from torch.nn.utils.rnn import pad_packed_sequence as unpack from torch.nn.utils.rnn import pack_padded_sequence as pack try: import ipdb except ImportError: pass class MyGRU(nn.Module): def __init__(self, input_siz...
1,302
32.410256
95
py
ResponseEdit
ResponseEdit-master/s2s/modules/GlobalAttention.py
""" Global attention takes a matrix and a query vector. It then computes a parameterized convex combination of the matrix based on the input query. H_1 H_2 H_3 ... H_n q q q q | | | | \ | | / ..... \ | / ...
1,725
28.254237
79
py
ResponseEdit
ResponseEdit-master/s2s/modules/ConcatAttention.py
import torch import torch.nn as nn import math try: import ipdb except ImportError: pass class ConcatAttention(nn.Module): def __init__(self, attend_dim, query_dim, att_dim): super(ConcatAttention, self).__init__() self.attend_dim = attend_dim self.query_dim = query_dim se...
2,422
39.383333
115
py
ResponseEdit
ResponseEdit-master/s2s/modules/Maxout.py
import torch import torch.nn as nn import math class MaxOut(nn.Module): def __init__(self, pool_size): super(MaxOut, self).__init__() self.pool_size = pool_size def forward(self, input): """ input: reduce_size: """ input_size = list(input.size()) ...
911
26.636364
71
py
ResponseEdit
ResponseEdit-master/s2s/modules/myAdam.py
import math from torch.optim.optimizer import Optimizer class MyAdam(Optimizer): """Implements Adam algorithm. It has been proposed in `Adam: A Method for Stochastic Optimization`_. Arguments: params (iterable): iterable of parameters to optimize or dicts defining parameter groups ...
2,913
37.342105
90
py
EpipolarPose
EpipolarPose-master/scripts/train.py
import argparse import os import pprint import shutil import _init_paths import torch import torch.nn.parallel import torch.backends.cudnn as cudnn import torch.optim import torch.utils.data import torch.utils.data.distributed from lib.core.config import config from lib.core.config import update_config from lib.core....
5,905
29.760417
114
py
EpipolarPose
EpipolarPose-master/scripts/valid.py
import argparse import pprint import _init_paths import torch import torch.nn.parallel import torch.backends.cudnn as cudnn import torch.optim import torch.utils.data import torch.utils.data.distributed from lib.core.config import config from lib.core.config import update_config from lib.core.config import update_dir...
3,473
28.440678
100
py
EpipolarPose
EpipolarPose-master/refiner/main.py
import os import time import logging import argparse import numpy as np import torch import torch.nn as nn import torch.backends.cudnn as cudnn import _init_paths from refiner.data import Human36M from refiner.model import get_model, weight_init from refiner.utils import lr_decay, AverageMeter, save_ckpt def parse_...
4,944
27.75
109
py
EpipolarPose
EpipolarPose-master/refiner/utils.py
import os import torch class AverageMeter(object): def __init__(self): self.val = 0 self.avg = 0 self.sum = 0 self.count = 0 def update(self, val, n=1): self.val = val self.sum += val * n self.count += n self.avg = self.sum / self.count def lr_...
959
25.666667
59
py
EpipolarPose
EpipolarPose-master/refiner/model.py
from __future__ import absolute_import from __future__ import print_function import torch.nn as nn import torch def weight_init(m): if isinstance(m, nn.Linear): nn.init.kaiming_normal_(m.weight) # nn.init.constant_(m.weight, 0.) # nn.init.constant_(m.bias, 0.) class LinearPG(nn.Module):...
4,263
25.484472
103
py
EpipolarPose
EpipolarPose-master/refiner/data.py
import os from torch.utils.data import Dataset import numpy as np import pickle as pkl from lib.utils.prep_h36m import compute_similarity_transform import logging MPII_NAMES = [''] * 15 MPII_NAMES[0] = 'RFoot' MPII_NAMES[1] = 'RKnee' MPII_NAMES[2] = 'RHip' MPII_NAMES[3] = 'LHip' MPII_NAMES[4] = 'LKnee' MPII_NAMES[5] =...
5,273
31.9625
107
py
EpipolarPose
EpipolarPose-master/lib/core/inference.py
import math import numpy as np import torch from torch.nn import functional as F from lib.utils.transforms import transform_preds from lib.utils.cameras import load_cameras from lib.utils.cameras import Camera def get_max_preds(batch_heatmaps): ''' get predictions from score maps heatmaps: numpy.ndarray...
5,455
30.906433
96
py
EpipolarPose
EpipolarPose-master/lib/core/integral_loss.py
import torch from torch.nn import functional as F import numpy as np import torch.nn as nn import math def weighted_mse_loss(input, target, weights, size_average, norm=False): if norm: input = input / torch.norm(input, 1) target = target / torch.norm(target, 1) out = (input - target) ** 2 ...
7,532
33.085973
113
py
EpipolarPose
EpipolarPose-master/lib/core/function.py
import logging import time import numpy as np import torch from lib.utils.img_utils import trans_coords_from_patch_to_org_3d from lib.core.integral_loss import get_result_func from lib.utils.utils import AverageMeter logger = logging.getLogger(__name__) def train_integral(config, train_loader, model, criterion, op...
4,375
31.176471
115
py
EpipolarPose
EpipolarPose-master/lib/dataset/h36m.py
import torch import pickle as pkl import random import os import logging import numpy as np import copy from lib.utils.prep_h36m import CamBackProj, compute_similarity_transform from lib.dataset.JointIntegralDataset import JointsIntegralDataset, H36M_NAMES, MPII_NAMES from lib.utils.data_utils import define_actions fr...
14,061
36.201058
122
py
EpipolarPose
EpipolarPose-master/lib/dataset/JointIntegralDataset.py
import logging import numpy as np from torch.utils.data import Dataset from lib.core.integral_loss import get_label_func from lib.utils.augmentation import load_occluders H36M_NAMES = ['']*17 H36M_NAMES[0] = 'Hip' H36M_NAMES[1] = 'RHip' H36M_NAMES[2] = 'RKnee' H36M_NAMES[3] = 'RFoot' H36M_NAMES[4] = 'LHip' H36M...
2,269
23.148936
104
py
EpipolarPose
EpipolarPose-master/lib/models/pose3d_resnet.py
import os import logging import torch import torch.nn as nn BN_MOMENTUM = 0.1 logger = logging.getLogger(__name__) def conv3x3(in_planes, out_planes, stride=1): """3x3 convolution with padding""" return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride, padding=1, bias=Fals...
11,074
35.19281
109
py
EpipolarPose
EpipolarPose-master/lib/utils/utils.py
import os import logging import time from pathlib import Path import numpy as np import torch import torch.optim as optim from lib.core.config import get_model_name def create_logger(cfg, cfg_name, phase='train'): root_output_dir = Path(cfg.OUTPUT_DIR) # set up logger if not root_output_dir.exists(): ...
5,484
24.630841
83
py
EpipolarPose
EpipolarPose-master/lib/utils/img_utils.py
import cv2 import torch import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import axes3d, Axes3D # <-- Note the capitalization! from lib.utils.utils import calc_total_skeleton_length from lib.utils.transforms import get_affine_transform from lib.utils.augmentation import occlude_with_objects from lib.core.int...
12,661
37.253776
119
py
RTNet2022
RTNet2022-main/main.py
import argparse import os import torch import numpy as np import time from exp.exp_model import Exp_Model parser = argparse.ArgumentParser(description='[RTNet] Respecting Times Series Properties') parser.add_argument('--model', type=str, required=True, default='RT', help='model of experiment') pa...
15,082
55.703008
121
py
RTNet2022
RTNet2022-main/utils/tools.py
import numpy as np import torch import torch.nn.functional as F def adjust_learning_rate(optimizer, epoch, args): if args.lradj == 'type1': args.learning_rate = args.learning_rate * 0.5 lr_adjust = {epoch: args.learning_rate} elif args.lradj == 'type2': lr_adjust = { 2: 5e-...
4,375
33.730159
112
py
RTNet2022
RTNet2022-main/utils/metrics.py
import numpy as np import torch def RSE(pred, true): return np.sqrt(np.sum((true - pred) ** 2)) / np.sqrt(np.sum((true - true.mean()) ** 2)) def CORR(pred, true): u = ((true - true.mean(0)) * (pred - pred.mean(0))).sum(0) d = np.sqrt(((true - true.mean(0)) ** 2 * (pred - pred.mean(0)) ** 2).sum(0)) ...
778
18
91
py
RTNet2022
RTNet2022-main/data/data_loader.py
import os import warnings import numpy as np import pandas as pd from sklearn.preprocessing import MaxAbsScaler from torch.utils.data import Dataset from utils.tools import StandardScaler warnings.filterwarnings('ignore') def _get_time_features(dt, timebed): if timebed == 'year': return np.stack([ ...
28,353
39.505714
119
py
RTNet2022
RTNet2022-main/RT/embed.py
import torch import torch.nn as nn import torch.nn.functional as F import math class TokenEmbedding(nn.Module): def __init__(self, c_in, d_model, group=1): super(TokenEmbedding, self).__init__() padding = 0 self.tokenConv = nn.Conv1d(in_channels=c_in, out_channels=d_model, groups=group, ...
1,027
30.151515
91
py
RTNet2022
RTNet2022-main/RT/model.py
import torch import torch.nn as nn from RT.ConvBlock import ConvLayer, ConvBlock from RT.embed import DataEmbedding class RT_block(nn.Module): def __init__(self, d_model, kernel, dropout, group, block_nums, label_len, pred_len, c_out, flag='End-to-end', FE='ResNet'): super(RT_block, self...
7,479
41.5
117
py
RTNet2022
RTNet2022-main/RT/ConvBlock.py
import torch import torch.nn as nn import math from torch.nn.utils import weight_norm class ConvLayer(nn.Module): def __init__(self, c_in, c_out, kernel=3, dropout=0, group=1, s=1): super(ConvLayer, self).__init__() self.dropout = nn.Dropout(dropout) self.kernel = kernel self.downC...
8,251
42.431579
99
py
RTNet2022
RTNet2022-main/exp/exp_model.py
from data.data_loader import Dataset_ETT_hour, Dataset_ETT_min, Dataset_WTH, Dataset_ECL from exp.exp_basic import Exp_Basic from RT.model import RT from utils.tools import EarlyStopping, adjust_learning_rate, loss_process, Cost_loss from utils.metrics import metric import numpy as np import torch import torch.nn as...
21,674
43.325153
120
py
RTNet2022
RTNet2022-main/exp/exp_basic.py
import os import torch import numpy as np class Exp_Basic(object): def __init__(self, args): self.args = args self.device = self._acquire_device() self.model = self._build_model().to(self.device) def _build_model(self): raise NotImplementedError return None def _a...
885
22.315789
84
py
canife
canife-main/canife/canary_designer.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import copy import random from collections import defaultdict from timeit import default...
27,010
50.449524
278
py
canife
canife-main/canife/canary_analyser.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import copy import math import matplotlib.pyplot as plt import numpy as np import torch...
35,758
54.268934
327
py
canife
canife-main/canife/utils.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import copy import itertools import re import string import unicodedata from typing impo...
10,307
34.42268
172
py
canife
canife-main/canife/canary_designer_nlp.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import random import matplotlib.pyplot as plt import numpy as np import seaborn as sns ...
6,553
43.585034
256
py
canife
canife-main/plotting/extract_aws.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import argparse import glob import os import pandas as pd import torch USERNAME = os....
1,759
29.877193
95
py
canife
canife-main/plotting/extract_exp.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import argparse import glob import pandas as pd import torch def extract_sweep(root_d...
1,764
30.517857
90
py
canife
canife-main/plotting/example_plotter.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import argparse import ast import pathlib import sys from pathlib import Path import ma...
14,587
41.530612
185
py
canife
canife-main/FLSim/flsim/privacy/privacy_engine.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. """ This file contains the noise generation function and the required DP parameters that...
10,738
33.200637
88
py
canife
canife-main/FLSim/flsim/privacy/user_update_clip.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. """ This file contains the functions for clipping clients' updates in an FL simulation. ...
2,598
33.653333
102
py
canife
canife-main/FLSim/flsim/privacy/tests/test_privacy_engine.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import math from unittest.mock import MagicMock import numpy as np import pytest import...
12,209
33.106145
88
py
canife
canife-main/FLSim/flsim/privacy/tests/test_user_update_clipper.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import pytest import torch from flsim.common.pytest_helper import ( assertAlmostEqua...
5,081
36.925373
86
py
canife
canife-main/FLSim/flsim/privacy/tests/test_dp_integration.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Any, Dict, Optional import numpy as np import torch import torch.nn ...
27,447
34.973788
109
py
canife
canife-main/FLSim/flsim/secure_aggregation/secure_aggregator.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from __future__ import annotations import logging from dataclasses import dataclass fro...
14,035
34.806122
88
py
canife
canife-main/FLSim/flsim/secure_aggregation/tests/test_secure_aggregation.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import torch from flsim.channels.message import Message from flsim.common.pytest_helper ...
15,727
37.360976
89
py
canife
canife-main/FLSim/flsim/secure_aggregation/tests/test_secagg_integration.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import torch from flsim.common.pytest_helper import assertEqual, assertNotEqual from fls...
7,113
37.247312
88
py
canife
canife-main/FLSim/flsim/common/tests/test_timeout_simulator.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import numpy as np import torch from flsim.common.pytest_helper import ( assertAlmos...
6,510
39.69375
97
py
canife
canife-main/FLSim/flsim/common/tests/test_fine_tuner.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import torch from flsim.clients.base_client import ClientConfig from flsim.common.fine_t...
3,057
36.753086
83
py
canife
canife-main/FLSim/flsim/common/tests/test_training_simulator.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import math from typing import List, Tuple, Type import numpy as np import pytest impor...
28,262
40.259854
100
py
canife
canife-main/FLSim/flsim/clients/base_client.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. """ This file defines the concept of a base client for a federated learning setting. Als...
16,369
37.791469
155
py
canife
canife-main/FLSim/flsim/clients/dp_client.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. """ This file defines the concept of a differentially private client where a sample leve...
6,365
35.797688
99
py
canife
canife-main/FLSim/flsim/clients/tests/test_client.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from unittest.mock import MagicMock import pytest import torch import torch.nn as nn fr...
24,318
37.540412
89
py
canife
canife-main/FLSim/flsim/active_user_selectors/simple_user_selector.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from __future__ import annotations import abc import copy import math from dataclasses ...
16,943
32.752988
96
py
canife
canife-main/FLSim/flsim/active_user_selectors/diverse_user_selector.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from __future__ import annotations import copy from dataclasses import dataclass from t...
20,917
38.6926
104
py
canife
canife-main/FLSim/flsim/active_user_selectors/tests/test_active_user_selector.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import math from collections import Counter import torch from flsim.active_user_selecto...
16,032
40.215938
88
py
canife
canife-main/FLSim/flsim/active_user_selectors/tests/test_diverse_user_selector.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import math from collections import Counter import torch from flsim.active_user_selecto...
23,663
38.972973
103
py
canife
canife-main/FLSim/flsim/channels/message.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from copy import deepcopy from dataclasses import dataclass, field from typing import Op...
2,440
33.380282
90
py
canife
canife-main/FLSim/flsim/channels/product_quantization_channel.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from __future__ import annotations import math from collections import OrderedDict from...
7,116
38.104396
131
py
canife
canife-main/FLSim/flsim/channels/sparse_mask_channel.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from __future__ import annotations from collections import OrderedDict from dataclasses...
5,153
38.045455
95
py
canife
canife-main/FLSim/flsim/channels/scalar_quantization_channel.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from __future__ import annotations from collections import OrderedDict from dataclasses...
7,986
41.94086
98
py
canife
canife-main/FLSim/flsim/channels/tests/test_sparse_mask_channel.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import OrderedDict, Type import pytest import torch from flsim.channels.bas...
10,994
32.935185
88
py
canife
canife-main/FLSim/flsim/channels/pq_utils/pq.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import math import torch from sklearn.cluster import KMeans class PQ: """ Qua...
12,975
37.850299
93
py
canife
canife-main/FLSim/flsim/servers/aggregator.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from enum import IntEnum import torch import torch.nn as nn from flsim.utils.distribute...
3,225
30.320388
84
py
canife
canife-main/FLSim/flsim/servers/sync_dp_servers.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from __future__ import annotations from dataclasses import dataclass from typing import...
8,498
40.661765
122
py
canife
canife-main/FLSim/flsim/servers/tests/test_sync_dp_servers.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import itertools import math from tempfile import mkstemp from unittest.mock import Magi...
13,235
33.379221
102
py
canife
canife-main/FLSim/flsim/servers/tests/test_aggregator.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from tempfile import mkstemp import pytest import torch.distributed as dist import tor...
6,401
29.485714
84
py
canife
canife-main/FLSim/flsim/optimizers/server_optimizers.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. """This file contains optimizers for the server. The server expects an IServerOptimizer...
10,100
30.46729
113
py
canife
canife-main/FLSim/flsim/optimizers/async_aggregators.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from __future__ import annotations import logging from dataclasses import dataclass fro...
19,388
33.256184
99
py
canife
canife-main/FLSim/flsim/optimizers/optimizer_scheduler.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from __future__ import annotations import abc import copy from dataclasses import datac...
8,691
30.042857
99
py
canife
canife-main/FLSim/flsim/optimizers/local_optimizers.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from __future__ import annotations from dataclasses import dataclass from typing import...
4,963
28.547619
99
py
canife
canife-main/FLSim/flsim/optimizers/sync_aggregators.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from __future__ import annotations import abc import logging from dataclasses import da...
11,740
29.897368
99
py
canife
canife-main/FLSim/flsim/optimizers/layerwise_optimizers.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import torch from torch.optim.optimizer import Optimizer class LARS(Optimizer): r"...
6,459
34.690608
103
py
canife
canife-main/FLSim/flsim/optimizers/tests/test_optimizer_scheduler.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import torch from flsim.common.pytest_helper import assertEqual, assertTrue from flsim.o...
2,859
39.857143
80
py
canife
canife-main/FLSim/flsim/optimizers/tests/test_async_aggregator.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import random from dataclasses import dataclass from typing import List import numpy as...
18,364
37.260417
116
py
canife
canife-main/FLSim/flsim/optimizers/tests/test_optimizer_utils.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Any, Dict, Union from flsim.optimizers.async_aggregators import ( ...
6,388
31.267677
87
py
canife
canife-main/FLSim/flsim/utils/count_sketch.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from collections import OrderedDict from copy import deepcopy from typing import Optiona...
9,770
34.402174
116
py
canife
canife-main/FLSim/flsim/utils/cuda.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import abc import torch from flsim.interfaces.model import IFLModel def FloatTensor(c...
3,592
28.211382
83
py
canife
canife-main/FLSim/flsim/utils/sample_model.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Optional import torch import torch.nn as nn import torch.nn.function...
9,329
31.283737
96
py
canife
canife-main/FLSim/flsim/utils/simple_batch_metrics.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Any import torch from flsim.interfaces.batch_metrics import IFLBatch...
1,176
23.020408
71
py
canife
canife-main/FLSim/flsim/utils/example_utils.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. # Cifar-10 dataset specific utils for use in the tutorials import random from typing im...
22,010
34.105263
127
py
canife
canife-main/FLSim/flsim/utils/test_utils.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Any, Dict, List, NamedTuple, Optional, Tuple, Union from unittest.moc...
13,399
27.510638
108
py
canife
canife-main/FLSim/flsim/utils/timing/training_duration_distribution.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from __future__ import annotations import abc import copy from dataclasses import datac...
7,305
29.827004
86
py
canife
canife-main/FLSim/flsim/utils/fl/personalized_model.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import abc import copy from typing import Dict, Iterable import torch class FLModelWi...
5,726
39.048951
88
py
canife
canife-main/FLSim/flsim/utils/fl/common.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import copy import math from typing import List, Optional, Union import torch from flsi...
11,843
35.331288
88
py
canife
canife-main/FLSim/flsim/utils/distributed/fl_distributed.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import logging from enum import IntEnum from itertools import chain from typing import I...
14,829
36.544304
97
py
canife
canife-main/FLSim/flsim/utils/tests/test_training_time_estimator.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import torch from flsim.common.pytest_helper import assertAlmostEqual, assertEqual from ...
5,258
31.263804
83
py
canife
canife-main/FLSim/flsim/utils/tests/test_data_utils.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import torch from flsim.common.pytest_helper import assertEqual, assertLessEqual, assert...
3,346
37.034091
85
py
canife
canife-main/FLSim/flsim/utils/tests/test_model_param_utils.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import collections import math import torch import torch.nn as nn from flsim.common.pyt...
13,535
40.649231
99
py
canife
canife-main/FLSim/flsim/utils/tests/helpers/test_async_trainer_utils.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Any, Optional, Tuple import numpy as np import torch from flsim.clie...
23,373
37.507414
123
py
canife
canife-main/FLSim/flsim/utils/tests/helpers/test_data_utils.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import math import string from typing import Tuple import torch from flsim.data.data_pr...
10,136
32.127451
89
py
canife
canife-main/FLSim/flsim/utils/tests/helpers/test_models.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Iterable import torch import torch.nn as nn from flsim.utils.fl.pers...
2,069
26.6
84
py
canife
canife-main/FLSim/flsim/utils/tests/helpers/test_utils.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from typing import Any, List, Optional import torch import torch.nn as nn from flsim.da...
7,948
41.058201
88
py
canife
canife-main/FLSim/flsim/utils/data/dummy_image_dataset.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. from io import BytesIO import numpy as np import torch import torch.utils.data as data ...
1,550
27.2
80
py
canife
canife-main/FLSim/flsim/utils/data/data_utils.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import hashlib import time from collections import defaultdict from itertools import zip...
1,519
28.803922
81
py