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 |
|---|---|---|---|---|---|---|
canife | canife-main/FLSim/flsim/data/dataset_data_loader.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, Iterable, Optional, Type
import torch
from flsim.data.data_shar... | 5,180 | 36.007143 | 88 | py |
canife | canife-main/FLSim/flsim/data/data_sharder.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 random
from collections import def... | 9,419 | 31.595156 | 89 | py |
canife | canife-main/FLSim/flsim/data/csv_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.
import abc
from typing import Any, Dict
# see https://fb.workplace.com/groups/fbcode/pe... | 2,048 | 36.944444 | 85 | py |
canife | canife-main/FLSim/flsim/data/tests/test_dataset_dataloader_with_batch.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
import pkg_resources
import pytest
import torch
from flsim... | 2,385 | 33.085714 | 85 | py |
canife | canife-main/FLSim/flsim/data/tests/test_data_sharder.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 random
import string
import torch
from flsim.common.pytest_helper im... | 8,266 | 37.451163 | 88 | py |
canife | canife-main/FLSim/flsim/reducers/base_round_reducer.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 round aggregator for a
federated learning se... | 9,022 | 30.996454 | 99 | py |
canife | canife-main/FLSim/flsim/reducers/weighted_dp_round_reducer.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 enum import I... | 6,955 | 34.309645 | 113 | py |
canife | canife-main/FLSim/flsim/reducers/dp_round_reducer.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 itertools imp... | 5,737 | 37.510067 | 99 | py |
canife | canife-main/FLSim/flsim/reducers/tests/test_round_reducer.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 dataclasses import dataclass
from tempfile import mkstemp
from typing i... | 31,593 | 36.837126 | 101 | py |
canife | canife-main/FLSim/flsim/interfaces/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
from typing import Any
import torch.nn as nn
from flsim.interfaces.batch_met... | 903 | 22.179487 | 71 | py |
canife | canife-main/FLSim/flsim/interfaces/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.
import abc
from dataclasses import dataclass
from omegaconf import MISSING
from torch.u... | 611 | 22.538462 | 77 | py |
canife | canife-main/FLSim/flsim/interfaces/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.
import abc
from typing import Any, List
import torch
class IFLBatchMetrics(abc.ABC):
... | 1,165 | 23.808511 | 77 | py |
canife | canife-main/FLSim/flsim/interfaces/metrics_reporter.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
from enum import Enum, auto
from typing import Any, Dict, List, Optional, Tup... | 6,163 | 34.022727 | 88 | py |
canife | canife-main/FLSim/flsim/metrics_reporter/tensorboard_metrics_reporter.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 Any, Dict, List, Optional, Tuple
from flsim.c... | 6,621 | 34.794595 | 87 | py |
canife | canife-main/FLSim/flsim/trainers/private_sync_trainer.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... | 5,085 | 35.589928 | 155 | py |
canife | canife-main/FLSim/flsim/trainers/sync_trainer.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
import math
import random
from datacl... | 27,170 | 39.67515 | 103 | py |
canife | canife-main/FLSim/flsim/trainers/canary_sync_trainer.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
import math
import random
import sys
fro... | 55,148 | 52.96184 | 436 | py |
canife | canife-main/FLSim/flsim/trainers/trainer_base.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
import sys
from dataclasse... | 12,995 | 37.449704 | 108 | py |
canife | canife-main/FLSim/flsim/trainers/tests/test_trainer.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 json
import math
from typing import List
import flsim.configs # noq... | 45,123 | 37.143702 | 123 | py |
canife | canife-main/FLSim/flsim/trainers/tests/test_async_trainer.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
import numpy as np
import pytest
import torch
from f... | 42,209 | 40.260997 | 114 | py |
canife | canife-main/FLSim/flsim/trainers/tests/test_async_trainer_weights.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
from typing import Tuple
import numpy as np
import torch
from flsim.common.... | 24,683 | 39.8 | 98 | py |
canife | canife-main/FLSim/flsim/trainers/tests/test_fedbuff.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 Enum
from typing import Union
import numpy as np
import torch
from fls... | 33,542 | 38.369718 | 123 | py |
canife | canife-main/FLSim/examples/canary_example.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 json
import os
import random
from typing import Any, Iterator... | 27,165 | 35.910326 | 180 | py |
canife | canife-main/FLSim/examples/old_examples/cifar10_example.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.
"""In this tutorial, we will train an image classifier with FLSim to simulate a federate... | 5,090 | 32.715232 | 155 | py |
canife | canife-main/FLSim/examples/old_examples/sent140_example.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.
"""In this tutorial, we will train a binary sentiment classifier on LEAF's Sent140 datas... | 8,178 | 31.585657 | 102 | py |
canife | canife-main/FLSim/examples/old_examples/celeba_example.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.
"""In this tutorial, we will train a binary classifier on LEAF's CelebA dataset with FLS... | 9,128 | 36.72314 | 180 | py |
scotchcorner | scotchcorner-master/docs/conf.py | # -*- coding: utf-8 -*-
#
# scotchcorner documentation build configuration file, created by
# sphinx-quickstart on Fri Feb 5 22:03:30 2016.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
... | 9,968 | 31.90099 | 92 | py |
SCSS_OFDMArchitecture | SCSS_OFDMArchitecture-main/dfswave_kernel_waveunet.py | import os, sys
from tqdm import tqdm
import numpy as np
import random
import torch
from torch.utils.data import TensorDataset, DataLoader
from torch import optim
from pytorch_lightning import Trainer, seed_everything
from asteroid.engine import System
import asteroid
from pytorch_lightning.callbacks.early_stopping im... | 2,145 | 30.558824 | 265 | py |
SCSS_OFDMArchitecture | SCSS_OFDMArchitecture-main/syncdfswave_train_models.py | import os, sys
from tqdm import tqdm
import numpy as np
import random
import torch
from torch.utils.data import TensorDataset, DataLoader
from torch import optim
from pytorch_lightning import Trainer, seed_everything
from asteroid.engine import System
import asteroid
from pytorch_lightning.callbacks.early_stopping im... | 2,642 | 29.732558 | 258 | py |
SCSS_OFDMArchitecture | SCSS_OFDMArchitecture-main/realexpwave_gendata.py | import os, sys
from tqdm import tqdm
import numpy as np
import random
import torch
from torch.utils.data import TensorDataset, DataLoader
from torch import optim
from pytorch_lightning import Trainer, seed_everything
from asteroid.engine import System
import asteroid
from pytorch_lightning.callbacks.early_stopping im... | 2,338 | 26.845238 | 109 | py |
SCSS_OFDMArchitecture | SCSS_OFDMArchitecture-main/waveunet.py | import torch
import torch.nn as nn
# Adapted from https://github.com/f90/Wave-U-Net-Pytorch
class InterpolationLayer(nn.Module):
def __init__(self, n_ch, interp_kernel_size=5):
super(InterpolationLayer, self).__init__()
self.interp_kernel_size = interp_kernel_size
self.interp_filter = nn.Co... | 2,747 | 44.04918 | 161 | py |
SCSS_OFDMArchitecture | SCSS_OFDMArchitecture-main/realexpwave_diffreq_gendata.py | import os, sys
from tqdm import tqdm
import numpy as np
import random
import torch
from torch.utils.data import TensorDataset, DataLoader
from torch import optim
from pytorch_lightning import Trainer, seed_everything
from asteroid.engine import System
import asteroid
from pytorch_lightning.callbacks.early_stopping im... | 2,384 | 30.8 | 116 | py |
hap.py | hap.py-master/src/python/Tools/fastasize.py | # coding=utf-8
#
# Copyright (c) 2010-2015 Illumina, Inc.
# All rights reserved.
#
# This file is distributed under the simplified BSD license.
# The full text can be found here (and in LICENSE.txt in the root folder of
# this distribution):
#
# https://github.com/Illumina/licenses/blob/master/Simplified-BSD-License.tx... | 2,667 | 25.156863 | 109 | py |
DisPFL | DisPFL-master/fedml_core/trainer/model_trainer.py | from abc import ABC, abstractmethod
import torch
from fedml_api.utils.main_flops_counter import count_training_flops, count_inference_flops
class ModelTrainer(ABC):
"""Abstract base class for federated learning trainer.
1. The goal of this abstract class is to be compatible to
any deep learning fr... | 1,789 | 28.833333 | 105 | py |
DisPFL | DisPFL-master/fedml_core/robustness/robust_aggregation.py | import torch
def vectorize_weight(state_dict):
weight_list = []
for (k, v) in state_dict.items():
if is_weight_param(k):
weight_list.append(v)
return torch.cat(weight_list)
def load_model_weight_diff(local_state_dict, weight_diff, global_state_dict):
"""
load rule: w_t + clip... | 2,135 | 37.142857 | 106 | py |
DisPFL | DisPFL-master/fedml_api/standalone/fedavg/set_client.py | import copy
import logging
import math
import numpy as np
import torch
class Client:
def __init__(self, client_idx, local_training_data, local_test_data, local_sample_number, args, device,
model_trainer):
self.client_idx = client_idx
self.local_training_data = local_training_data... | 3,981 | 42.758242 | 129 | py |
DisPFL | DisPFL-master/fedml_api/standalone/fedavg/my_model_trainer.py | import copy
import logging
import time
import pdb
import numpy as np
import torch
from torch import nn
from fedml_api.model.cv.cnn_meta import Meta_net
try:
from fedml_core.trainer.model_trainer import ModelTrainer
except ImportError:
from FedML.fedml_core.trainer.model_trainer import ModelTrainer
class MyMo... | 3,391 | 32.584158 | 180 | py |
DisPFL | DisPFL-master/fedml_api/standalone/fedavg/client.py | import copy
import logging
import math
import time
import pdb
import numpy as np
import torch
class Client:
def __init__(self, client_idx, local_training_data, local_test_data, local_sample_number, args, device,
model_trainer, logger):
self.logger = logger
self.client_idx = client... | 2,298 | 42.377358 | 123 | py |
DisPFL | DisPFL-master/fedml_api/standalone/fedavg/fedavg_api.py | import copy
import logging
import pickle
import random
import pdb
import numpy as np
import torch
from fedml_api.standalone.fedavg.client import Client
class FedAvgAPI(object):
def __init__(self, dataset, device, args, model_trainer, logger):
self.logger = logger
self.device = device
self... | 9,644 | 47.959391 | 144 | py |
DisPFL | DisPFL-master/fedml_api/standalone/dpsgd/set_client.py | import copy
import logging
import math
import numpy as np
import torch
class Client:
def __init__(self, client_idx, local_training_data, local_test_data, local_sample_number, args, device,
model_trainer):
self.client_idx = client_idx
self.local_training_data = local_training_data... | 3,981 | 42.758242 | 129 | py |
DisPFL | DisPFL-master/fedml_api/standalone/dpsgd/my_model_trainer.py | import copy
import logging
import time
import numpy as np
import torch
from torch import nn
from fedml_api.model.cv.cnn_meta import Meta_net
import pdb
try:
from fedml_core.trainer.model_trainer import ModelTrainer
except ImportError:
from FedML.fedml_core.trainer.model_trainer import ModelTrainer
class My... | 4,676 | 36.119048 | 182 | py |
DisPFL | DisPFL-master/fedml_api/standalone/dpsgd/client.py | import copy
import logging
import math
import time
import pdb
import numpy as np
import torch
class Client:
def __init__(self, client_idx, local_training_data, local_test_data, local_sample_number, args, device,
model_trainer, logger):
self.client_idx = client_idx
self.local_train... | 2,490 | 43.482143 | 123 | py |
DisPFL | DisPFL-master/fedml_api/standalone/dpsgd/dpsgd_api.py | import copy
import logging
import pickle
import random
import numpy as np
import torch
import pdb
from fedml_api.standalone.dpsgd.client import Client
class DPSGDAPI(object):
def __init__(self, dataset, device, args, model_trainer, logger):
self.logger = logger
self.device = device
self.... | 12,519 | 46.424242 | 144 | py |
DisPFL | DisPFL-master/fedml_api/standalone/subavg/my_model_trainer.py | import copy
import logging
import time
import numpy as np
import torch
from torch import nn
from fedml_api.model.cv.cnn_meta import Meta_net
from fedml_api.standalone.subavg.prune_func import fake_prune
try:
from fedml_core.trainer.model_trainer import ModelTrainer
except ImportError:
from FedML.fedml_core.t... | 4,296 | 36.692982 | 179 | py |
DisPFL | DisPFL-master/fedml_api/standalone/subavg/prune_func.py | import copy
import logging
import numpy as np
import torch
from scipy.spatial import distance
def fake_prune( each_prune_ratio, param_dict, mask):
'''
This function derives the new pruning mask, it put 0 for the weights under the given percentile
:param percent: pruning percent
:param model: a pytor... | 2,895 | 31.909091 | 115 | py |
DisPFL | DisPFL-master/fedml_api/standalone/subavg/client.py | import copy
import logging
import math
import pdb
import numpy as np
import torch
from fedml_api.standalone.subavg.prune_func import dist_masks, real_prune, print_pruning
class Client:
def __init__(self, client_idx, local_training_data, local_test_data, local_sample_number, args, device,
model_... | 3,283 | 41.649351 | 123 | py |
DisPFL | DisPFL-master/fedml_api/standalone/subavg/subavg_api.py | import copy
import logging
import math
import pickle
import random
import numpy as np
import torch
# import wandb
from fedml_api.standalone.DisPFL.slim_util import model_difference
from fedml_api.standalone.subavg.client import Client
class SubAvgAPI(object):
def __init__(self, dataset, device, args, model_trai... | 11,665 | 46.230769 | 144 | py |
DisPFL | DisPFL-master/fedml_api/standalone/local/my_model_trainer.py | import copy
import logging
import time
import numpy as np
import torch
from torch import nn
from fedml_api.model.cv.cnn_meta import Meta_net
try:
from fedml_core.trainer.model_trainer import ModelTrainer
except ImportError:
from FedML.fedml_core.trainer.model_trainer import ModelTrainer
class MyModelTraine... | 3,406 | 32.732673 | 180 | py |
DisPFL | DisPFL-master/fedml_api/standalone/local/local_api.py | import copy
import logging
import pickle
import random
import numpy as np
import torch
from fedml_api.standalone.local.client import Client
class LocalAPI(object):
def __init__(self, dataset, device, args, model_trainer, logger):
self.device = device
self.args = args
self.logger = logger... | 10,680 | 48.221198 | 185 | py |
DisPFL | DisPFL-master/fedml_api/standalone/local/client.py | import copy
import logging
import math
import time
import pdb
import numpy as np
import torch
class Client:
def __init__(self, client_idx, local_training_data, local_test_data, local_sample_number, args, device,
model_trainer, logger):
self.logger = logger
self.client_idx = client... | 2,349 | 40.22807 | 157 | py |
DisPFL | DisPFL-master/fedml_api/standalone/DisPFL/slim_util.py | import copy
import logging
import numpy as np
import torch
import pdb
def cosine_annealing(args, round):
return args.anneal_factor / 2 * (1 + np.cos((round * np.pi) / args.comm_round))
def model_difference(model_a, model_b):
a = sum([torch.sum(torch.square(model_a[name] - model_b[name])) for name in model_a])... | 542 | 26.15 | 89 | py |
DisPFL | DisPFL-master/fedml_api/standalone/DisPFL/my_model_trainer.py | import copy
import logging
import time
import numpy as np
import pdb
import torch
from torch import nn
from fedml_api.model.cv.cnn_meta import Meta_net
try:
from fedml_core.trainer.model_trainer import ModelTrainer
except ImportError:
from fedml_core.trainer.model_trainer import ModelTrainer
class MyModelT... | 8,412 | 39.061905 | 180 | py |
DisPFL | DisPFL-master/fedml_api/standalone/DisPFL/client.py | import copy
import logging
import math
import numpy as np
import pdb
import torch
class Client:
def __init__(self, client_idx, local_training_data, local_test_data, local_sample_number, args, device,
model_trainer, logger):
self.logger = logger
self.client_idx = client_idx
... | 5,274 | 46.954545 | 163 | py |
DisPFL | DisPFL-master/fedml_api/standalone/DisPFL/dispfl_api.py | import copy
import logging
import math
import pickle
import random
import time
import pdb
import numpy as np
import torch
from fedml_api.standalone.DisPFL import client
from fedml_api.standalone.DisPFL.client import Client
from fedml_api.standalone.DisPFL.slim_util import model_difference
from fedml_api.standalone.Di... | 17,669 | 52.708207 | 205 | py |
DisPFL | DisPFL-master/fedml_api/standalone/ditto/ditto_api.py | import copy
import logging
import pickle
import random
import numpy as np
import torch
from fedml_api.standalone.ditto.client import Client
class DittoAPI(object):
def __init__(self, dataset, device, args, model_trainer, logger):
self.logger = logger
self.device = device
self.args = args... | 8,485 | 47.770115 | 144 | py |
DisPFL | DisPFL-master/fedml_api/standalone/ditto/my_model_trainer.py | import copy
import logging
import time
import numpy as np
import torch
from torch import nn
from fedml_api.model.cv.cnn_meta import Meta_net
try:
from fedml_core.trainer.model_trainer import ModelTrainer
except ImportError:
from FedML.fedml_core.trainer.model_trainer import ModelTrainer
class MyModelTraine... | 4,545 | 34.24031 | 180 | py |
DisPFL | DisPFL-master/fedml_api/standalone/ditto/client.py | import copy
import logging
import math
import time
import numpy as np
import torch
class Client:
def __init__(self, client_idx, local_training_data, local_test_data, local_sample_number, args, device,
model_trainer, logger):
self.logger = logger
self.client_idx = client_idx
... | 2,477 | 40.3 | 148 | py |
DisPFL | DisPFL-master/fedml_api/standalone/turboaggregate/TA_trainer.py | import copy
import logging
import torch
import wandb
from torch import nn
from fedml_api.standalone.turboaggregate.TA_client import TA_Client
class TurboAggregateTrainer(object):
def __init__(self, dataset, model, device, args):
self.device = device
self.args = args
[train_data_num, tes... | 7,177 | 39.325843 | 112 | py |
DisPFL | DisPFL-master/fedml_api/standalone/turboaggregate/TA_client.py | import logging
from torch import nn
from fedml_api.standalone.fedavg.client import Client
class TA_Client(Client):
def __init__(self, local_training_data, local_test_data, local_sample_number, args, device, client_idx):
self.local_training_data = local_training_data
self.local_test_data = local_... | 777 | 27.814815 | 108 | py |
DisPFL | DisPFL-master/fedml_api/standalone/fedfomo/fedfomo_api.py | import copy
import logging
import pickle
import random
import numpy as np
import torch
import pdb
from fedml_api.standalone.fedfomo.client import Client
class FEDFOMOAPI(object):
def __init__(self, dataset, device, args, model_trainer,logger):
self.logger = logger
self.device = device
se... | 17,531 | 48.385915 | 178 | py |
DisPFL | DisPFL-master/fedml_api/standalone/fedfomo/set_client.py | import copy
import logging
import math
import numpy as np
import torch
class Client:
def __init__(self, client_idx, local_training_data, local_test_data, local_sample_number, args, device,
model_trainer):
self.client_idx = client_idx
self.local_training_data = local_training_data... | 3,981 | 42.758242 | 129 | py |
DisPFL | DisPFL-master/fedml_api/standalone/fedfomo/my_model_trainer.py | import copy
import logging
import time
import numpy as np
import torch
from torch import nn
from fedml_api.model.cv.cnn_meta import Meta_net
try:
from fedml_core.trainer.model_trainer import ModelTrainer
except ImportError:
from FedML.fedml_core.trainer.model_trainer import ModelTrainer
class MyModelTraine... | 3,498 | 32.644231 | 180 | py |
DisPFL | DisPFL-master/fedml_api/standalone/fedfomo/fedfomo_api_my.py | import copy
import logging
import pickle
import random
import numpy as np
import torch
import pdb
from fedml_api.standalone.fedfomo.client import Client
class FEDFOMOAPI(object):
def __init__(self, dataset, device, args, model_trainer,logger):
self.logger = logger
self.device = device
se... | 17,531 | 48.385915 | 178 | py |
DisPFL | DisPFL-master/fedml_api/standalone/fedfomo/client.py | import copy
import logging
import math
import time
import numpy as np
import torch
class Client:
def __init__(self, client_idx, local_training_data, local_test_data, local_sample_number, args, device,
model_trainer, logger):
self.logger = logger
self.client_idx = client_idx
... | 3,067 | 42.828571 | 163 | py |
DisPFL | DisPFL-master/fedml_api/standalone/fedfomo/my_model_trainer_my.py | import copy
import logging
import time
import numpy as np
import torch
from torch import nn
from fedml_api.model.cv.cnn_meta import Meta_net
try:
from fedml_core.trainer.model_trainer import ModelTrainer
except ImportError:
from FedML.fedml_core.trainer.model_trainer import ModelTrainer
class MyModelTraine... | 3,498 | 32.644231 | 180 | py |
DisPFL | DisPFL-master/fedml_api/utils/main_flops_counter.py | import logging
import pdb
import numpy as np
import os
import torch
import torchvision
import torch.nn as nn
from torch.autograd import Variable
import torch.optim as optim
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.distributed as dist
import torch.optim
import torch.utils.data
import ... | 11,351 | 41.837736 | 142 | py |
DisPFL | DisPFL-master/fedml_api/model/cv/resnet_gn.py | import math
import torch.nn as nn
import torch.utils.model_zoo as model_zoo
__all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101',
'resnet152']
from fedml_api.model.cv.group_normalization import GroupNorm2d
model_urls = {
'resnet18': 'https://download.pytorch.org/models/resnet18-5c106c... | 7,765 | 31.90678 | 78 | py |
DisPFL | DisPFL-master/fedml_api/model/cv/group_normalization.py | import torch.nn.functional as F
from torch.nn.modules.batchnorm import _BatchNorm
"""Pytorch implementation of group normalization in https://arxiv.org/abs/1803.08494 (Following the PyTorch Style)"""
def group_norm(input, group, running_mean, running_var, weight=None, bias=None,
use_input_stats=True, ... | 5,019 | 41.184874 | 117 | py |
DisPFL | DisPFL-master/fedml_api/model/cv/cnn_cifar10.py | import copy
import logging
import math
import random
import numpy as np
import torch
from torch import nn
import torch.nn.functional as F
track_running_stats=False
class cnn_cifar10(nn.Module):
def __init__(self):
super(cnn_cifar10, self).__init__()
self.n_cls = 10
self.conv1 = torch.nn.Co... | 4,082 | 36.118182 | 90 | py |
DisPFL | DisPFL-master/fedml_api/model/cv/resnet.py | import torch
from torch import Tensor
import torch.nn as nn
from typing import Type, Any, Callable, Union, List, Optional
from torch.hub import load_state_dict_from_url
import torch.nn.functional as F
import pdb
# 定义带两个卷积路径和一条捷径的残差基本块类
class BasicBlock(nn.Module):
expansion = 1
def __init__(self, in_planes, pl... | 14,688 | 44.47678 | 130 | py |
DisPFL | DisPFL-master/fedml_api/model/cv/cnn.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class CNN_OriginalFedAvg(torch.nn.Module):
"""The CNN model used in the original FedAvg paper:
"Communication-Efficient Learning of Deep Networks from Decentralized Data"
https://arxiv.org/abs/1602.05629.
The number of parameters when... | 7,132 | 41.458333 | 97 | py |
DisPFL | DisPFL-master/fedml_api/model/cv/vgg.py | '''
Modified from https://github.com/pytorch/vision.git
'''
import math
import torch.nn as nn
import torch.nn.init as init
__all__ = [
'VGG', 'vgg11',
]
class VGG(nn.Module):
def __init__(self, features, num_classes=10, init_weights=True):
super(VGG, self).__init__()
self.features = feature... | 2,500 | 28.77381 | 113 | py |
DisPFL | DisPFL-master/fedml_api/model/cv/lenet5.py | from torch import nn
import torch.nn.functional as F
class LeNet5(nn.Module):
"""LeNet-5 without padding in the first layer.
This is based on Caffe's implementation of Lenet-5 and is slightly different
from the vanilla LeNet-5. Note that the first layer does NOT have padding
and therefore inte... | 1,596 | 33.717391 | 83 | py |
DisPFL | DisPFL-master/fedml_api/model/cv/batchnorm_utils.py | import queue
import collections
import threading
import functools
import torch
import torch.nn.functional as F
from torch.nn.modules.batchnorm import _BatchNorm
from torch.nn.parallel._functions import ReduceAddCoalesced, Broadcast
from torch.nn.parallel.data_parallel import DataParallel
__all__ = ['FutureResult',... | 19,684 | 41.516199 | 117 | py |
DisPFL | DisPFL-master/fedml_api/model/cv/cnn_meta.py | import copy
import logging
import math
import random
import numpy as np
import torch
from sklearn.decomposition import PCA
from torch import nn
import torch.nn.functional as F
class cnn_cifar10_meta(nn.Module):
# def random_growth(self, i, new_mask, weight):
# size = new_mask.size()
# new_ma... | 6,833 | 37.610169 | 134 | py |
DisPFL | DisPFL-master/fedml_api/model/cv/resnet_ip.py | '''
ResNet for CIFAR-10/100 Dataset.
Reference:
1. https://github.com/pytorch/vision/blob/master/torchvision/models/resnet.py
2. https://github.com/facebook/fb.resnet.torch/blob/master/models/resnet.lua
3. Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun
Deep Residual Learning for Image Recognition. https://arxiv.org... | 15,398 | 41.775 | 137 | py |
DisPFL | DisPFL-master/fedml_api/model/cv/resnet_meta.py | '''
ResNet for CIFAR-10/100 Dataset.
Reference:
1. https://github.com/pytorch/vision/blob/master/torchvision/models/resnet.py
2. https://github.com/facebook/fb.resnet.torch/blob/master/models/resnet.lua
3. Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun
Deep Residual Learning for Image Recognition. https://arxiv.org... | 6,931 | 32.326923 | 110 | py |
DisPFL | DisPFL-master/fedml_api/model/cv/resnet_meta_2.py | import torch
import torch.nn as nn
import torch.utils.model_zoo as model_zoo
import torch.nn.functional as F
stage_repeat = [2, 2, 2]
channel_scale = []
for i in range(31):
channel_scale += [(10 + i * 3)/100]
def conv3x3(in_planes, out_planes, stride=1):
"""3x3 convolution with padding"""
return nn.Conv2... | 6,700 | 33.188776 | 129 | py |
DisPFL | DisPFL-master/fedml_api/model/cv/darts/architect.py | import logging
from collections import OrderedDict
import numpy as np
import torch
from torch.autograd import Variable
def _concat(xs):
return torch.cat([x.view(-1) for x in xs])
class Architect(object):
def __init__(self, model, criterion, args, device):
self.network_momentum = args.momentum
... | 16,729 | 41.569975 | 119 | py |
DisPFL | DisPFL-master/fedml_api/model/cv/darts/utils.py | import os
import shutil
import numpy as np
import torch
from torch.autograd import Variable
class AvgrageMeter(object):
def __init__(self):
self.reset()
def reset(self):
self.avg = 0
self.sum = 0
self.cnt = 0
def update(self, val, n=1):
self.sum += val * n
... | 2,574 | 24.49505 | 109 | py |
DisPFL | DisPFL-master/fedml_api/model/cv/darts/model.py | import torch
import torch.nn as nn
from fedml_api.model.cv.darts.operations import FactorizedReduce, ReLUConvBN, OPS, Identity
from fedml_api.model.cv.darts.utils import drop_path
class Cell(nn.Module):
def __init__(self, genotype, C_prev_prev, C_prev, C, reduction, reduction_prev):
super(Cell, self).__... | 7,653 | 34.271889 | 96 | py |
DisPFL | DisPFL-master/fedml_api/model/cv/darts/model_search_gdas.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from fedml_api.model.cv.darts.genotypes import PRIMITIVES, Genotype
from fedml_api.model.cv.darts.operations import OPS, FactorizedReduce, ReLUConvBN
class MixedOp(nn.Module):
def __init__(self, C, stride):
super(MixedOp, self).__init__(... | 6,703 | 34.470899 | 119 | py |
DisPFL | DisPFL-master/fedml_api/model/cv/darts/model_search.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from fedml_api.model.cv.darts.genotypes import PRIMITIVES, Genotype
from fedml_api.model.cv.darts.operations import OPS, FactorizedReduce, ReLUConvBN
from fedml_api.model.cv.darts.utils import count_parameters_in_MB
class MixedOp(nn.Module):
def... | 11,490 | 36.429967 | 119 | py |
DisPFL | DisPFL-master/fedml_api/model/cv/darts/train_search.py | import argparse
import glob
import logging
import os
import sys
import time
import numpy as np
import torch
import torch.backends.cudnn as cudnn
import torch.nn as nn
import torch.nn.functional as F
import torch.utils
import torchvision.datasets as dset
import wandb
from fedml_api.model.cv.darts import utils
from fed... | 13,489 | 41.689873 | 140 | py |
DisPFL | DisPFL-master/fedml_api/model/cv/darts/train.py | import argparse
import glob
import logging
import os
import sys
import time
import numpy as np
import torch
import torch.backends.cudnn as cudnn
import torch.nn as nn
import torch.utils
import torchvision.datasets as dset
import wandb
from fedml_api.model.cv.darts import utils
from fedml_api.model.cv.darts import Net... | 8,494 | 38.511628 | 112 | py |
DisPFL | DisPFL-master/fedml_api/model/cv/darts/operations.py | import torch
import torch.nn as nn
OPS = {
'none': lambda C, stride, affine: Zero(stride),
'avg_pool_3x3': lambda C, stride, affine: nn.AvgPool2d(3, stride=stride, padding=1, count_include_pad=False),
'max_pool_3x3': lambda C, stride, affine: nn.MaxPool2d(3, stride=stride, padding=1),
'skip_connect': l... | 3,993 | 35.981481 | 116 | py |
DisPFL | DisPFL-master/fedml_api/data_preprocessing/tiny_imagenet/data_val_loader.py | import logging
import math
import pdb
import numpy as np
import torch
import random
import torch.utils.data as data
import torchvision.transforms as transforms
from .datasets import tiny_truncated, tiny
def record_net_data_stats(y_train, net_dataidx_map, logger):
net_cls_counts = []
for net_i, dataidx in ... | 14,774 | 44.183486 | 200 | py |
DisPFL | DisPFL-master/fedml_api/data_preprocessing/tiny_imagenet/data_loader.py | import logging
import math
import pdb
import numpy as np
import torch
import random
import torch.utils.data as data
import torchvision.transforms as transforms
from .datasets import tiny, tiny_truncated
def record_net_data_stats(y_train, net_dataidx_map):
net_cls_counts = []
for net_i, dataidx in net_data... | 14,042 | 43.160377 | 181 | py |
DisPFL | DisPFL-master/fedml_api/data_preprocessing/tiny_imagenet/datasets.py | import logging
import pdb
import numpy as np
import torch.utils.data as data
from PIL import Image
from PIL import Image
import os
import os.path
import pickle
import torch
import torchvision
from typing import Any, Callable, Optional, Tuple
# from .vision import VisionDataset
# from .utils import check_integrity, do... | 9,388 | 33.645756 | 256 | py |
DisPFL | DisPFL-master/fedml_api/data_preprocessing/cifar10/data_val_loader.py | import logging
import math
import pdb
import numpy as np
import torch
import random
import torch.utils.data as data
import torchvision.transforms as transforms
from torchvision.datasets import CIFAR10
from .datasets import CIFAR10_truncated
def record_net_data_stats(y_train, net_dataidx_map, logger):
net_cls_c... | 14,875 | 44.492355 | 200 | py |
DisPFL | DisPFL-master/fedml_api/data_preprocessing/cifar10/data_loader.py | import logging
import math
import pdb
import numpy as np
import torch
import random
import torch.utils.data as data
import torchvision.transforms as transforms
from torchvision.datasets import CIFAR10
from .datasets import CIFAR10_truncated
def record_net_data_stats(y_train, net_dataidx_map):
net_cls_counts = []
... | 11,307 | 44.232 | 181 | py |
DisPFL | DisPFL-master/fedml_api/data_preprocessing/cifar10/datasets.py | import logging
import pdb
import numpy as np
import torch.utils.data as data
from PIL import Image
from torchvision.datasets import CIFAR100, CIFAR10
# IMG_EXTENSIONS = ('.jpg', '.jpeg', '.png', '.ppm', '.bmp', '.pgm', '.tif', '.tiff', '.webp')
#
#
# def accimage_loader(path):
# import accimage
# try:
# ... | 2,777 | 28.870968 | 131 | py |
DisPFL | DisPFL-master/fedml_api/data_preprocessing/cifar100/data_val_loader.py | import logging
import math
import random
import numpy as np
import torch
import torch.utils.data as data
import torchvision.transforms as transforms
from torchvision.datasets import CIFAR100
import pdb
from .datasets import CIFAR100_truncated
def record_net_data_stats(y_train, net_dataidx_map, logger):
net_cls_co... | 14,829 | 44.913313 | 200 | py |
DisPFL | DisPFL-master/fedml_api/data_preprocessing/cifar100/data_loader.py | import logging
import math
import random
import numpy as np
import torch
import torch.utils.data as data
import torchvision.transforms as transforms
from torchvision.datasets import CIFAR100
import pdb
from .datasets import CIFAR100_truncated
def record_net_data_stats(y_train, net_dataidx_map, logger):
net_cls_co... | 11,428 | 43.29845 | 182 | py |
DisPFL | DisPFL-master/fedml_api/data_preprocessing/cifar100/datasets.py | import logging
import numpy as np
import torch.utils.data as data
from PIL import Image
from torchvision.datasets import CIFAR100
IMG_EXTENSIONS = ('.jpg', '.jpeg', '.png', '.ppm', '.bmp', '.pgm', '.tif', '.tiff', '.webp')
class CIFAR100_truncated(data.Dataset):
def __init__(self, root, cache_data_set=None,d... | 2,082 | 28.338028 | 131 | py |
DisPFL | DisPFL-master/fedml_experiments/standalone/fedavg/main_fedavg.py | import argparse
import logging
import os
import random
import sys
import pdb
import numpy as np
import torch
sys.path.insert(0, os.path.abspath("/gdata/dairong/DisPFL/"))
from fedml_api.model.cv.vgg import vgg11
from fedml_api.data_preprocessing.cifar10.data_loader import load_partition_data_cifar10
from fedml_api.dat... | 8,561 | 43.827225 | 141 | py |
DisPFL | DisPFL-master/fedml_experiments/standalone/dpsgd/main_dpsgd.py | import argparse
import logging
import os
import random
import sys
import numpy as np
import torch
import pdb
sys.path.insert(0, os.path.abspath("/gdata/dairong/DisPFL/"))
from fedml_api.model.cv.vgg import vgg11
from fedml_api.model.cv.lenet5 import LeNet5
from fedml_api.data_preprocessing.cifar10.data_loader import ... | 8,754 | 43.897436 | 141 | py |
DisPFL | DisPFL-master/fedml_experiments/standalone/subavg/main_subavg.py |
import argparse
import logging
import os
import random
import sys
import numpy as np
import torch
sys.path.insert(0, os.path.abspath("/gdata/dairong/DisPFL/"))
from fedml_api.model.cv.vgg import vgg11, vgg16
from fedml_api.model.cv.lenet5 import LeNet5
from fedml_api.standalone.subavg.subavg_api import SubAvgAPI
fr... | 9,420 | 43.649289 | 141 | py |
DisPFL | DisPFL-master/fedml_experiments/standalone/local/main_local.py | import argparse
import logging
import os
import random
import sys
import numpy as np
import torch
sys.path.insert(0, os.path.abspath("/gdata/dairong/DisPFL/"))
from fedml_api.model.cv.vgg import vgg11, vgg16
from fedml_api.standalone.local.local_api import LocalAPI
from fedml_api.data_preprocessing.cifar10.data_loade... | 8,755 | 43.673469 | 141 | py |
DisPFL | DisPFL-master/fedml_experiments/standalone/DisPFL/main_dispfl.py | import argparse
import logging
import os
import random
import sys
import pdb
import numpy as np
import torch
# sys.path.insert(0, os.path.abspath(os.path.join(os.getcwd(), "../../../")))
sys.path.insert(0, os.path.abspath("/gdata/dairong/DisPFL/"))
from fedml_api.data_preprocessing.cifar100.data_loader import load_pa... | 9,979 | 41.649573 | 141 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.