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
ImgX-DiffSeg
ImgX-DiffSeg-main/imgx/exp/mixed_precision.py
"""Mixed precision related functions.""" from functools import partial import chex import haiku as hk import jax import jax.numpy as jnp import jmp from imgx import model from imgx.model import CONFIG_NAME_TO_MODEL_CLS_NAME def get_mixed_precision_policy(use_mp: bool) -> jmp.Policy: """Return general mixed prec...
2,956
29.173469
78
py
ImgX-DiffSeg
ImgX-DiffSeg-main/imgx/exp/eval.py
"""Module for building evaluation functions.""" import json from functools import partial from pathlib import Path from typing import Callable, Dict, Iterable, Optional, Tuple import chex import haiku as hk import jax import numpy as np import pandas as pd from jax import numpy as jnp from omegaconf import DictConfig ...
16,503
31.746032
80
py
ImgX-DiffSeg
ImgX-DiffSeg-main/tests/unit/test_model_basic.py
"""Test basic functions for model.""" import chex import jax from absl.testing import parameterized from chex._src import fake from imgx.model.basic import sinusoidal_positional_embedding # Set `FLAGS.chex_n_cpu_devices` CPU devices for all tests. def setUpModule() -> None: # pylint: disable=invalid-name """Fak...
1,478
27.442308
78
py
ImgX-DiffSeg
ImgX-DiffSeg-main/tests/unit/test_diffusion_gaussian.py
"""Test Gaussian diffusion related classes and functions.""" from typing import Tuple import chex import haiku as hk import jax import jax.numpy as jnp from absl.testing import parameterized from chex._src import fake from imgx.diffusion.gaussian_diffusion import ( DiffusionBetaSchedule, DiffusionModelOutputT...
19,693
33.250435
80
py
ImgX-DiffSeg
ImgX-DiffSeg-main/tests/unit/test_loss_cross_entropy.py
"""Test dice loss functions.""" import chex import jax import numpy as np from absl.testing import parameterized from chex._src import fake from imgx.loss import mean_cross_entropy, mean_focal_loss # Set `FLAGS.chex_n_cpu_devices` CPU devices for all tests. def setUpModule() -> None: # pylint: disable=invalid-name...
5,017
27.511364
80
py
ImgX-DiffSeg
ImgX-DiffSeg-main/tests/unit/test_train_state.py
"""Test TrainState and related functions.""" from pathlib import Path from typing import Dict import chex import jax.numpy as jnp import jax.random import jmp import pytest from chex._src import fake from imgx.device import broadcast_to_local_devices from imgx.exp import train_state def setUpModule() -> None: # p...
3,895
30.934426
80
py
ImgX-DiffSeg
ImgX-DiffSeg-main/tests/unit/test_exp_model.py
"""Test mixed precision related functions in factory.""" import haiku as hk import pytest from omegaconf import DictConfig from imgx.exp.model import build_vision_model from imgx.model import MODEL_CLS_NAME_TO_CONFIG_NAME, SUPPORTED_VISION_MODELS DUMMY_TASK_CONFIG = { "name": "segmentation", "diffusion": { ...
1,733
24.5
77
py
ImgX-DiffSeg
ImgX-DiffSeg-main/tests/unit/test_dataset_augmentation.py
"""Test function for data augmentation.""" from typing import Tuple import chex import jax import jax.numpy as jnp import numpy as np from absl.testing import parameterized from chex._src import fake from imgx import IMAGE, LABEL from imgx.datasets import FOREGROUND_RANGE from imgx.datasets.augmentation import ( ...
23,132
29.081925
80
py
ImgX-DiffSeg
ImgX-DiffSeg-main/tests/unit/test_loss_dice.py
"""Test dice loss functions.""" import chex import jax import numpy as np from absl.testing import parameterized from chex._src import fake from imgx.loss import mean_dice_loss # Set `FLAGS.chex_n_cpu_devices` CPU devices for all tests. def setUpModule() -> None: # pylint: disable=invalid-name """Fake multi-de...
5,992
29.42132
80
py
ImgX-DiffSeg
ImgX-DiffSeg-main/tests/unit/test_diffusion_variance_schedule.py
"""Test Gaussian diffusion related classes and functions.""" import chex import jax.numpy as jnp from absl.testing import parameterized from chex._src import fake from imgx.diffusion.variance_schedule import ( DiffusionBetaSchedule, downsample_beta_schedule, get_beta_schedule, ) # Set `FLAGS.chex_n_cpu...
2,208
27.320513
60
py
ImgX-DiffSeg
ImgX-DiffSeg-main/tests/unit/test_exp_mixed_precision.py
"""Test mixed precision related functions in factory.""" import haiku as hk import pytest from imgx import model from imgx.exp.mixed_precision import set_mixed_precision_policy from imgx.model import MODEL_CLS_NAME_TO_CONFIG_NAME from imgx.model import __all__ as all_model_classes @pytest.mark.parametrize( "mode...
938
31.37931
80
py
ImgX-DiffSeg
ImgX-DiffSeg-main/tests/unit/test_metric_surface_distance.py
"""Test loss functions.""" from functools import partial from typing import Callable, List, Tuple, Union import chex import jax import numpy as np from absl.testing import parameterized from imgx.metric.surface_distance import ( aggregated_surface_distance, average_surface_distance, get_binary_mask_bound...
31,405
31.444215
88
py
ImgX-DiffSeg
ImgX-DiffSeg-main/tests/unit/test_metric_dice.py
"""Test dice score metric related functions.""" import chex import jax import numpy as np from absl.testing import parameterized from chex._src import fake from imgx.metric import dice_score, iou # Set `FLAGS.chex_n_cpu_devices` CPU devices for all tests. def setUpModule() -> None: # pylint: disable=invalid-name ...
4,360
25.430303
77
py
ImgX-DiffSeg
ImgX-DiffSeg-main/tests/unit/test_model_unet_3d_time.py
"""Test Unet related classes and functions.""" from typing import Tuple import chex import haiku as hk import jax import jax.numpy as jnp from absl.testing import parameterized from chex._src import fake from imgx.model import Unet3dSliceTime, Unet3dTime # Set `FLAGS.chex_n_cpu_devices` CPU devices for all tests. d...
6,305
27.278027
80
py
ImgX-DiffSeg
ImgX-DiffSeg-main/tests/unit/test_exp_eval.py
"""Test functions in imgx.exp.eval.""" import chex import jax import numpy as np from chex._src import fake from imgx.exp.eval import ( get_jit_segmentation_metrics, get_non_jit_segmentation_metrics, ) # Set `FLAGS.chex_n_cpu_devices` CPU devices for all tests. def setUpModule() -> None: # pylint: disable...
1,741
29.561404
75
py
ImgX-DiffSeg
ImgX-DiffSeg-main/tests/unit/test_model_unet_3d.py
"""Test Unet related classes and functions.""" from typing import Tuple import chex import haiku as hk import jax import jax.numpy as jnp from absl.testing import parameterized from chex._src import fake from imgx.model import Unet3d, Unet3dSlice # Set `FLAGS.chex_n_cpu_devices` CPU devices for all tests. def setUp...
5,355
25.646766
79
py
ImgX-DiffSeg
ImgX-DiffSeg-main/tests/data/test_dataset_iterator.py
"""Test image data iterators.""" from typing import Tuple import chex import haiku as hk import jax import numpy as np import SimpleITK as sitk # noqa: N813 from absl.testing import parameterized from chex._src import fake from omegaconf import DictConfig from imgx import IMAGE, LABEL, UID from imgx.datasets import ...
7,123
29.444444
78
py
CPM-Live
CPM-Live-master/cpm-live/cpmbee_translator.py
from typing import Dict from cpm_live.generation.bee import CPMBeeBeamSearch from cpm_live.models import CPMBeeTorch, CPMBeeConfig from cpm_live.tokenizers import CPMBeeTokenizer import torch import spacy import re def is_chinese(ch: str): if "\u4e00" <= ch <= "\u9fff": return True return False def ...
6,854
32.768473
180
py
CPM-Live
CPM-Live-master/cpm-live/setup.py
from setuptools import setup, find_packages setup( name="cpm_live", version="0.1.0", author="OpenBMB", author_email="openbmb@gmail.com", description="Toolkit for CPM-Live", packages=find_packages(), install_requires=[ "numpy", "torch>=1.10", "bmtrain>=0.1.8", ...
452
20.571429
48
py
CPM-Live
CPM-Live-master/cpm-live/pretrain_cpm_bee.py
# coding=utf-8 # Copyright 2022 The OpenBMB team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
15,523
38.805128
99
py
CPM-Live
CPM-Live-master/cpm-live/finetune_cpm_bee.py
# coding=utf-8 # Copyright 2022 The OpenBMB team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
16,454
37.900709
99
py
CPM-Live
CPM-Live-master/cpm-live/text_generation.py
from cpm_live.generation.bee import CPMBeeBeamSearch from cpm_live.models import CPMBeeTorch, CPMBeeConfig from cpm_live.tokenizers import CPMBeeTokenizer import torch if __name__ == "__main__": data_list = [ {"document": "今天天气是真的<mask_0>", "<ans>": {"<mask_0>": ""}}, ] config = CPMBeeConfig.from...
778
26.821429
71
py
CPM-Live
CPM-Live-master/cpm-live/cpm_live/dataset/distributed_dataset.py
# coding=utf-8 # Copyright 2020 The OpenBMB team. 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 b...
25,959
32.758127
131
py
CPM-Live
CPM-Live-master/cpm-live/cpm_live/models/bee.py
# coding=utf-8 # Copyright 2022 The OpenBMB team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
11,433
38.157534
100
py
CPM-Live
CPM-Live-master/cpm-live/cpm_live/models/ant.py
# coding=utf-8 # Copyright 2022 The OpenBMB team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
7,842
35.47907
96
py
CPM-Live
CPM-Live-master/cpm-live/cpm_live/models/bee_torch.py
# coding=utf-8 # Copyright 2022 The OpenBMB team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
9,873
39.970954
100
py
CPM-Live
CPM-Live-master/cpm-live/cpm_live/models/__init__.py
from .ant import CPMAntConfig, CPMAnt from .bee import CPMBeeConfig, CPMBee from .ant_torch import CPMAntTorch from .bee_torch import CPMBeeTorch
146
28.4
37
py
CPM-Live
CPM-Live-master/cpm-live/cpm_live/models/ant_torch.py
# coding=utf-8 # Copyright 2022 The OpenBMB team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
6,552
37.547059
96
py
CPM-Live
CPM-Live-master/cpm-live/cpm_live/training_tasks/ant/pretrain.py
# coding=utf-8 # Copyright 2020 The OpenBMB team. 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 b...
4,499
37.135593
99
py
CPM-Live
CPM-Live-master/cpm-live/cpm_live/training_tasks/bee/pretrain.py
# coding=utf-8 # Copyright 2022 The OpenBMB team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
38,408
35.860845
100
py
CPM-Live
CPM-Live-master/cpm-live/cpm_live/native_layers/embedding.py
# coding=utf-8 # Copyright 2022 The OpenBMB team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
4,165
36.531532
151
py
CPM-Live
CPM-Live-master/cpm-live/cpm_live/native_layers/position_embedding.py
# coding=utf-8 # Copyright 2022 The OpenBMB team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
8,848
34.681452
100
py
CPM-Live
CPM-Live-master/cpm-live/cpm_live/native_layers/feedforward.py
# coding=utf-8 # Copyright 2022 The OpenBMB team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
3,676
29.38843
176
py
CPM-Live
CPM-Live-master/cpm-live/cpm_live/native_layers/layernorm.py
import torch @torch.jit.script # type: ignore def rms_layernorm(hidden: torch.Tensor, weight: torch.Tensor, eps: float): old_dtype = hidden.dtype variance = hidden.to(torch.float32).pow(2).mean(dim=-1, keepdim=True) hidden = (hidden * torch.rsqrt(variance + eps)).to(old_dtype) return hidden * weight ...
1,156
29.447368
122
py
CPM-Live
CPM-Live-master/cpm-live/cpm_live/native_layers/linear.py
# coding=utf-8 # Copyright 2022 The OpenBMB team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
1,721
32.115385
109
py
CPM-Live
CPM-Live-master/cpm-live/cpm_live/native_layers/transformer.py
# coding=utf-8 # Copyright 2022 The OpenBMB team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
4,852
37.515873
155
py
CPM-Live
CPM-Live-master/cpm-live/cpm_live/native_layers/attention.py
# coding=utf-8 # Copyright 2022 The OpenBMB team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
4,604
38.025424
191
py
CPM-Live
CPM-Live-master/cpm-live/cpm_live/native_layers/blocks.py
# coding=utf-8 # Copyright 2022 The OpenBMB team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
8,723
34.036145
198
py
CPM-Live
CPM-Live-master/cpm-live/cpm_live/layers/embedding.py
# coding=utf-8 # Copyright 2022 The OpenBMB team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
4,458
36.788136
151
py
CPM-Live
CPM-Live-master/cpm-live/cpm_live/layers/position_embedding.py
# coding=utf-8 # Copyright 2022 The OpenBMB team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
9,197
35.070588
100
py
CPM-Live
CPM-Live-master/cpm-live/cpm_live/layers/feedforward.py
# coding=utf-8 # Copyright 2022 The OpenBMB team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
3,770
29.658537
176
py
CPM-Live
CPM-Live-master/cpm-live/cpm_live/layers/layernorm.py
import torch import bmtrain as bmt @torch.jit.script # type: ignore def rms_layernorm(hidden: torch.Tensor, weight: torch.Tensor, eps: float): old_dtype = hidden.dtype variance = hidden.to(torch.float32).pow(2).mean(dim=-1, keepdim=True) hidden = (hidden * torch.rsqrt(variance + eps)).to(old_dtype) r...
1,180
29.282051
122
py
CPM-Live
CPM-Live-master/cpm-live/cpm_live/layers/linear.py
# coding=utf-8 # Copyright 2022 The OpenBMB team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
1,901
31.793103
109
py
CPM-Live
CPM-Live-master/cpm-live/cpm_live/layers/transformer.py
# coding=utf-8 # Copyright 2022 The OpenBMB team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
4,948
37.664063
155
py
CPM-Live
CPM-Live-master/cpm-live/cpm_live/layers/attention.py
# coding=utf-8 # Copyright 2022 The OpenBMB team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
4,800
38.677686
191
py
CPM-Live
CPM-Live-master/cpm-live/cpm_live/layers/blocks.py
# coding=utf-8 # Copyright 2022 The OpenBMB team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
8,751
34.008
198
py
CPM-Live
CPM-Live-master/cpm-live/cpm_live/utils/export.py
import os import time import functools import torch import bmtrain as bmt import json from cpm_live.models import CPMBee from .log import logger from typing import List, Optional def rename_if_exists(file_path): if not os.path.exists(file_path): return timestamp = time.strftime('%Y%m%d%H%M%S') fil...
1,820
30.947368
95
py
CPM-Live
CPM-Live-master/cpm-live/cpm_live/utils/object.py
import bmtrain as bmt import pickle import torch def allgather_objects(obj): if bmt.world_size() == 1: return [obj] with torch.no_grad(): data_bytes: bytes = pickle.dumps(obj) data_length: int = len(data_bytes) gpu_data_length = torch.tensor([data_length], device="cuda", dtyp...
994
33.310345
88
py
CPM-Live
CPM-Live-master/cpm-live/cpm_live/utils/data_utils.py
import torch def pad(orig_items, key, padding_value=0, padding_side="left"): items = [] if isinstance(orig_items[0][key], list): assert isinstance(orig_items[0][key][0], torch.Tensor) for it in orig_items: for tr in it[key]: items.append({key: tr}) else: ...
1,550
33.466667
94
py
CPM-Live
CPM-Live-master/cpm-live/cpm_live/utils/gradient_shrink.py
import torch class OpGradientShrink(torch.autograd.Function): @staticmethod def forward(ctx, x: torch.Tensor, alpha: float): ctx.alpha = alpha return x @staticmethod def backward(ctx, grad_output): return grad_output * ctx.alpha, None def gradient_shrink(x: torch.Tensor, alp...
382
21.529412
57
py
CPM-Live
CPM-Live-master/cpm-live/cpm_live/generation/bee.py
from typing import Any, Dict, List, Tuple import numpy as np import torch import torch.nn.functional as F from .generation_utils import BeamHypotheses, apply_repetition_penalty from ..tokenizers.bee import CPMBeeTokenizer from ..models.bee import CPMBee from ..training_tasks.bee.pretrain import convert_data_to_id from ...
26,159
40.52381
148
py
CPM-Live
CPM-Live-master/cpm-live/cpm_live/generation/ant.py
import torch import torch.nn.functional as F from .generation_utils import BeamHypotheses, apply_repetition_penalty, top_k_top_p_filtering from ..utils import pad class CPMAntGeneration: def __init__(self, model, tokenizer, prompt_length=32): model.eval() self.model = model self.tokenizer ...
14,654
36.966321
148
py
CPM-Live
CPM-Live-master/cpm-live/cpm_live/generation/generation_utils.py
import torch import torch.nn.functional as F def top_k_top_p_filtering(logits, top_k=0, top_p=0.0, filter_value=-float("inf")): # This function has been mostly taken from huggingface conversational ai code at # https://medium.com/huggingface/how-to-build-a-state-of-the-art-conversational-ai-with-transfer-lear...
4,382
37.787611
122
py
LOSTIN
LOSTIN-main/GNN-supernode/inference.py
import torch from torch_geometric.data import DataLoader import torch.optim as optim import torch.nn.functional as F from gnn import GNN from torch.optim.lr_scheduler import ReduceLROnPlateau from torch_geometric.utils import degree from tqdm import tqdm import argparse import time import numpy as np import json impor...
7,700
43.514451
183
py
LOSTIN
LOSTIN-main/GNN-supernode/node_encoder.py
import torch from features import get_node_feature_dims, get_edge_feature_dims full_node_feature_dims = get_node_feature_dims() full_edge_feature_dims = get_edge_feature_dims() class NodeEncoder(torch.nn.Module): def __init__(self, emb_dim): super(NodeEncoder, self).__init__() self.node...
1,815
28.770492
90
py
LOSTIN
LOSTIN-main/GNN-supernode/test_evaluation.py
import torch from torch_geometric.loader import DataLoader from torch.utils.data import TensorDataset import torch.optim as optim import torch.nn.functional as F from gnn import GNN from torch.optim.lr_scheduler import ReduceLROnPlateau from tqdm import tqdm import argparse import time import numpy as np import json i...
7,667
40.225806
183
py
LOSTIN
LOSTIN-main/GNN-supernode/evaluate.py
from sklearn.metrics import roc_auc_score, average_precision_score import pandas as pd import os import numpy as np try: import torch except ImportError: torch = None ### Evaluator for graph classification class Evaluator: def __init__(self, name): self.name = name meta_info = pd.read_csv...
14,336
40.677326
222
py
LOSTIN
LOSTIN-main/GNN-supernode/read_graph_pyg.py
import pandas as pd import torch from torch_geometric.data import Data import os.path as osp import numpy as np from read_graph_raw import read_csv_graph_raw from tqdm import tqdm def read_graph_pyg(raw_dir, add_inverse_edge = False, additional_node_files = [], additional_edge_files = [], binary = False): graph_l...
1,697
29.321429
185
py
LOSTIN
LOSTIN-main/GNN-supernode/main_gnn.py
import torch from torch_geometric.loader import DataLoader import torch.optim as optim import torch.nn.functional as F from gnn import GNN from torch.optim.lr_scheduler import ReduceLROnPlateau from tqdm import tqdm import argparse import time import numpy as np import json import operator from functools import reduce...
9,703
41.375546
183
py
LOSTIN
LOSTIN-main/GNN-supernode/gnn.py
import torch from torch_geometric.nn import MessagePassing,BatchNorm from torch_geometric.nn import global_add_pool, global_mean_pool, global_max_pool, GlobalAttention, Set2Set import torch.nn.functional as F from torch_geometric.nn.inits import uniform from torch.nn import Sequential, ReLU, Linear, ModuleList from co...
3,673
39.822222
188
py
LOSTIN
LOSTIN-main/GNN-supernode/conv.py
import torch from torch_geometric.nn import MessagePassing import torch.nn.functional as F from torch_geometric.nn import global_mean_pool, global_add_pool from node_encoder import NodeEncoder,EdgeEncoder from torch_geometric.utils import degree import math ### GIN convolution along the graph structure class GINConv(...
8,910
35.520492
182
py
LOSTIN
LOSTIN-main/GNN-supernode/dataset_pyg.py
from torch_geometric.data import InMemoryDataset import pandas as pd import shutil, os import os.path as osp import torch import numpy as np from read_graph_pyg import read_graph_pyg class PygGraphPropPredDataset(InMemoryDataset): def __init__(self, name, root = 'dataset', transform=None, pre_transform = None, me...
6,385
41.291391
212
py
LOSTIN
LOSTIN-main/GNN-LSTM/main_gnn_customized_delay.py
### Libraries import numpy as np import argparse from tqdm import tqdm import matplotlib.pyplot as plts import pandas as pd import torch # Preliminaries # torchtext 0.6.0 from torchtext.data import Field, TabularDataset, BucketIterator # Models import torch.nn as nn from torch.nn.utils.rnn import pack_padded_sequence...
9,155
36.679012
148
py
LOSTIN
LOSTIN-main/GNN-LSTM/node_encoder.py
import torch from features import get_node_feature_dims, get_edge_feature_dims full_node_feature_dims = get_node_feature_dims() full_edge_feature_dims = get_edge_feature_dims() class NodeEncoder(torch.nn.Module): def __init__(self, emb_dim): super(NodeEncoder, self).__init__() self.node...
1,857
28.967742
90
py
LOSTIN
LOSTIN-main/GNN-LSTM/read_graph_pyg.py
import pandas as pd import torch from torch_geometric.data import Data import os.path as osp import numpy as np from read_graph_raw import read_csv_graph_raw from tqdm import tqdm def read_graph_pyg(raw_dir, add_inverse_edge = False, additional_node_files = [], additional_edge_files = [], binary = False): graph_l...
1,387
27.916667
156
py
LOSTIN
LOSTIN-main/GNN-LSTM/main_gnn_customized_inference.py
### Libraries # torchtext 0.6.0 import numpy as np import argparse from tqdm import tqdm # Libraries import matplotlib.pyplot as plts import pandas as pd import torch # Preliminaries from torchtext.data import Field, TabularDataset, BucketIterator # Models import torch.nn as nn from torch.nn.utils.rnn import pack_pad...
6,775
37.942529
169
py
LOSTIN
LOSTIN-main/GNN-LSTM/gnn.py
import torch from torch_geometric.nn import MessagePassing,BatchNorm from torch_geometric.nn import global_add_pool, global_mean_pool, global_max_pool, GlobalAttention, Set2Set import torch.nn.functional as F from torch_geometric.nn.inits import uniform from torch.nn import Sequential, ReLU, Linear, ModuleList from co...
2,744
36.60274
188
py
LOSTIN
LOSTIN-main/GNN-LSTM/conv.py
import torch from torch_geometric.nn import MessagePassing import torch.nn.functional as F from torch_geometric.nn import global_mean_pool, global_add_pool from node_encoder import NodeEncoder,EdgeEncoder from torch_geometric.utils import degree import math ### GIN convolution along the graph structure class GINConv(...
8,791
35.481328
182
py
LOSTIN
LOSTIN-main/GNN-LSTM/main_gnn_customized_area.py
### Libraries import numpy as np import argparse from tqdm import tqdm import matplotlib.pyplot as plts import pandas as pd import torch # Preliminaries # torchtext 0.6.0 from torchtext.data import Field, TabularDataset, BucketIterator # Models import torch.nn as nn from torch.nn.utils.rnn import pack_padded_sequence...
9,153
36.670782
148
py
LOSTIN
LOSTIN-main/GNN-LSTM/dataset_pyg.py
from torch_geometric.data import InMemoryDataset import pandas as pd import shutil, os import os.path as osp import torch import numpy as np from read_graph_pyg import read_graph_pyg class PygGraphPropPredDataset(InMemoryDataset): def __init__(self, name, root = 'dataset', transform=None, pre_transform = None, me...
6,691
38.364706
199
py
LOSTIN
LOSTIN-main/LSTM/LSTM_inference.py
### Libraries # torchtext 0.6.0 import numpy as np import argparse from tqdm import tqdm # Libraries import matplotlib.pyplot as plts import pandas as pd import torch # Preliminaries from torchtext.data import Field, TabularDataset, BucketIterator # Models import torch.nn as nn from torch.nn.utils.rnn import pack_pad...
6,857
33.29
149
py
LOSTIN
LOSTIN-main/LSTM/LSTM_area.py
### Libraries # torchtext 0.6.0 import numpy as np import argparse from tqdm import tqdm # Libraries import matplotlib.pyplot as plts import pandas as pd import torch # Preliminaries from torchtext.data import Field, TabularDataset, BucketIterator # Models import torch.nn as nn from torch.nn.utils.rnn import pack_pad...
9,043
34.328125
148
py
LOSTIN
LOSTIN-main/LSTM/LSTM_delay.py
### Libraries # torchtext 0.6.0 import numpy as np import argparse from tqdm import tqdm # Libraries import matplotlib.pyplot as plts import pandas as pd import torch # Preliminaries from torchtext.data import Field, TabularDataset, BucketIterator # Models import torch.nn as nn from torch.nn.utils.rnn import pack_pad...
9,049
34.490196
148
py
LOSTIN
LOSTIN-main/CNN/cnn_data_gen.py
import utils import pandas as pd import numpy as np import argparse import pprint as pp from os import listdir from os.path import isfile, join import torch from torch.utils.data import TensorDataset, DataLoader def main(args): ff_10 = pd.read_csv('flow_10.csv',header=None) ff_15 = pd.read_csv('flow_15.csv...
7,046
33.208738
116
py
LOSTIN
LOSTIN-main/CNN/train_cnn.py
import torch from torch.autograd import Variable import torch.nn.functional as F import torch.nn as nn import torch.utils.data as Data from torch.utils.data import TensorDataset, DataLoader import numpy as np import argparse # Keras -> PyTorch Implementation # Modification: Classification -> Regression class CNN_Reg...
5,484
31.264706
110
py
scalene
scalene-master/test/testpyt.py
# -*- coding: utf-8 -*- import random import torch class DynamicNet(torch.nn.Module): def __init__(self, D_in, H, D_out): """ In the constructor we construct three nn.Linear instances that we will use in the forward pass. """ super(DynamicNet, self).__init__() self....
2,339
34.454545
85
py
scalene
scalene-master/test/torchtest.py
import torch import math def torchtest(): dtype = torch.float #device = torch.device("cpu") device = torch.device("cuda:0") # Uncomment this to run on GPU # device = torch.device("cuda") # Uncomment this to run on GPU # Create Tensors to hold input and outputs. # By default, requires_grad=Fa...
2,736
41.765625
85
py
scalene
scalene-master/test/testtf.py
import tensorflow as tf from time import perf_counter def config(): num_threads = 16 tf.config.threading.set_inter_op_parallelism_threads( num_threads ) tf.config.threading.set_intra_op_parallelism_threads( num_threads ) def run_benchmark(): mnist = tf.keras.datasets.mnist ...
1,116
26.925
77
py
XFL
XFL-master/python/common/evaluation/metrics.py
# Copyright 2022 The XFL 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 applicable law...
20,407
37.946565
115
py
XFL
XFL-master/python/common/crypto/one_time_pad/one_time_add.py
# Copyright 2022 The XFL 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 applicable law...
7,887
40.298429
128
py
XFL
XFL-master/python/common/crypto/one_time_pad/component.py
# Copyright 2022 The XFL 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 applicable ...
7,684
33.931818
125
py
XFL
XFL-master/python/common/dataset/azpro_data.py
# Copyright 2022 The XFL 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 applicable law...
5,809
38.52381
110
py
XFL
XFL-master/python/common/dataset/hiv.py
# Copyright 2022 The XFL 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 applicable law...
5,661
37.256757
110
py
XFL
XFL-master/python/common/dataset/sst2.py
# Copyright 2022 The XFL 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 applicable law...
4,360
36.594828
105
py
XFL
XFL-master/python/common/dataset/breast_cancer_wisconsin.py
# Copyright 2022 The XFL 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 applicable law...
7,461
40.921348
108
py
XFL
XFL-master/python/common/dataset/cifar.py
# Copyright 2022 The XFL 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 applicable law...
12,098
40.434932
182
py
XFL
XFL-master/python/common/dataset/boston_housing_price.py
# Copyright 2022 The XFL 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 applicable law...
5,887
39.054422
110
py
XFL
XFL-master/python/common/utils/model_io.py
# Copyright 2022 The XFL 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 applicable law...
4,851
35.757576
110
py
XFL
XFL-master/python/common/utils/algo_utils.py
# Copyright 2022 The XFL 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 applicable ...
9,180
30.016892
108
py
XFL
XFL-master/python/common/utils/config_checker.py
import os import importlib import traceback from collections import Counter from common.checker.compare import compare from common.utils.logger import logger from common.utils.config_parser import replace_variable def find_rule_class(fed_type, operator_name, role, inference): try: if inference: ...
25,081
35.037356
149
py
XFL
XFL-master/python/common/utils/model_preserver.py
# Copyright 2022 The XFL 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 applicable ...
1,794
31.053571
87
py
XFL
XFL-master/python/common/utils/auto_descriptor/torch/torch_descriptor.py
import inspect import math import torch.optim as optim import torch.optim.lr_scheduler as lr_scheduler import torch.nn as nn import sklearn.metrics as sklearn_metrics import algorithm.core.metrics as custom_metrics from algorithm.core.metrics import metric_dict # from common.checker.qualifiers import (OneOf, Optiona...
20,063
41.780384
203
py
XFL
XFL-master/python/algorithm/config_descriptor/vertical_kmeans/label_trainer.py
from common.checker.x_types import String, Bool, Integer, Float, Any from common.checker.qualifiers import OneOf, SomeOf, RepeatableSomeOf, Required, Optional vertical_kmeans_label_trainer_rule = { "identity": "label_trainer", "model_info": { "name": "vertical_kmeans" }, "input": { "tr...
2,041
31.935484
109
py
XFL
XFL-master/python/algorithm/config_descriptor/horizontal_kmeans/assist_trainer.py
from common.checker.x_types import String, Bool, Integer, Float, Any from common.checker.qualifiers import OneOf, SomeOf, RepeatableSomeOf, Required, Optional from common.utils.auto_descriptor.torch.optimizer import optimizer from common.utils.auto_descriptor.torch.lr_scheduler import lr_scheduler from common.utils.aut...
2,660
34.013158
109
py
XFL
XFL-master/python/algorithm/config_descriptor/horizontal_linear_regression/assist_trainer.py
from common.checker.x_types import String, Bool, Integer, Float, Any from common.checker.qualifiers import OneOf, SomeOf, RepeatableSomeOf, Required, Optional from common.utils.auto_descriptor.torch.optimizer import optimizer from common.utils.auto_descriptor.torch.lr_scheduler import lr_scheduler from common.utils.aut...
3,686
35.50495
121
py
XFL
XFL-master/python/algorithm/config_descriptor/horizontal_logistic_regression/assist_trainer.py
from common.checker.x_types import String, Bool, Integer, Float, Any from common.checker.qualifiers import OneOf, SomeOf, RepeatableSomeOf, Required, Optional from common.utils.auto_descriptor.torch.optimizer import optimizer from common.utils.auto_descriptor.torch.lr_scheduler import lr_scheduler from common.utils.aut...
4,321
36.912281
203
py
XFL
XFL-master/python/algorithm/config_descriptor/vertical_xgboost_infer/label_trainer.py
from common.checker.x_types import String, Bool, Integer, Float, Any from common.checker.qualifiers import OneOf, SomeOf, RepeatableSomeOf, Required, Optional vertical_xgboost_infer_label_trainer_rule = { "identity": "label_trainer", "model_info": { "name": "vertical_xgboost" }, "inference": T...
1,197
26.860465
89
py
XFL
XFL-master/python/algorithm/config_descriptor/vertical_xgboost_infer/sync.py
from common.checker.x_types import String, Bool, Integer, Float, Any, All from common.checker.qualifiers import OneOf, SomeOf, RepeatableSomeOf, Required, Optional vertical_xgboost_infer_sync_rule = { "train_info": { "train_params": { "batch_size_val": All() } } }
303
24.333333
89
py
XFL
XFL-master/python/algorithm/config_descriptor/vertical_xgboost_infer/trainer.py
from common.checker.x_types import String, Bool, Integer, Float, Any from common.checker.qualifiers import OneOf, SomeOf, RepeatableSomeOf, Required, Optional vertical_xgboost_infer_trainer_rule = { "identity": "trainer", "model_info": { "name": "vertical_xgboost" }, "inference": True, "in...
1,034
25.538462
89
py
XFL
XFL-master/python/algorithm/config_descriptor/horizontal_poisson_regression/assist_trainer.py
from common.checker.x_types import String, Bool, Integer, Float, Any from common.checker.qualifiers import OneOf, SomeOf, RepeatableSomeOf, Required, Optional from common.utils.auto_descriptor.torch.optimizer import optimizer from common.utils.auto_descriptor.torch.lr_scheduler import lr_scheduler from common.utils.aut...
3,544
36.315789
122
py