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 |
|---|---|---|---|---|---|---|
PySyft | PySyft-master/packages/syft/examples/duet/super_resolution/original/main.py | # future
from __future__ import print_function
# stdlib
import argparse
from math import log10
# third party
from model import Net
import torch
import torch.nn as nn
import torch.optim as optim
from torch.utils.data import DataLoader
from data import get_test_set # isort:skip
from data import get_training_set # is... | 3,372 | 25.769841 | 87 | py |
PySyft | PySyft-master/packages/syft/examples/duet/super_resolution/original/model.py | # third party
import torch
import torch.nn as nn
import torch.nn.init as init
class Net(nn.Module):
def __init__(self, upscale_factor):
super(Net, self).__init__()
self.relu = nn.ReLU()
self.conv1 = nn.Conv2d(1, 64, (5, 5), (1, 1), (2, 2))
self.conv2 = nn.Conv2d(64, 64, (3, 3), (1... | 1,074 | 32.59375 | 79 | py |
PySyft | PySyft-master/packages/syft/examples/duet/super_resolution/original/dataset.py | # stdlib
from os import listdir
from os.path import join
# third party
from PIL import Image
import torch.utils.data as data
def is_image_file(filename):
return any(filename.endswith(extension) for extension in [".png", ".jpg", ".jpeg"])
def load_img(filepath):
img = Image.open(filepath).convert("YCbCr")
... | 1,128 | 25.880952 | 87 | py |
PySyft | PySyft-master/packages/syft/examples/duet/super_resolution/original/data.py | # stdlib
from os import makedirs
from os import remove
from os.path import basename
from os.path import exists
from os.path import join
import tarfile
# third party
from six.moves import urllib
from torchvision.transforms import CenterCrop
from torchvision.transforms import Compose
from torchvision.transforms import R... | 2,238 | 24.443182 | 97 | py |
PySyft | PySyft-master/packages/syft/examples/duet/super_resolution/original/super_resolve.py | # future
from __future__ import print_function
# stdlib
import argparse
# third party
from PIL import Image
import numpy as np
import torch
from torchvision.transforms import ToTensor
# Training settings
parser = argparse.ArgumentParser(description="PyTorch Super Res Example")
parser.add_argument("--input_image", ty... | 1,378 | 27.729167 | 88 | py |
PySyft | PySyft-master/packages/syft/examples/duet/word_language_model/original/main.py | # coding: utf-8
# stdlib
import argparse
import math
import os
import time
# third party
import torch
import torch.nn as nn
import torch.onnx
import data # isort:skip
import model # isort:skip
parser = argparse.ArgumentParser(
description="PyTorch Wikitext-2 RNN/LSTM/GRU/Transformer Language Model"
)
parser.ad... | 10,608 | 30.763473 | 97 | py |
PySyft | PySyft-master/packages/syft/examples/duet/word_language_model/original/generate.py | ###############################################################################
# Language Modeling on Wikitext-2
#
# This file generates new sentences sampled from the language model
#
###############################################################################
# stdlib
import argparse
# third party
import torch
... | 3,193 | 30.313725 | 88 | py |
PySyft | PySyft-master/packages/syft/examples/duet/word_language_model/original/model.py | # stdlib
import math
# third party
import torch
import torch.nn as nn
import torch.nn.functional as F
class RNNModel(nn.Module):
"""Container module with an encoder, a recurrent module, and a decoder."""
def __init__(
self, rnn_type, ntoken, ninp, nhid, nlayers, dropout=0.5, tie_weights=False
):... | 6,701 | 36.441341 | 110 | py |
PySyft | PySyft-master/packages/syft/examples/duet/word_language_model/original/data.py | # stdlib
from io import open
import os
# third party
import torch
class Dictionary(object):
def __init__(self):
self.word2idx = {}
self.idx2word = []
def add_word(self, word):
if word not in self.word2idx:
self.idx2word.append(word)
self.word2idx[word] = len(s... | 1,507 | 27.45283 | 67 | py |
PySyft | PySyft-master/packages/syft/examples/duet/vae/original/main.py | # future
from __future__ import print_function
# stdlib
import argparse
# third party
import torch
from torch import nn
from torch import optim
from torch.nn import functional as F
import torch.utils.data
from torchvision import datasets
from torchvision import transforms
from torchvision.utils import save_image
par... | 5,114 | 27.416667 | 83 | py |
PySyft | PySyft-master/packages/syft/examples/duet/mnist/send_tensor.py | # stdlib
import multiprocessing as mp
from multiprocessing import Process
import time
# third party
import torch as th
mp.set_start_method("spawn", force=True)
# Make sure to run the local network.py server first:
#
# $ syft-network
#
def do() -> None:
# syft absolute
import syft as sy
_ = sy.logger.a... | 1,472 | 21.318182 | 77 | py |
PySyft | PySyft-master/packages/syft/examples/duet/mnist/original/main.py | # future
from __future__ import print_function
# stdlib
import argparse
# third party
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.optim.lr_scheduler import StepLR
from torchvision import datasets
from torchvision import transforms
class Net(nn.Module):
... | 5,772 | 28.304569 | 88 | py |
PySyft | PySyft-master/packages/syft/examples/duet/fast_neural_style/original/download_saved_models.py | # stdlib
import os
import zipfile
# PyTorch 1.1 moves _download_url_to_file
# from torch.utils.model_zoo to torch.hub
# PyTorch 1.0 exists another _download_url_to_file
# 2 argument
# TODO: If you remove support PyTorch 1.0 or older,
# You should remove torch.utils.model_zoo
# Ref. PyTorch #18758
# ... | 1,041 | 26.421053 | 75 | py |
PySyft | PySyft-master/packages/syft/examples/duet/fast_neural_style/original/neural_style/neural_style.py | # stdlib
import argparse
import os
import re
import sys
import time
# third party
import numpy as np
import torch
import torch.onnx
from torch.optim import Adam
from torch.utils.data import DataLoader
from torchvision import datasets
from torchvision import transforms
from transformer_net import TransformerNet
import ... | 10,786 | 29.908309 | 134 | py |
PySyft | PySyft-master/packages/syft/examples/duet/fast_neural_style/original/neural_style/vgg.py | # stdlib
from collections import namedtuple
# third party
import torch
from torchvision import models
class Vgg16(torch.nn.Module):
def __init__(self, requires_grad=False):
super(Vgg16, self).__init__()
vgg_pretrained_features = models.vgg16(pretrained=True).features
self.slice1 = torch.n... | 1,416 | 31.953488 | 72 | py |
PySyft | PySyft-master/packages/syft/examples/duet/fast_neural_style/original/neural_style/transformer_net.py | # third party
import torch
class TransformerNet(torch.nn.Module):
def __init__(self):
super(TransformerNet, self).__init__()
# Initial convolution layers
self.conv1 = ConvLayer(3, 32, kernel_size=9, stride=1)
self.in1 = torch.nn.InstanceNorm2d(32, affine=True)
self.conv2 = ... | 3,826 | 36.15534 | 86 | py |
PySyft | PySyft-master/packages/syft/examples/duet/fast_neural_style/original/neural_style/utils.py | # third party
from PIL import Image
import torch
def load_image(filename, size=None, scale=None):
img = Image.open(filename)
if size is not None:
img = img.resize((size, size), Image.ANTIALIAS)
elif scale is not None:
img = img.resize(
(int(img.size[0] / scale), int(img.size[1]... | 1,018 | 25.815789 | 81 | py |
PySyft | PySyft-master/packages/syft/examples/pygrid/tutorials/diabetes_model_training.py | # stdlib
from typing import Any
from typing import List as TypeList
from typing import Tuple as TypeTuple
from typing import Union as TypeUnion
# third party
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from sklearn.preprocessing import StandardScaler
import torch
from torch import nn
from to... | 4,199 | 28.166667 | 85 | py |
PySyft | PySyft-master/packages/syft/src/syft/__init__.py | """
Welcome to the syft package! This package is the primary package for PySyft.
This package has two kinds of attributes: submodules and convenience functions.
Submodules are configured in the standard way, but the convenience
functions exist to allow for a convenient `import syft as sy` to then expose
the most-used f... | 4,944 | 45.650943 | 114 | py |
PySyft | PySyft-master/packages/syft/src/syft/core/node/common/action/run_class_method_action.py | # stdlib
import functools
from typing import Any
from typing import Dict
from typing import List
from typing import Optional
# third party
from google.protobuf.reflection import GeneratedProtocolMessageType
from nacl.signing import VerifyKey
# syft absolute
from syft.core.plan.plan import Plan
# syft relative
from .... | 12,676 | 37.531915 | 95 | py |
PySyft | PySyft-master/packages/syft/src/syft/core/plan/__init__.py | """
plan exports
"""
# syft relative
from .plan import Plan # noqa: 401
from .translation.torchscript.plan import PlanTorchscript # noqa: 401
| 144 | 19.714286 | 70 | py |
PySyft | PySyft-master/packages/syft/src/syft/core/plan/translation/torchscript/plan_translate.py | # stdlib
from collections import OrderedDict
from typing import Any
from typing import Dict as TypeDict
from typing import List as TypeList
from typing import Optional
# third party
import torch as th
# syft relative
from .....core.node.common.client import Client
from .....core.store import ObjectStore
from .....lib... | 4,254 | 33.04 | 97 | py |
PySyft | PySyft-master/packages/syft/src/syft/core/plan/translation/torchscript/plan.py | # stdlib
import io
from typing import Any
from typing import Optional
# third party
from google.protobuf.reflection import GeneratedProtocolMessageType
from syft_proto.execution.v1.plan_pb2 import Plan as Plan_PB
import torch as th
# syft relative
from .....core.common.object import Serializable
from .....logger impo... | 2,722 | 31.807229 | 95 | py |
PySyft | PySyft-master/packages/syft/src/syft/core/common/serde/serializable.py | # stdlib
from typing import Any
from typing import Type
# third party
from google.protobuf.message import Message
from google.protobuf.reflection import GeneratedProtocolMessageType
# syft relative
from ....logger import traceback_and_raise
from ....util import random_name
def bind_protobuf(cls: Any) -> Any:
pr... | 6,074 | 35.160714 | 102 | py |
PySyft | PySyft-master/packages/syft/src/syft/core/remote_dataloader/remote_dataloader.py | # stdlib
from typing import Any
from typing import Iterator
from typing import Union
# third party
from google.protobuf.reflection import GeneratedProtocolMessageType
import torch as th
from torch.utils.data import DataLoader
from torch.utils.data import Dataset
# syft relative
from ... import deserialize
from ... im... | 3,987 | 32.79661 | 90 | py |
PySyft | PySyft-master/packages/syft/src/syft/ast/util.py | # -*- coding: utf-8 -*-
"""This module contains utility funtions for Syft's AST submodule."""
# stdlib
from typing import List as TypeList
# third party
import torch
module_type = type(torch)
func_type = type(lambda x: x)
builtin_func_type = type(torch.ones)
class_type = type(func_type)
def unsplit(list_of_things:... | 666 | 23.703704 | 83 | py |
PySyft | PySyft-master/packages/syft/src/syft/proto/lib/numpy/array_pb2.py | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: proto/lib/numpy/array.proto
"""Generated protocol buffer code."""
# third party
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _re... | 4,898 | 29.055215 | 313 | py |
PySyft | PySyft-master/packages/syft/src/syft/proto/lib/torch/device_pb2.py | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: proto/lib/torch/device.proto
"""Generated protocol buffer code."""
# third party
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _r... | 2,931 | 28.029703 | 181 | py |
PySyft | PySyft-master/packages/syft/src/syft/proto/lib/torch/module_pb2.py | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: proto/lib/torch/module.proto
"""Generated protocol buffer code."""
# third party
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _r... | 9,054 | 32.913858 | 774 | py |
PySyft | PySyft-master/packages/syft/src/syft/proto/lib/torch/tensor_pb2.py | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: proto/lib/torch/tensor.proto
"""Generated protocol buffer code."""
# third party
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _r... | 17,427 | 32.13308 | 1,246 | py |
PySyft | PySyft-master/packages/syft/src/syft/proto/lib/torch/parameter_pb2.py | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: proto/lib/torch/parameter.proto
"""Generated protocol buffer code."""
# third party
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as... | 5,014 | 31.564935 | 410 | py |
PySyft | PySyft-master/packages/syft/src/syft/proto/lib/torch/size_pb2.py | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: proto/lib/torch/size.proto
"""Generated protocol buffer code."""
# third party
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _ref... | 3,277 | 28.267857 | 243 | py |
PySyft | PySyft-master/packages/syft/src/syft/proto/lib/torch/returntypes_pb2.py | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: proto/lib/torch/returntypes.proto
"""Generated protocol buffer code."""
# third party
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection ... | 3,393 | 29.854545 | 253 | py |
PySyft | PySyft-master/packages/syft/src/syft/proto/lib/sympc/share_tensor_pb2.py | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: proto/lib/sympc/share_tensor.proto
"""Generated protocol buffer code."""
# third party
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection... | 4,359 | 31.537313 | 361 | py |
PySyft | PySyft-master/packages/syft/src/syft/proto/lib/sympc/replicatedshared_tensor_pb2.py | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: proto/lib/sympc/replicatedshared_tensor.proto
"""Generated protocol buffer code."""
# third party
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import... | 4,582 | 33.201493 | 389 | py |
PySyft | PySyft-master/packages/syft/src/syft/federated/model_centric_fl_worker.py | # stdlib
import base64
import secrets
from timeit import timeit
from typing import Any as TypeAny
from typing import Dict as TypeDict
from typing import Generator
from typing import List as TypeList
from typing import Union
# third party
import requests
from syft_proto.execution.v1.plan_pb2 import Plan as PlanTorchscr... | 7,214 | 34.195122 | 88 | py |
PySyft | PySyft-master/packages/syft/src/syft/federated/model_centric_fl_client.py | # syft relative
from ..federated import JSONDict
from ..federated.model_centric_fl_base import ModelCentricFLBase
from ..lib.python import List
from ..lib.torch.module import Module as SyModule
from ..proto.core.plan.plan_pb2 import Plan
from .model_serialization import deserialize_model_params
from .model_serializatio... | 2,193 | 34.387097 | 76 | py |
PySyft | PySyft-master/packages/syft/src/syft/federated/model_serialization/state.py | # stdlib
from typing import List
# third party
from google.protobuf.reflection import GeneratedProtocolMessageType
from syft_proto.execution.v1.state_pb2 import State as StatePB
from syft_proto.execution.v1.state_tensor_pb2 import StateTensor as StateTensorPB
# syft relative
from ...core.common.object import Serializ... | 4,232 | 36.131579 | 95 | py |
PySyft | PySyft-master/packages/syft/src/syft/federated/model_serialization/placeholder.py | # stdlib
from typing import Optional
from typing import Set
from typing import Tuple
from typing import Union
# third party
from google.protobuf.reflection import GeneratedProtocolMessageType
from syft_proto.execution.v1.placeholder_pb2 import Placeholder as PlaceholderPB
import torch as th
# syft relative
from ...co... | 5,058 | 34.131944 | 95 | py |
PySyft | PySyft-master/packages/syft/src/syft/federated/model_serialization/common.py | # stdlib
from typing import Any
from typing import Union
# third party
from syft_proto.types.torch.v1.tensor_data_pb2 import TensorData as TensorData_PB
from syft_proto.types.torch.v1.tensor_pb2 import TorchTensor as TorchTensor_PB
import torch as th
# Torch dtypes to string (and back) mappers
TORCH_DTYPE_STR = {
... | 3,550 | 29.350427 | 84 | py |
PySyft | PySyft-master/packages/syft/src/syft/lib/util.py | # stdlib
import inspect
from types import ModuleType
from typing import Callable
from typing import Optional
from typing import Union
from typing import Union as TypeUnion
# syft relative
from ..ast.globals import Globals
from ..core.node.abstract.node import AbstractNodeClient
# this gets called on global ast as wel... | 5,666 | 33.554878 | 114 | py |
PySyft | PySyft-master/packages/syft/src/syft/lib/__init__.py | # stdlib
import importlib
import sys
from types import ModuleType
from typing import Any
from typing import Any as TypeAny
from typing import Dict as TypeDict
from typing import Iterable
from typing import List as TypeList
from typing import Optional
from typing import Set as TypeSet
from typing import Tuple as TypeTup... | 8,648 | 34.739669 | 98 | py |
PySyft | PySyft-master/packages/syft/src/syft/lib/PIL/image.py | # third party
import PIL
import numpy as np
import torch
import torchvision
# syft relative
from ...generate_wrapper import GenerateWrapper
from ...lib.torch.tensor_util import protobuf_tensor_deserializer
from ...lib.torch.tensor_util import protobuf_tensor_serializer
from ...proto.lib.torch.tensor_pb2 import TensorD... | 1,002 | 26.861111 | 76 | py |
PySyft | PySyft-master/packages/syft/src/syft/lib/plan/__init__.py | # stdlib
from typing import Any as TypeAny
from typing import List as TypeList
from typing import Tuple as TypeTuple
# syft relative
from ...ast import add_classes
from ...ast import add_methods
from ...ast import add_modules
from ...ast.globals import Globals
from ...core.plan.plan import Plan
from ...core.plan.trans... | 1,625 | 24.40625 | 69 | py |
PySyft | PySyft-master/packages/syft/src/syft/lib/numpy/array.py | # third party
import numpy as np
import pyarrow as pa
import torch
# syft relative
from ...experimental_flags import flags
from ...generate_wrapper import GenerateWrapper
from ...lib.torch.tensor_util import protobuf_tensor_deserializer
from ...lib.torch.tensor_util import protobuf_tensor_serializer
from ...proto.lib.... | 3,099 | 27.971963 | 85 | py |
PySyft | PySyft-master/packages/syft/src/syft/lib/opacus/__init__.py | # stdlib
import functools
from typing import Any as TypeAny
from typing import List as TypeList
from typing import Tuple as TypeTuple
# third party
import opacus
# syft relative
from ...ast import add_classes
from ...ast import add_methods
from ...ast import add_modules
from ...ast.globals import Globals
from ..util ... | 1,936 | 27.485294 | 85 | py |
PySyft | PySyft-master/packages/syft/src/syft/lib/torch/allowlist.py | # stdlib
from typing import Dict
from typing import Union
# syft relative
from ..misc.union import UnionGenerator
allowlist: Dict[str, Union[str, Dict[str, str]]] = {} # (path: str, return_type:type)
dynamic_allowlist: Dict[str, str] = {}
# ----------------------------------------------------------------------------... | 164,182 | 44.695241 | 103 | py |
PySyft | PySyft-master/packages/syft/src/syft/lib/torch/module.py | # stdlib
import ast
from collections import OrderedDict
import copy
import inspect
from itertools import islice
import os
from pathlib import Path
import sys
from typing import Any
from typing import Callable
from typing import Dict
from typing import Iterator
from typing import List
from typing import Optional
from ty... | 28,317 | 35.445302 | 107 | py |
PySyft | PySyft-master/packages/syft/src/syft/lib/torch/uppercase_tensor.py | # stdlib
# third party
import torch as th
# syft relative
from ...generate_wrapper import GenerateWrapper
from ...lib.torch.tensor_util import protobuf_tensor_deserializer
from ...lib.torch.tensor_util import protobuf_tensor_serializer
from ...logger import warning
from ...proto.lib.torch.device_pb2 import Device as ... | 2,047 | 29.117647 | 81 | py |
PySyft | PySyft-master/packages/syft/src/syft/lib/torch/size.py | # third party
import torch
# syft relative
from ...generate_wrapper import GenerateWrapper
from ...proto.lib.torch.size_pb2 import Size as TorchSize_PB
def protobuf_torch_size_serializer(torch_size: torch.Size) -> TorchSize_PB:
serialized_size = TorchSize_PB(data=torch_size)
return serialized_size
def prot... | 681 | 25.230769 | 77 | py |
PySyft | PySyft-master/packages/syft/src/syft/lib/torch/parameter.py | # stdlib
# third party
import torch as th
from torch.nn import Parameter
# syft relative
from ...generate_wrapper import GenerateWrapper
from ...lib.torch.tensor_util import protobuf_tensor_deserializer
from ...lib.torch.tensor_util import protobuf_tensor_serializer
from ...proto.lib.torch.parameter_pb2 import Parame... | 1,773 | 32.471698 | 75 | py |
PySyft | PySyft-master/packages/syft/src/syft/lib/torch/__init__.py | # stdlib
from typing import Any
from typing import Dict
from typing import Union
# third party
from packaging import version
import torch
# syft relative
from . import device # noqa: 401
from . import parameter # noqa: 401
from . import return_types # noqa: 401
from . import size # noqa: 401
from . import upperca... | 2,782 | 33.358025 | 88 | py |
PySyft | PySyft-master/packages/syft/src/syft/lib/torch/tensor_util.py | # third party
import torch as th
# syft relative
from ...proto.lib.torch.tensor_pb2 import TensorData
# Torch dtypes to string (and back) mappers
TORCH_DTYPE_STR = {
th.uint8: "uint8",
th.int8: "int8",
th.int16: "int16",
th.int32: "int32",
th.int64: "int64",
th.float16: "float16",
th.float... | 2,139 | 31.424242 | 84 | py |
PySyft | PySyft-master/packages/syft/src/syft/lib/torch/device.py | # stdlib
from typing import Any
from typing import Optional
# third party
from torch import device
# syft relative
from ...generate_wrapper import GenerateWrapper
from ...proto.lib.torch.device_pb2 import Device as Device_PB
# use -2 to represent index=None
INDEX_NONE = -2
def object2proto(obj: device) -> "Device_... | 844 | 21.837838 | 77 | py |
PySyft | PySyft-master/packages/syft/src/syft/lib/torch/return_types.py | # stdlib
import re
from typing import Any
from typing import Dict
from typing import List
# third party
from packaging import version
import torch
# syft relative
from ...generate_wrapper import GenerateWrapper
from ...lib.util import full_name_with_name
from ...proto.lib.torch.returntypes_pb2 import ReturnTypes as R... | 4,001 | 29.318182 | 95 | py |
PySyft | PySyft-master/packages/syft/src/syft/lib/python/dict.py | # stdlib
from collections import UserDict
from collections.abc import ItemsView
from collections.abc import KeysView
from collections.abc import ValuesView
from typing import Any
from typing import Dict as TypeDict
from typing import Iterable
from typing import Optional
from typing import Union
# third party
from goog... | 8,223 | 34.296137 | 92 | py |
PySyft | PySyft-master/packages/syft/src/syft/lib/python/__init__.py | # stdlib
from typing import Optional
# syft relative
from . import collections
from ...ast import add_classes
from ...ast import add_dynamic_objects
from ...ast import add_methods
from ...ast import add_modules
from ...ast.globals import Globals
from ...core.node.abstract.node import AbstractNodeClient
from ..misc.uni... | 31,373 | 53 | 86 | py |
PySyft | PySyft-master/packages/syft/src/syft/lib/python/tuple.py | # stdlib
from typing import Any
from typing import Optional
from typing import Union
# third party
from google.protobuf.reflection import GeneratedProtocolMessageType
# syft relative
from ... import deserialize
from ... import serialize
from ...core.common import UID
from ...core.common.serde.serializable import bind... | 4,462 | 33.867188 | 88 | py |
PySyft | PySyft-master/packages/syft/src/syft/lib/python/collections/ordered_dict.py | # stdlib
from collections import OrderedDict as PyOrderedDict
from collections.abc import ItemsView
from collections.abc import KeysView
from collections.abc import ValuesView
from typing import Any
from typing import Optional
# third party
from google.protobuf.reflection import GeneratedProtocolMessageType
# syft re... | 7,405 | 36.979487 | 92 | py |
PySyft | PySyft-master/packages/syft/src/syft/lib/xgboost/__init__.py | """Partial-dependency library, runs when user loads xgboost.
__init__ file for sklearn. This defines various modules, classes and methods which we currently support.
We create an AST for all these modules, classes and methods so that they can be called remotely.
"""
# stdlib
import functools
from typing import Any as ... | 3,168 | 33.445652 | 105 | py |
PySyft | PySyft-master/packages/syft/src/syft/lib/torchvision/allowlist.py | # stdlib
from typing import Dict
from typing import Union
# (path: str, return_type:type)
allowlist: Dict[str, Union[str, Dict[str, str]]] = {}
allowlist["torchvision.__version__"] = "syft.lib.python.String"
# MNIST
allowlist["torchvision.transforms.Compose"] = "torchvision.transforms.Compose"
# allowlist["torchvisio... | 11,436 | 43.158301 | 90 | py |
PySyft | PySyft-master/packages/syft/src/syft/lib/torchvision/__init__.py | # stdlib
from typing import Any
from typing import Dict
from typing import Union
# third party
from packaging import version
import torchvision as tv
# syft relative
from ...ast.globals import Globals
from ...logger import critical
from .allowlist import allowlist
TORCHVISION_VERSION = version.parse(tv.__version__)
... | 1,758 | 29.327586 | 87 | py |
PySyft | PySyft-master/packages/syft/src/syft/lib/pytorch_lightning/__init__.py | # stdlib
import functools
from typing import Any as TypeAny
from typing import List as TypeList
from typing import Tuple as TypeTuple
# third party
import pytorch_lightning as pl
# syft relative
from ...ast import add_classes
from ...ast import add_methods
from ...ast import add_modules
from ...ast.globals import Glo... | 1,871 | 27.8 | 80 | py |
PySyft | PySyft-master/packages/syft/src/syft/lib/tensor/tensorbase.py | # stdlib
from functools import partial
from typing import Any
from typing import List
from typing import Union
# third party
import numpy as np
import torch
# syft absolute
from syft.lib.tensor.tensorbase_util import call_func_and_wrap_result
Num = Union[int, float]
class ChildDelegatorTensor:
def __getattr__(... | 6,078 | 35.620482 | 88 | py |
PySyft | PySyft-master/packages/syft/src/syft/lib/misc/__init__.py | # stdlib
from collections import defaultdict
import sys
from typing import Any as TypeAny
from typing import Callable
from typing import Dict
from typing import KeysView
from typing import List as TypeList
from typing import Set
# third party
from cachetools import cached
from cachetools.keys import hashkey
# syft re... | 6,168 | 38.544872 | 111 | py |
PySyft | PySyft-master/packages/syft/src/syft/lib/remote_dataloader/__init__.py | # stdlib
from typing import Any as TypeAny
from typing import List as TypeList
from typing import Tuple as TypeTuple
# syft relative
from ...ast import add_classes
from ...ast import add_methods
from ...ast import add_modules
from ...ast.globals import Globals
from ...core.remote_dataloader import RemoteDataLoader
fro... | 2,078 | 29.130435 | 88 | py |
PySyft | PySyft-master/packages/syft/src/syft/lib/sympc/share.py | # stdlib
# stdlib
import dataclasses
from uuid import UUID
# third party
import sympc
from sympc.config import Config
from sympc.tensor import ShareTensor
# syft absolute
import syft
# syft relative
from ...generate_wrapper import GenerateWrapper
from ...lib.torch.tensor_util import protobuf_tensor_deserializer
fro... | 2,083 | 26.786667 | 84 | py |
PySyft | PySyft-master/packages/syft/src/syft/lib/sympc/__init__.py | """add the sympc library into syft."""
# stdlib
import functools
from typing import Any as TypeAny
from typing import List as TypeList
from typing import Tuple as TypeTuple
# syft relative
from . import rst_share # noqa: 401
from . import session # noqa: 401
from . import share # noqa: 401
from ...ast import add_c... | 1,652 | 24.430769 | 88 | py |
PySyft | PySyft-master/packages/syft/src/syft/lib/sympc/rst_share.py | # stdlib
import dataclasses
from uuid import UUID
# third party
import sympc
from sympc.config import Config
from sympc.tensor import ReplicatedSharedTensor
# syft absolute
import syft
# syft relative
from ...generate_wrapper import GenerateWrapper
from ...lib.torch.tensor_util import protobuf_tensor_deserializer
fr... | 2,164 | 27.116883 | 87 | py |
PySyft | PySyft-master/packages/syft/scripts/adjust_torch_versions.py | # stdlib
import platform
import re
import sys
from typing import Any
from typing import Dict
# third party
from packaging import version
VERSIONS_NONE: Dict[str, Any] = dict(torchvision=None, torchcsprng=None)
VERSIONS_LUT: Dict[str, Dict[str, Any]] = {
"1.4.0": dict(torchvision="0.5.0", torchcsprng=None),
"1... | 1,754 | 28.25 | 72 | py |
PySyft | PySyft-master/packages/syft/scripts/autofix_allowlist_test.py | # stdlib
import glob
import json
import os
from pathlib import Path
import re
import shutil
from typing import Any
from typing import Pattern
# third party
import jsonlines
import torch
torch_version = torch.__version__
# --------------------------------------
# add exception and it's handler
# ----------------------... | 11,319 | 32.690476 | 111 | py |
PySyft | PySyft-master/packages/syft/scripts/mnist.py | """
Warm the MNIST cache: https://github.com/pytorch/vision/issues/1938
"""
# third party
from packaging import version
import torchvision
# syft absolute
from syft.util import get_root_data_path
# https://github.com/pytorch/vision/issues/3549
TORCHVISION_VERSION = version.parse(torchvision.__version__)
if TORCHVISIO... | 1,087 | 28.405405 | 76 | py |
PySyft | PySyft-master/packages/syft/tests/conftest.py | # stdlib
import logging
from multiprocessing import Process
import socket
from time import time
from typing import Any as TypeAny
from typing import Dict as TypeDict
from typing import Generator
from typing import List as TypeList
# third party
import _pytest
import pytest
# syft absolute
import syft as sy
from syft ... | 6,056 | 32.464088 | 86 | py |
PySyft | PySyft-master/packages/syft/tests/stress/gc_test.py | # stdlib
import gc
# third party
import pytest
import torch
# syft absolute
import syft as sy
@pytest.mark.slow
def test_same_var_for_ptr_gc(
node: sy.VirtualMachine, client: sy.VirtualMachineClient
) -> None:
"""
Test for checking if the gc is correctly triggered
when the last reference to the ptr ... | 1,166 | 19.12069 | 65 | py |
PySyft | PySyft-master/packages/syft/tests/syft/core/node/common/service/resolve_pointer_type_test.py | # stdlib
import operator
from typing import Callable
from typing import List
from typing import Tuple
# third party
import pytest
import torch
# syft absolute
import syft as sy
@pytest.fixture()
def inputs() -> Tuple[int, float, bool, torch.Tensor]:
return (1, 1.5, True, torch.Tensor([1, 2, 3]))
@pytest.fixtu... | 2,068 | 31.328125 | 88 | py |
PySyft | PySyft-master/packages/syft/tests/syft/core/node/common/service/obj_search_permission_service_test.py | # third party
import torch as th
# syft absolute
import syft as sy
from syft.core.node.common.service.obj_search_permission_service import (
ImmediateObjectSearchPermissionUpdateService,
)
from syft.core.node.common.service.obj_search_permission_service import (
ObjectSearchPermissionUpdateMessage,
)
def tes... | 2,601 | 29.611765 | 87 | py |
PySyft | PySyft-master/packages/syft/tests/syft/core/node/common/action/function_or_constructor_action_test.py | # third party
import torch as th
# syft absolute
import syft as sy
from syft.core.common.uid import UID
from syft.core.node.common.action.function_or_constructor_action import (
RunFunctionOrConstructorAction,
)
# TODO test execution
# TODO test permissions
def test_run_function_or_constructor_action_serde(
... | 1,094 | 25.071429 | 105 | py |
PySyft | PySyft-master/packages/syft/tests/syft/core/node/common/action/save_object_action_test.py | # third party
import torch as th
# syft absolute
import syft as sy
from syft import serialize
from syft.core.common.uid import UID
from syft.core.io.address import Address
from syft.core.io.location import SpecificLocation
from syft.core.node.common.action.save_object_action import SaveObjectAction
from syft.core.stor... | 864 | 27.833333 | 76 | py |
PySyft | PySyft-master/packages/syft/tests/syft/core/node/domain/domain_test.py | # third party
import pytest
import torch as th
# syft absolute
from syft.core.common.message import SyftMessage
from syft.core.node.domain import Domain
from syft.core.node.domain.service import RequestStatus
@pytest.mark.asyncio
async def test_domain_creation() -> None:
Domain(name="test domain")
@pytest.mark... | 3,161 | 24.918033 | 80 | py |
PySyft | PySyft-master/packages/syft/tests/syft/core/plan/planception_test.py | # stdlib
from typing import Any
from typing import List as TypeList
# third party
import numpy as np
import pytest
import torch as th
from torchvision import datasets
from torchvision import transforms
# syft absolute
import syft as sy
from syft import SyModule
from syft import SySequential
from syft import logger
fr... | 6,409 | 28.539171 | 94 | py |
PySyft | PySyft-master/packages/syft/tests/syft/core/plan/torchscript_test.py | # third party
import pytest
import torch as th
# syft absolute
import syft as sy
from syft import make_plan
from syft.core.plan.plan_builder import PLAN_BUILDER_VM
from syft.core.plan.plan_builder import ROOT_CLIENT
from syft.core.plan.translation.torchscript.plan_translate import translate
@pytest.mark.slow
def tes... | 4,424 | 31.536765 | 96 | py |
PySyft | PySyft-master/packages/syft/tests/syft/core/plan/plan_test.py | # stdlib
from typing import Any
from typing import Tuple as TypeTuple
# third party
import pytest
import torch as th
# syft absolute
import syft as sy
from syft import Plan
from syft import make_plan
from syft import serialize
from syft.core.common.uid import UID
from syft.core.io.address import Address
from syft.cor... | 11,141 | 30.653409 | 96 | py |
PySyft | PySyft-master/packages/syft/tests/syft/core/pointer/pointer_test.py | # stdlib
from io import StringIO
import sys
from typing import Any
from typing import List
# third party
import pytest
import torch as th
# syft absolute
import syft as sy
from syft.core.node.common.client import AbstractNodeClient
from syft.core.pointer.pointer import Pointer
def validate_output(data: Any, data_pt... | 6,660 | 27.465812 | 87 | py |
PySyft | PySyft-master/packages/syft/tests/syft/core/pointer/garbage_collection/gc_strategies_test.py | # third party
import torch
# syft absolute
import syft as sy
from syft.core.pointer.garbage_collection import GCBatched
from syft.core.pointer.garbage_collection import GCSimple
from syft.core.pointer.garbage_collection import GarbageCollection
from syft.core.pointer.garbage_collection import gc_get_default_strategy
f... | 2,262 | 23.597826 | 77 | py |
PySyft | PySyft-master/packages/syft/tests/syft/core/common/module_test.py | # stdlib
from typing import Any
from typing import List
from typing import Union
# third party
import torch as th
# syft absolute
import syft as sy
def test_module() -> None:
torch = sy.lib.torch.torch
nn = torch.nn
F = torch.nn.functional
# manually constructed Module with PyTorch external API
... | 4,659 | 31.361111 | 86 | py |
PySyft | PySyft-master/packages/syft/tests/syft/core/fl/model-centric/mcfl_create_execute_plan_test.py | # stdlib
import base64
from collections import OrderedDict
import json
import os
import time
from typing import Any
from typing import Dict as TypeDict
from typing import Generator
from typing import List as TypeList
from typing import Optional
from typing import Tuple as TypeTuple
from typing import Union as TypeUnion... | 21,163 | 29.89635 | 98 | py |
PySyft | PySyft-master/packages/syft/tests/syft/core/remote_dataloader/remote_dataloader_test.py | # stdlib
import os
# third party
import pytest
import torch as th
from torch.utils.data import Dataset
# syft absolute
import syft as sy
from syft.core.remote_dataloader import RemoteDataLoader
from syft.core.remote_dataloader import RemoteDataset
class ExampleDataset(Dataset):
def __init__(self, ten: th.Tensor... | 1,432 | 22.491803 | 73 | py |
PySyft | PySyft-master/packages/syft/tests/syft/core/store/dataset_object_test.py | # third party
import torch as th
# syft absolute
import syft as sy
from syft import serialize
from syft.core.common import UID
from syft.core.store.dataset import Dataset
from syft.core.store.storeable_object import StorableObject
def test_create_dataset_with_store_obj() -> None:
id = UID()
data = UID()
... | 8,534 | 30.378676 | 79 | py |
PySyft | PySyft-master/packages/syft/tests/syft/core/store/storable_object_test.py | # third party
import torch as th
# syft absolute
import syft as sy
from syft import serialize
from syft.core.common import UID
from syft.core.store.storeable_object import StorableObject
def test_create_storable_obj() -> None:
id = UID()
data = UID()
description = "This is a dummy test"
tags = ["dumm... | 1,622 | 27.473684 | 103 | py |
PySyft | PySyft-master/packages/syft/tests/syft/core/store/memory_storage_test.py | """In this test suite, we evaluate the MemoryStore class. For more info
on the MemoryStore class and its purpose, please see the documentation
in the class itself.
Table of Contents:
- INITIALIZATION: tests for ways MemoryStore can be initialized
- CLASS METHODS: tests for the use of MemoryStore's class method... | 4,485 | 25.544379 | 87 | py |
PySyft | PySyft-master/packages/syft/tests/syft/api/deprecated_test.py | # third party
import pytest
import torch as th
# syft absolute
import syft as sy
from syft.lib import load_lib
def test_searchable_pointable(root_client: sy.VirtualMachineClient) -> None:
with pytest.deprecated_call():
x_ptr = th.Tensor([1, 2, 3]).send(root_client, searchable=True)
assert x_ptr.poin... | 658 | 22.535714 | 76 | py |
PySyft | PySyft-master/packages/syft/tests/syft/grid/duet/duet_scenarios_tests/duet_torch_test.py | # stdlib
import sys
import time
def do_test(port: int) -> None:
# third party
import torch
# syft absolute
import syft as sy
sy.logger.add(sys.stderr, "ERROR")
duet = sy.launch_duet(loopback=True, network_url=f"http://127.0.0.1:{port}/")
duet.requests.add_handler(action="accept")
t... | 926 | 18.723404 | 81 | py |
PySyft | PySyft-master/packages/syft/tests/syft/grid/duet/duet_scenarios_tests/__init__.py | # stdlib
from typing import Callable
from typing import List
from typing import Tuple
# syft relative
from .duet_init_test import test_scenario_init
from .duet_sanity_test import test_scenario_sanity
from .duet_torch_test import test_scenario_torch_tensor_sanity
def register_duet_scenarios(
registered_tests: Lis... | 526 | 28.277778 | 62 | py |
PySyft | PySyft-master/packages/syft/tests/syft/lib/allowlist_test.py | """In this test suite, we load the allowlist.json and run through all the tests based
on what expected inputs and return types are provided by the json file.
"""
# stdlib
from itertools import product
import json
import os
from pathlib import Path
import platform
import random
import sys
import time
from typing import... | 32,964 | 40.465409 | 90 | py |
PySyft | PySyft-master/packages/syft/tests/syft/lib/allowlist_report.py | # stdlib
import glob
import json
import os
from pathlib import Path
import platform
import sys
from typing import Any
from typing import Dict
from typing import List
from typing import Union
# third party
from jinja2 import Template
from packaging import version
# this forces the import priority to use site-packages ... | 6,286 | 35.132184 | 88 | py |
PySyft | PySyft-master/packages/syft/tests/syft/lib/PIL/pil_test.py | # third party
import pytest
import torch
# syft absolute
import syft as sy
from syft.grid.duet.ui import LOGO_URL
PIL = pytest.importorskip("PIL")
np = pytest.importorskip("numpy")
sy.load("numpy", "PIL")
@pytest.mark.vendor(lib="PIL")
def test_send_and_get(root_client: sy.VirtualMachineClient) -> None:
im = P... | 999 | 26.777778 | 84 | py |
PySyft | PySyft-master/packages/syft/tests/syft/lib/opacus/opacus_test.py | # third party
import pytest
# syft absolute
import syft as sy
opacus = pytest.importorskip("opacus")
sy.load("opacus")
@pytest.mark.vendor(lib="opacus")
def test_remote_engine_simple(root_client: sy.VirtualMachineClient) -> None:
remote_opacus = root_client.opacus
remote_torch = root_client.torch
model... | 753 | 23.322581 | 76 | py |
PySyft | PySyft-master/packages/syft/tests/syft/lib/torch/size_test.py | # third party
import torch
# syft absolute
import syft as sy
def test_protobuf_torch_size_serializer_deserializer() -> None:
torch_size = torch.Size([4, 5, 2, 1])
torch_size_pb = sy.lib.torch.size.protobuf_torch_size_serializer(torch_size)
torch_size_deserialized = sy.lib.torch.size.protobuf_torch_size_d... | 675 | 28.391304 | 81 | py |
PySyft | PySyft-master/packages/syft/tests/syft/lib/torch/module_test.py | # stdlib
import copy
import os
from pathlib import Path
import time
from typing import Any
from typing import Tuple
# third party
import pytest
import torch
import torch as th
# syft absolute
import syft as sy
from syft import SyModule
from syft import SySequential
from syft.core.plan.plan import Plan
from syft.core.... | 10,383 | 26.183246 | 91 | py |
PySyft | PySyft-master/packages/syft/tests/syft/lib/torch/returntypes_test.py | # stdlib
from typing import Any
# third party
from packaging import version
import pytest
import torch
# syft absolute
import syft as sy
from syft.lib.torch.return_types import types_fields
A = torch.tensor([[1.0, 1, 1], [2, 3, 4], [3, 5, 2], [4, 2, 5], [5, 4, 3]])
B = torch.tensor([[-10.0, -3], [12, 14], [14, 12], ... | 2,571 | 22.814815 | 84 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.