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 |
|---|---|---|---|---|---|---|
dpcca | dpcca-master/models/pccaopt.py | """=============================================================================
Probabilistic canonical correlation analysis. For references in comments:
A Probabilistic Interpretation of Canonical Correlation Analysis.
Bach, Jordan (2006).
The EM algorithm for mixtures of factor analyzers.
Ghahraman... | 10,408 | 33.127869 | 80 | py |
dpcca | dpcca-master/models/pcca.py | """=============================================================================
Probabilistic canonical correlation analysis. For references in comments:
A Probabilistic Interpretation of Canonical Correlation Analysis.
Bach, Jordan (2006).
The EM algorithm for mixtures of factor analyzers.
Ghahraman... | 13,897 | 34.454082 | 80 | py |
dpcca | dpcca-master/models/lenet5ae.py | """=============================================================================
PyTorch implementation of LeNet-5. See:
http://yann.lecun.com/exdb/publis/pdf/lecun-98.pdf
============================================================================="""
import torch.nn as nn
import torch.nn.functional as F
# ----... | 2,184 | 33.140625 | 80 | py |
dpcca | dpcca-master/tests/test_neg_log_likelihood.py | """=============================================================================
Test that our vectorized implementation of the negative log-likelihood is
correct.
============================================================================="""
import numpy as np
import unittest
import torch
from models import PCCA... | 2,320 | 29.539474 | 80 | py |
dpcca | dpcca-master/tests/test_pos_psi.py | """=============================================================================
Test our function ensuring Psi is nonnegative works as expected.
============================================================================="""
import unittest
import torch
import linalg as LA
# ----------------------------------------... | 718 | 31.681818 | 80 | py |
dpcca | dpcca-master/tests/test_vectorized_sum_of_outer_products.py | """=============================================================================
Test that our implementation of a vectorized outer product is correct.
============================================================================="""
import torch
import unittest
# ------------------------------------------------------... | 1,105 | 31.529412 | 80 | py |
dpcca | dpcca-master/tests/test_em_Psi_diag_new.py | """=============================================================================
Test vectorized Psi_diag_new vs. simple Psi_diag_new.
============================================================================="""
import torch
import unittest
from models import PCCAVec, PCCASimple
import linalg as LA
# ---------... | 2,681 | 37.314286 | 80 | py |
dpcca | dpcca-master/tests/test_tiling_is_differentiable.py | """=============================================================================
Verify that my mental model of how PyTorch handles nn.Parameters is correct.
============================================================================="""
import unittest
from copy import deepcopy
import torch
from torch import nn... | 2,250 | 30.704225 | 80 | py |
dpcca | dpcca-master/tests/test_woodbury_inversion.py | """=============================================================================
Verify implementation of Woodbury matrix inversion.
============================================================================="""
import unittest
import numpy as np
import torch
import linalg
from tests.utils import relaxed_allclose... | 1,556 | 32.847826 | 80 | py |
dpcca | dpcca-master/tests/test_tile_params.py | """=============================================================================
Verify that parameter unrolling function is correct.
============================================================================="""
import unittest
import torch
from torch import nn
import cuda
from models import PCCAOpt
# ------... | 5,900 | 40.851064 | 81 | py |
dpcca | dpcca-master/tests/utils.py | """=============================================================================
Utility functions for unit testing.
============================================================================="""
import numpy as np
import torch
# ------------------------------------------------------------------------------
def re... | 1,925 | 34.666667 | 80 | py |
dpcca | dpcca-master/tests/test_pcca_end_to_end.py | """=============================================================================
Test PCCA model end-to-end.
============================================================================="""
import torch
import unittest
from models import PCCAVec, PCCASimple
# --------------------------------------------------------... | 1,926 | 34.036364 | 84 | py |
dpcca | dpcca-master/tests/test_diag_inversion.py | """=============================================================================
Verify matrix inversion of diagonal matrices is both fast and accurate.
============================================================================="""
import unittest
import time
import torch
import linalg
# --------------------------... | 1,009 | 27.857143 | 80 | py |
dpcca | dpcca-master/tests/test_em_step.py | """=============================================================================
Test vectorized EM vs. simple EM.
============================================================================="""
import torch
import unittest
from models import PCCASimple, PCCAVec, PCCAOpt
# ----------------------------------------... | 1,829 | 37.125 | 80 | py |
dpcca | dpcca-master/tests/test_em_Lambda_new.py | """=============================================================================
Test vectorized Lambda_new vs. simple Lambda_new.
============================================================================="""
import torch
import unittest
from models import PCCASimple, PCCAVec
import linalg as LA
# -------------... | 3,599 | 38.130435 | 80 | py |
dpcca | dpcca-master/tests/test_slice_is_differentiable.py | """=============================================================================
Verify PyTorch's slice functionality is differentiable as we expect.
============================================================================="""
import unittest
import torch
# --------------------------------------------------------... | 1,171 | 26.904762 | 80 | py |
dpcca | dpcca-master/data/loader.py | """=============================================================================
Dataset-agnostic data loader.
============================================================================="""
import math
import numpy as np
import random
from torch.utils.data.sampler import SubsetRandomSampler
from torch.utils.dat... | 3,094 | 33.010989 | 80 | py |
dpcca | dpcca-master/data/gtexv6/dataset.py | """=============================================================================
GTEx V6 data set of histology images and gene expression levels.
============================================================================="""
from sklearn import preprocessing
import torch
from torch.utils.data import Dataset
from... | 3,731 | 31.452174 | 80 | py |
dpcca | dpcca-master/data/gtexv6/config.py | """============================================================================
Configuration for the GTEx V6 data set.
============================================================================"""
import matplotlib.pyplot as plt
import numpy as np
import torch
from torchvision.utils import save_image
from mode... | 3,515 | 31.555556 | 80 | py |
dpcca | dpcca-master/data/mnist/generate.py | """=============================================================================
Script to generate multimodal MNIST dataset.
============================================================================="""
import numpy as np
import torch
from torch.distributions.multivariate_normal import MultivariateNormal
from ... | 3,107 | 28.046729 | 80 | py |
dpcca | dpcca-master/data/mnist/dataset.py | """=============================================================================
Multimodal MNIST data set.
============================================================================="""
import numpy as np
import torch
from torch.utils.data import Dataset
# --------------------------------------------------------... | 1,603 | 29.264151 | 80 | py |
dpcca | dpcca-master/data/mnist/config.py | """============================================================================
Configuration for the multimodal MNIST data set.
============================================================================"""
import matplotlib.pyplot as plt
import torch
from torchvision.utils import save_image
from data.config im... | 3,850 | 32.780702 | 80 | py |
FATE | FATE-master/examples/pipeline/homo_nn/pipeline_homo_nn_train_binary.py | #
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 3,330 | 34.817204 | 120 | py |
FATE | FATE-master/examples/pipeline/homo_nn/pipeline_homo_nn_train_regression.py | #
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 3,333 | 35.637363 | 120 | py |
FATE | FATE-master/examples/pipeline/homo_nn/pipeline_homo_nn_train_multi.py | #
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 3,628 | 37.2 | 120 | py |
FATE | FATE-master/examples/pipeline/homo_nn/pipeline_homo_nn_aggregate_n_epoch.py | #
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 3,357 | 35.107527 | 120 | py |
FATE | FATE-master/examples/pipeline/hetero_ftl/pipeline-hetero-ftl-with-predict.py | #
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 3,842 | 37.818182 | 103 | py |
FATE | FATE-master/examples/pipeline/hetero_ftl/pipeline-hetero-ftl-encrypted.py | #
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 3,286 | 38.60241 | 103 | py |
FATE | FATE-master/examples/pipeline/hetero_ftl/pipeline-hetero-ftl-communication-efficient.py | #
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 3,471 | 38.908046 | 103 | py |
FATE | FATE-master/examples/pipeline/hetero_ftl/pipeline-hetero-ftl-plain.py | #
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 3,282 | 38.554217 | 103 | py |
FATE | FATE-master/examples/pipeline/hetero_nn/pipeline-hetero-nn-train-binary-selective-bp.py | #
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 4,307 | 35.201681 | 117 | py |
FATE | FATE-master/examples/pipeline/hetero_nn/pipeline-hetero-nn-train-binary-drop-out.py | #
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 4,241 | 34.949153 | 116 | py |
FATE | FATE-master/examples/pipeline/hetero_nn/pipeline-hetero-nn-train-with-early-stop.py | #
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 5,533 | 39.101449 | 110 | py |
FATE | FATE-master/examples/pipeline/hetero_nn/pipeline-hetero-nn-train-binary.py | #
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 4,154 | 35.130435 | 116 | py |
FATE | FATE-master/examples/pipeline/hetero_nn/pipeline-hetero-nn-train-binary-coae.py | #
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 4,957 | 36.560606 | 118 | py |
FATE | FATE-master/examples/pipeline/hetero_nn/pipeline-hetero-nn-train-binary-multi-host.py | #
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 4,613 | 37.45 | 116 | py |
FATE | FATE-master/examples/pipeline/hetero_nn/pipeline-hetero-nn-train-with-check-point.py | #
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 4,374 | 35.458333 | 110 | py |
FATE | FATE-master/examples/pipeline/hetero_nn/pipeline-hetero-nn-train-with-warm_start.py | #
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 4,500 | 36.508333 | 117 | py |
FATE | FATE-master/examples/pipeline/hetero_nn/pipeline-hetero-nn-train-multi.py | #
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 4,593 | 37.283333 | 117 | py |
FATE | FATE-master/examples/pipeline/homo_graph/pipeline_homo_graph_sage.py | #
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 3,919 | 38.59596 | 117 | py |
FATE | FATE-master/examples/benchmark_quality/homo_nn/local-homo_nn.py | #
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 3,738 | 27.761538 | 76 | py |
FATE | FATE-master/examples/benchmark_quality/homo_nn/fate-homo_nn.py | #
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 7,460 | 34.870192 | 120 | py |
FATE | FATE-master/examples/benchmark_quality/hetero_nn/local-hetero_nn.py | import argparse
import numpy as np
import os
import pandas
from sklearn import metrics
from pipeline.utils.tools import JobConfig
import torch as t
from torch import nn
from pipeline import fate_torch_hook
from torch.utils.data import DataLoader, TensorDataset
from federatedml.nn.backend.utils.common import global_se... | 4,651 | 27.365854 | 79 | py |
FATE | FATE-master/examples/benchmark_quality/hetero_nn/fate-hetero_nn.py | #
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 7,650 | 32.853982 | 81 | py |
FATE | FATE-master/examples/benchmark_quality/hetero_nn_pytorch/local-hetero_nn.py | import argparse
import numpy as np
import os
from tensorflow import keras
import pandas
import tensorflow as tf
from tensorflow.keras.utils import to_categorical
from tensorflow.keras import optimizers
from sklearn import metrics
from pipeline.utils.tools import JobConfig
from sklearn.preprocessing import LabelEncoder
... | 4,792 | 30.741722 | 97 | py |
FATE | FATE-master/examples/benchmark_quality/hetero_nn_pytorch/fate-hetero_nn.py | import argparse
from collections import OrderedDict
from pipeline.backend.pipeline import PipeLine
from pipeline.component import DataTransform
from pipeline.component import HeteroNN
from pipeline.component import Intersection
from pipeline.component import Reader
from pipeline.component import Evaluation
from pipelin... | 6,139 | 40.768707 | 116 | py |
FATE | FATE-master/python/fate_test/fate_test/scripts/data_cli.py | import os
import re
import sys
import time
import uuid
import json
from datetime import timedelta
import click
from pathlib import Path
from ruamel import yaml
from fate_test import _config
from fate_test._config import Config
from fate_test._client import Clients
from fate_test._io import LOGGER, echo
from fate_test... | 19,039 | 43.176334 | 119 | py |
FATE | FATE-master/python/fate_client/setup.py | # -*- coding: utf-8 -*-
from setuptools import setup
packages = [
"flow_client",
"flow_client.flow_cli",
"flow_client.flow_cli.commands",
"flow_client.flow_cli.utils",
"flow_sdk",
"flow_sdk.client",
"flow_sdk.client.api",
"pipeline",
"pipeline.backend",
"pipeline.component",
... | 2,995 | 43.058824 | 1,418 | py |
FATE | FATE-master/python/fate_client/pipeline/__init__.py | try:
from pipeline.component.nn.backend.torch.import_hook import fate_torch_hook
from pipeline.component.nn.backend import torch as fate_torch
except ImportError:
fate_torch_hook, fate_torch = None, None
except ValueError:
fate_torch_hook, fate_torch = None, None
__all__ = ['fate_torch_hook', 'fate_tor... | 325 | 31.6 | 79 | py |
FATE | FATE-master/python/fate_client/pipeline/param/ftl_param.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/lic... | 7,810 | 47.216049 | 127 | py |
FATE | FATE-master/python/fate_client/pipeline/param/hetero_nn_param.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/lic... | 12,330 | 41.37457 | 139 | py |
FATE | FATE-master/python/fate_client/pipeline/param/boosting_param.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/lic... | 35,176 | 47.253772 | 134 | py |
FATE | FATE-master/python/fate_client/pipeline/param/homo_nn_param.py | from pipeline.param.base_param import BaseParam
class TrainerParam(BaseParam):
def __init__(self, trainer_name=None, **kwargs):
super(TrainerParam, self).__init__()
self.trainer_name = trainer_name
self.param = kwargs
def check(self):
if self.trainer_name is not None:
... | 2,340 | 31.971831 | 107 | py |
FATE | FATE-master/python/fate_client/pipeline/component/hetero_ftl.py | #
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 3,526 | 35.739583 | 95 | py |
FATE | FATE-master/python/fate_client/pipeline/component/homo_nn.py | #
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 8,452 | 41.691919 | 136 | py |
FATE | FATE-master/python/fate_client/pipeline/component/__init__.py | from pipeline.component.column_expand import ColumnExpand
from pipeline.component.data_statistics import DataStatistics
from pipeline.component.dataio import DataIO
from pipeline.component.data_transform import DataTransform
from pipeline.component.evaluation import Evaluation
from pipeline.component.hetero_data_split ... | 3,628 | 37.606383 | 141 | py |
FATE | FATE-master/python/fate_client/pipeline/component/hetero_nn.py | #
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 11,564 | 43.141221 | 134 | py |
FATE | FATE-master/python/fate_client/pipeline/component/nn/models/sequantial.py | #
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 3,465 | 34.731959 | 112 | py |
FATE | FATE-master/python/fate_client/pipeline/component/nn/models/keras_interface.py | #
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 2,295 | 28.435897 | 91 | py |
FATE | FATE-master/python/fate_client/pipeline/component/nn/backend/torch/import_hook.py | try:
from pipeline.component.nn.backend.torch import nn as nn_
from pipeline.component.nn.backend.torch import init as init_
from pipeline.component.nn.backend.torch import optim as optim_
from pipeline.component.nn.backend.torch.cust import CustModel, CustLoss
from pipeline.component.nn.backend.tor... | 1,920 | 36.666667 | 101 | py |
FATE | FATE-master/python/fate_client/pipeline/component/nn/backend/torch/base.py | import json
import torch as t
from torch.nn import Sequential as tSequential
from pipeline.component.nn.backend.torch.operation import OpBase
class FateTorchLayer(object):
def __init__(self):
t.nn.Module.__init__(self)
self.param_dict = dict()
self.initializer = {'weight': None, 'bias': N... | 4,209 | 26.880795 | 81 | py |
FATE | FATE-master/python/fate_client/pipeline/component/nn/backend/torch/optim.py | from torch import optim
from pipeline.component.nn.backend.torch.base import FateTorchOptimizer
class ASGD(optim.ASGD, FateTorchOptimizer):
def __init__(
self,
params=None,
lr=0.01,
lambd=0.0001,
alpha=0.75,
t0=1000000.0,
weight_decay=0,
foreach=Non... | 12,959 | 30.228916 | 118 | py |
FATE | FATE-master/python/fate_client/pipeline/component/nn/backend/torch/cust.py | from torch import nn
import importlib
from pipeline.component.nn.backend.torch.base import FateTorchLayer, FateTorchLoss
import difflib
MODEL_PATH = None
LOSS_PATH = None
def str_simi(str_a, str_b):
return difflib.SequenceMatcher(None, str_a, str_b).quick_ratio()
def get_class(module_name, class_name, param, ... | 4,188 | 36.738739 | 119 | py |
FATE | FATE-master/python/fate_client/pipeline/component/nn/backend/torch/init.py | import copy
import torch as t
from torch.nn import init as torch_init
import functools
from pipeline.component.nn.backend.torch.base import FateTorchLayer
from pipeline.component.nn.backend.torch.base import Sequential
str_init_func_map = {
"uniform": torch_init.uniform_,
"normal": torch_init.normal_,
"con... | 6,775 | 25.677165 | 89 | py |
FATE | FATE-master/python/fate_client/pipeline/component/nn/backend/torch/nn.py | from pipeline.component.nn.backend.torch.base import FateTorchLayer, FateTorchLoss
from pipeline.component.nn.backend.torch.base import Sequential
from torch import nn
class Bilinear(nn.modules.linear.Bilinear, FateTorchLayer):
def __init__(
self,
in1_features,
in2_features,
... | 81,792 | 32.412173 | 82 | py |
FATE | FATE-master/python/fate_client/pipeline/component/nn/backend/torch/interactive.py | import torch as t
from torch.nn import ReLU, Linear, LazyLinear, Tanh, Sigmoid, Dropout, Sequential
from pipeline.component.nn.backend.torch.base import FateTorchLayer
class InteractiveLayer(t.nn.Module, FateTorchLayer):
r"""A :class: InteractiveLayer.
An interface for InteractiveLayer. In interactive... | 5,522 | 34.178344 | 113 | py |
FATE | FATE-master/python/fate_client/pipeline/component/nn/backend/torch/__init__.py | try:
from pipeline.component.nn.backend.torch import nn, init, operation, optim, serialization
except ImportError:
nn, init, operation, optim, serialization = None, None, None, None, None
__all__ = ['nn', 'init', 'operation', 'optim', 'serialization']
| 261 | 36.428571 | 93 | py |
FATE | FATE-master/python/fate_client/pipeline/component/nn/backend/torch/operation.py | import torch
import torch as t
import copy
from torch.nn import Module
class OpBase(object):
def __init__(self):
self.param_dict = {}
def to_dict(self):
ret = copy.deepcopy(self.param_dict)
ret['op'] = type(self).__name__
return ret
class Astype(Module, OpBase):
def __... | 3,488 | 23.570423 | 89 | py |
FATE | FATE-master/python/fate_client/pipeline/component/nn/backend/torch/serialization.py | import copy
import inspect
from collections import OrderedDict
try:
from torch.nn import Sequential as tSeq
from pipeline.component.nn.backend.torch import optim, init, nn
from pipeline.component.nn.backend.torch import operation
from pipeline.component.nn.backend.torch.base import Sequential, get_torch... | 4,867 | 37.03125 | 100 | py |
FATE | FATE-master/python/fate_client/flow_client/flow_cli/commands/model.py | #
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 17,583 | 35.941176 | 120 | py |
FATE | FATE-master/python/federatedml/nn/model_zoo/graphsage.py | import torch as t
from torch import nn
from torch.nn import Module
import torch_geometric.nn as pyg
class Sage(nn.Module):
def __init__(self, in_channels, hidden_channels, class_num):
super().__init__()
self.model = nn.ModuleList([
pyg.SAGEConv(in_channels=in_channels, out_channels=hid... | 702 | 29.565217 | 94 | py |
FATE | FATE-master/python/federatedml/nn/model_zoo/homographsage.py |
import torch as t
from torch import nn
from torch.nn import Module
import torch_geometric.nn as pyg
class Sage(nn.Module):
def __init__(self, in_channels, hidden_channels, class_num):
super().__init__()
self.model = nn.ModuleList([
pyg.SAGEConv(in_channels=in_channels, out_channels=hi... | 703 | 28.333333 | 94 | py |
FATE | FATE-master/python/federatedml/nn/model_zoo/vision.py | import torch as t
from torchvision.models import get_model
class TorchVisionModels(t.nn.Module):
"""
This Class provides ALL torchvision classification models,
instantiate models and using pretrained weights by providing string model name and weight names
Parameters
----------
vision_model_na... | 1,062 | 38.37037 | 114 | py |
FATE | FATE-master/python/federatedml/nn/model_zoo/pretrained_bert.py | from transformers.models.bert import BertModel
from torch.nn import Module
from federatedml.util import LOGGER
class PretrainedBert(Module):
def __init__(self, pretrained_model_name_or_path: str = 'bert-base-uncased', freeze_weight=False):
"""
A pretrained Bert Model based on transformers
... | 1,566 | 38.175 | 117 | py |
FATE | FATE-master/python/federatedml/nn/dataset/base.py | from torch.utils.data import Dataset as Dataset_
from federatedml.nn.backend.utils.common import ML_PATH, LLM_PATH
import importlib
import abc
import numpy as np
class Dataset(Dataset_):
def __init__(self, **kwargs):
super(Dataset, self).__init__()
self._type = 'local' # train/predict
se... | 5,430 | 28.677596 | 119 | py |
FATE | FATE-master/python/federatedml/nn/dataset/image.py | import torch
from federatedml.nn.dataset.base import Dataset
from torchvision.datasets import ImageFolder
from torchvision import transforms
import numpy as np
class ImageDataset(Dataset):
"""
A basic Image Dataset built on pytorch ImageFolder, supports simple image transform
Given a folder path, ImageD... | 3,837 | 35.552381 | 119 | py |
FATE | FATE-master/python/federatedml/nn/dataset/graph.py | import numpy as np
import pandas as pd
from federatedml.statistic.data_overview import with_weight
from federatedml.nn.dataset.base import Dataset
try:
from torch_geometric.data import Data
except BaseException:
pass
import torch
from federatedml.util import LOGGER
class GraphDataset(Dataset):
"""
A... | 4,680 | 39.353448 | 145 | py |
FATE | FATE-master/python/federatedml/nn/backend/torch/import_hook.py | try:
from federatedml.component.nn.backend.torch import nn as nn_
from federatedml.component.nn.backend.torch import init as init_
from federatedml.component.nn.backend.torch import optim as optim_
from federatedml.component.nn.backend.torch.cust import CustModel, CustLoss
from federatedml.nn.backen... | 1,925 | 36.764706 | 101 | py |
FATE | FATE-master/python/federatedml/nn/backend/torch/base.py | import json
import torch as t
from torch.nn import Sequential as tSequential
from federatedml.nn.backend.torch.operation import OpBase
class FateTorchLayer(object):
def __init__(self):
t.nn.Module.__init__(self)
self.param_dict = dict()
self.initializer = {'weight': None, 'bias': None}
... | 4,203 | 26.657895 | 81 | py |
FATE | FATE-master/python/federatedml/nn/backend/torch/optim.py | from torch import optim
from federatedml.nn.backend.torch.base import FateTorchLayer, Sequential
from federatedml.nn.backend.torch.base import FateTorchOptimizer
class ASGD(optim.ASGD, FateTorchOptimizer):
def __init__(
self,
params=None,
lr=0.01,
lambd=0.0001,
alpha=0.75,... | 13,025 | 30.3125 | 118 | py |
FATE | FATE-master/python/federatedml/nn/backend/torch/cust_model.py | import importlib
from torch import nn
from federatedml.nn.backend.torch.base import FateTorchLayer
from federatedml.nn.backend.utils.common import ML_PATH
PATH = '{}.model_zoo'.format(ML_PATH)
class CustModel(FateTorchLayer, nn.Module):
def __init__(self, module_name, class_name, **kwargs):
super(Cust... | 1,984 | 34.446429 | 97 | py |
FATE | FATE-master/python/federatedml/nn/backend/torch/cust.py | from torch import nn
import importlib
from federatedml.nn.backend.torch.base import FateTorchLayer, FateTorchLoss
from federatedml.nn.backend.utils.common import ML_PATH, LLM_PATH
import difflib
LLM_MODEL_PATH = '{}.model_zoo'.format(LLM_PATH)
MODEL_PATH = '{}.model_zoo'.format(ML_PATH)
LOSS_PATH = '{}.loss'.format(M... | 4,907 | 34.057143 | 118 | py |
FATE | FATE-master/python/federatedml/nn/backend/torch/init.py | import copy
import torch as t
from torch.nn import init as torch_init
import functools
from federatedml.nn.backend.torch.base import FateTorchLayer
from federatedml.nn.backend.torch.base import Sequential
str_init_func_map = {
"uniform": torch_init.uniform_,
"normal": torch_init.normal_,
"constant": torch_... | 6,761 | 25.622047 | 89 | py |
FATE | FATE-master/python/federatedml/nn/backend/torch/nn.py | from torch import nn
from federatedml.nn.backend.torch.base import FateTorchLayer, FateTorchLoss
from federatedml.nn.backend.torch.base import Sequential
class Bilinear(nn.modules.linear.Bilinear, FateTorchLayer):
def __init__(
self,
in1_features,
in2_features,
out... | 81,778 | 32.406454 | 79 | py |
FATE | FATE-master/python/federatedml/nn/backend/torch/interactive.py | import torch as t
from torch.nn import ReLU, Linear, LazyLinear, Tanh, Sigmoid, Dropout, Sequential
from federatedml.nn.backend.torch.base import FateTorchLayer
class InteractiveLayer(t.nn.Module, FateTorchLayer):
r"""A :class: InteractiveLayer.
An interface for InteractiveLayer. In interactive layer... | 5,516 | 33.917722 | 113 | py |
FATE | FATE-master/python/federatedml/nn/backend/torch/__init__.py | try:
from federatedml.nn.backend.torch import nn, init, operation, optim, serialization
except ImportError:
nn, init, operation, optim, serialization = None, None, None, None, None
__all__ = ['nn', 'init', 'operation', 'optim', 'serialization']
| 254 | 35.428571 | 86 | py |
FATE | FATE-master/python/federatedml/nn/backend/torch/operation.py | import torch as t
import copy
from torch.nn import Module
class OpBase(object):
def __init__(self):
self.param_dict = {}
def to_dict(self):
ret = copy.deepcopy(self.param_dict)
ret['op'] = type(self).__name__
return ret
class Astype(Module, OpBase):
def __init__(self, ... | 3,475 | 23.652482 | 89 | py |
FATE | FATE-master/python/federatedml/nn/backend/torch/serialization.py | import copy
import inspect
from collections import OrderedDict
try:
from torch.nn import Sequential as tSeq
from federatedml.nn.backend.torch import optim, init, nn
from federatedml.nn.backend.torch import operation
from federatedml.nn.backend.torch.base import Sequential, get_torch_instance
from fe... | 4,832 | 36.757813 | 100 | py |
FATE | FATE-master/python/federatedml/nn/backend/torch/torch_modules_extract/extract_pytorch_modules.py | import inspect
from torch.nn.modules import linear, activation, rnn, dropout, sparse, pooling, conv, transformer, batchnorm
from torch.nn.modules import padding, pixelshuffle
from torch.nn.modules import loss
class Required(object):
def __init__(self):
pass
def __repr__(self):
return '(Requi... | 3,479 | 27.064516 | 108 | py |
FATE | FATE-master/python/federatedml/nn/backend/torch/torch_modules_extract/extract_pytorch_optim.py | import inspect
from torch import optim
from federatedml.nn.backend.torch.torch_modules_extract.extract_pytorch_modules import extract_init_param, Required
from torch.optim.optimizer import required
def code_assembly(param, nn_class):
para_str = ""
non_default_param = ""
init_str = """"""
special_param... | 2,304 | 27.45679 | 121 | py |
FATE | FATE-master/python/federatedml/nn/backend/torch/test/test_cust_model.py | from federatedml.nn.backend.torch import nn, init
import json
from federatedml.nn.backend.torch import serialization as s
import torch as t
from federatedml.nn.backend.torch.import_hook import fate_torch_hook
from federatedml.nn.backend.torch.cust import CustModel
fate_torch_hook(t)
cust_resnet = CustModel(name='resn... | 713 | 31.454545 | 77 | py |
FATE | FATE-master/python/federatedml/nn/backend/utils/data.py | import numpy as np
from torch.utils.data import Dataset as torchDataset
from federatedml.util import LOGGER
from federatedml.nn.dataset.base import Dataset, get_dataset_class
from federatedml.nn.dataset.image import ImageDataset
from federatedml.nn.dataset.table import TableDataset
from federatedml.nn.dataset.graph imp... | 2,598 | 35.605634 | 109 | py |
FATE | FATE-master/python/federatedml/nn/backend/utils/common.py | import torch as t
import numpy as np
import tempfile
ML_PATH = 'federatedml.nn'
LLM_PATH = "fate_llm"
HOMOMODELMETA = "HomoNNMeta"
HOMOMODELPARAM = "HomoNNParam"
def global_seed(seed):
# set random seed of torch
t.manual_seed(seed)
t.cuda.manual_seed_all(seed)
t.backends.cudnn.deterministic = True
... | 968 | 20.065217 | 72 | py |
FATE | FATE-master/python/federatedml/nn/backend/utils/distributed_util.py | #
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 815 | 27.137931 | 75 | py |
FATE | FATE-master/python/federatedml/nn/homo/client.py | import json
import torch
import inspect
from fate_arch.computing.non_distributed import LocalData
from fate_arch.computing import is_table
from federatedml.model_base import ModelBase
from federatedml.nn.homo.trainer.trainer_base import get_trainer_class, TrainerBase
from federatedml.nn.backend.utils.data import load_d... | 15,960 | 35.861432 | 145 | py |
FATE | FATE-master/python/federatedml/nn/homo/trainer/fedavg_trainer.py | import torch
import torch as t
import torch.distributed as dist
import tqdm
import numpy as np
import transformers
from torch.nn import DataParallel
from torch.utils.data import DataLoader
from torch.utils.data.distributed import DistributedSampler
from federatedml.framework.homo.aggregator.secure_aggregator import Sec... | 25,839 | 41.291326 | 146 | py |
FATE | FATE-master/python/federatedml/nn/homo/trainer/trainer_base.py | import os
import abc
import importlib
import torch as t
import numpy as np
from torch.nn import Module
from typing import List
from federatedml.util import consts
from federatedml.util import LOGGER
from federatedml.model_base import serialize_models
from federatedml.nn.backend.utils.common import ML_PATH
from federat... | 20,753 | 35.410526 | 131 | py |
FATE | FATE-master/python/federatedml/nn/homo/trainer/fedavg_graph_trainer.py | import torch
import torch as t
import numpy as np
from torch_geometric.loader import NeighborLoader
from federatedml.framework.homo.aggregator.secure_aggregator import SecureAggregatorClient as SecureAggClient
from federatedml.nn.dataset.base import Dataset
from federatedml.nn.homo.trainer.fedavg_trainer import FedAVGT... | 11,560 | 41.977695 | 152 | py |
FATE | FATE-master/python/federatedml/nn/hetero/host.py | #
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 5,442 | 36.027211 | 82 | py |
FATE | FATE-master/python/federatedml/nn/hetero/guest.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/lic... | 12,612 | 37.571865 | 96 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.