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
Hierarchical-Localization
Hierarchical-Localization-master/hloc/localize_inloc.py
import argparse from pathlib import Path import numpy as np import h5py from scipy.io import loadmat import torch from tqdm import tqdm import pickle import cv2 import pycolmap from . import logger from .utils.parsers import parse_retrieval, names_to_pair def interpolate_scan(scan, kp): h, w, c = scan.shape ...
5,545
30.333333
79
py
Hierarchical-Localization
Hierarchical-Localization-master/hloc/match_features.py
import argparse from typing import Union, Optional, Dict, List, Tuple from pathlib import Path import pprint from queue import Queue from threading import Thread from functools import partial from tqdm import tqdm import h5py import torch from . import matchers, logger from .utils.base_model import dynamic_load from ....
8,514
32.523622
80
py
Hierarchical-Localization
Hierarchical-Localization-master/hloc/match_dense.py
from tqdm import tqdm import numpy as np import h5py import torch from pathlib import Path from typing import Dict, Iterable, Optional, List, Tuple, Union, Set import pprint import argparse import torchvision.transforms.functional as F from types import SimpleNamespace from collections import defaultdict from scipy.spa...
22,408
37.371575
81
py
Hierarchical-Localization
Hierarchical-Localization-master/hloc/extractors/r2d2.py
import sys from pathlib import Path import torchvision.transforms as tvf from ..utils.base_model import BaseModel r2d2_path = Path(__file__).parent / "../../third_party/r2d2" sys.path.append(str(r2d2_path)) from extract import load_network, NonMaxSuppression, extract_multiscale class R2D2(BaseModel): default_co...
1,784
30.315789
71
py
Hierarchical-Localization
Hierarchical-Localization-master/hloc/extractors/cosplace.py
''' Code for loading models trained with CosPlace as a global features extractor for geolocalization through image retrieval. Multiple models are available with different backbones. Below is a summary of models available (backbone : list of available output descriptors dimensionality). For example you can use a model b...
1,451
29.893617
77
py
Hierarchical-Localization
Hierarchical-Localization-master/hloc/extractors/dir.py
import sys from pathlib import Path import torch from zipfile import ZipFile import os import sklearn import gdown from ..utils.base_model import BaseModel sys.path.append(str( Path(__file__).parent / '../../third_party/deep-image-retrieval')) os.environ['DB_ROOT'] = '' # required by dirtorch from dirtorch.util...
2,619
32.589744
111
py
Hierarchical-Localization
Hierarchical-Localization-master/hloc/extractors/dog.py
import kornia from kornia.feature.laf import ( laf_from_center_scale_ori, extract_patches_from_pyramid) import numpy as np import torch import pycolmap from ..utils.base_model import BaseModel EPS = 1e-6 def sift_to_rootsift(x): x = x / (np.linalg.norm(x, ord=1, axis=-1, keepdims=True) + EPS) x = np.sq...
4,457
37.431034
78
py
Hierarchical-Localization
Hierarchical-Localization-master/hloc/extractors/superpoint.py
import sys from pathlib import Path import torch from ..utils.base_model import BaseModel sys.path.append(str(Path(__file__).parent / '../../third_party')) from SuperGluePretrainedNetwork.models import superpoint # noqa E402 # The original keypoint sampling is incorrect. We patch it here but # we don't fix it upst...
1,439
31.727273
75
py
Hierarchical-Localization
Hierarchical-Localization-master/hloc/extractors/netvlad.py
from pathlib import Path import subprocess import logging import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import torchvision.models as models from scipy.io import loadmat from ..utils.base_model import BaseModel logger = logging.getLogger(__name__) EPS = 1e-6 class NetVLADLaye...
5,941
37.089744
98
py
Hierarchical-Localization
Hierarchical-Localization-master/hloc/extractors/openibl.py
import torch import torchvision.transforms as tvf from ..utils.base_model import BaseModel class OpenIBL(BaseModel): default_conf = { 'model_name': 'vgg16_netvlad', } required_inputs = ['image'] def _init(self, conf): self.net = torch.hub.load( 'yxgeee/OpenIBL', conf['mod...
741
27.538462
77
py
Hierarchical-Localization
Hierarchical-Localization-master/hloc/extractors/d2net.py
import sys from pathlib import Path import subprocess import torch from ..utils.base_model import BaseModel d2net_path = Path(__file__).parent / '../../third_party/d2net' sys.path.append(str(d2net_path)) from lib.model_test import D2Net as _D2Net from lib.pyramid import process_multiscale class D2Net(BaseModel): ...
1,772
31.236364
78
py
Hierarchical-Localization
Hierarchical-Localization-master/hloc/matchers/nearest_neighbor.py
import torch from ..utils.base_model import BaseModel def find_nn(sim, ratio_thresh, distance_thresh): sim_nn, ind_nn = sim.topk(2 if ratio_thresh else 1, dim=-1, largest=True) dist_nn = 2 * (1 - sim_nn) mask = torch.ones(ind_nn.shape[:-1], dtype=torch.bool, device=sim.device) if ratio_thresh: ...
2,292
35.396825
84
py
Hierarchical-Localization
Hierarchical-Localization-master/hloc/matchers/loftr.py
import torch import warnings from kornia.feature.loftr.loftr import default_cfg from kornia.feature import LoFTR as LoFTR_ from ..utils.base_model import BaseModel class LoFTR(BaseModel): default_conf = { 'weights': 'outdoor', 'match_threshold': 0.2, 'max_num_matches': None, } req...
1,618
28.981481
78
py
Hierarchical-Localization
Hierarchical-Localization-master/hloc/matchers/adalam.py
import torch from ..utils.base_model import BaseModel from kornia.feature.adalam import AdalamFilter from kornia.utils.helpers import get_cuda_device_if_available class AdaLAM(BaseModel): # See https://kornia.readthedocs.io/en/latest/_modules/kornia/feature/adalam/adalam.html. default_conf = { 'area...
1,965
34.107143
93
py
Hierarchical-Localization
Hierarchical-Localization-master/hloc/utils/base_model.py
import sys from abc import ABCMeta, abstractmethod from torch import nn from copy import copy import inspect class BaseModel(nn.Module, metaclass=ABCMeta): default_conf = {} required_inputs = [] def __init__(self, conf): """Perform some logic and call the _init method of the child model.""" ...
1,546
31.229167
78
py
Hierarchical-Localization
Hierarchical-Localization-master/hloc/pipelines/7Scenes/create_gt_sfm.py
from pathlib import Path import numpy as np import torch import PIL.Image from tqdm import tqdm import pycolmap from ...utils.read_write_model import write_model, read_model def scene_coordinates(p2D, R_w2c, t_w2c, depth, camera): assert len(depth) == len(p2D) ret = pycolmap.image_to_world(p2D, camera._asdic...
5,227
39.527132
79
py
batch-bandits
batch-bandits-main/CMAB/offline_evaluator.py
from matplotlib import pyplot as plt from torch.utils.data import Dataset from basics.base_agent import BaseAgent class OfflineEvaluator: def __init__(self, eval_info=None): if eval_info is None: eval_info = {} self.dataset = eval_info['dataset'] self.agent = eval_info['agen...
2,575
25.833333
105
py
batch-bandits
batch-bandits-main/utilities/dataloader.py
import pickle import pandas as pd from torch.utils.data import Dataset, DataLoader from sklearn.model_selection import train_test_split from utilities.data_generator import generate_samples def data_randomizer(pickle_file, seed=None): if isinstance(pickle_file, str): with open(pickle_file, 'rb') as f: ...
2,456
28.25
98
py
ecg-classification-quantized-cnn
ecg-classification-quantized-cnn-main/training.py
import torch import torchvision import torch.quantization import torchvision.transforms as transforms import torch.nn as nn import torch.nn.functional as F import torch.optim as optim import numpy as np import pickle as pk import pandas as pd import wfdb import pywt #import h5py import math import os import sys import ...
59,583
34.319502
287
py
ecg-classification-quantized-cnn
ecg-classification-quantized-cnn-main/tool_onnxgen.py
import torch.nn as nn import torch.nn.functional as F import torch.onnx import os from pathlib import Path import shutil if os.path.isdir('./output/net/'): print("Session already exists (./output/net/), overwrite the session? (y/n): ", end='') force_write = input() print("") if force_write == "y": ...
1,416
23.859649
91
py
ecg-classification-quantized-cnn
ecg-classification-quantized-cnn-main/evaluation.py
import torch import torchvision import torch.quantization import torchvision.transforms as transforms import torch.nn as nn import torch.nn.functional as F import torch.optim as optim import numpy as np import pickle as pk import pandas as pd import wfdb import math import os import sys import argparse from pathlib imp...
31,326
30.901222
147
py
neural-tangents
neural-tangents-main/setup.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
4,462
31.34058
95
py
neural-tangents
neural-tangents-main/examples/empirical_ntk.py
# Copyright 2022 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
2,892
29.135417
80
py
neural-tangents
neural-tangents-main/examples/imdb.py
"""An example doing inference with an infinitely wide attention network on IMDb. Adapted from https://github.com/google/neural-tangents/blob/main/examples/infinite_fcn.py By default, this example does inference on a very small subset, and uses small word embeddings for performance. A 300/300 train/test split takes 30...
4,628
32.543478
80
py
neural-tangents
neural-tangents-main/examples/elementwise_numerical.py
# Copyright 2022 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
2,016
32.616667
80
py
neural-tangents
neural-tangents-main/examples/datasets.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
6,991
32.454545
86
py
neural-tangents
neural-tangents-main/examples/util.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
1,503
37.564103
79
py
neural-tangents
neural-tangents-main/examples/infinite_fcn.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
2,505
33.805556
80
py
neural-tangents
neural-tangents-main/examples/function_space.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
3,399
34.789474
78
py
neural-tangents
neural-tangents-main/examples/elementwise.py
# Copyright 2022 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
2,095
34.525424
80
py
neural-tangents
neural-tangents-main/examples/weight_space.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
3,533
32.339623
79
py
neural-tangents
neural-tangents-main/examples/experimental/empirical_ntk_tf.py
# Copyright 2022 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
3,838
30.991667
80
py
neural-tangents
neural-tangents-main/tests/empirical_ntk_test.py
# Copyright 2022 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
1,004
27.714286
74
py
neural-tangents
neural-tangents-main/tests/elementwise_test.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
996
26.694444
74
py
neural-tangents
neural-tangents-main/tests/rules_test.py
# Copyright 2022 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
18,744
27.927469
80
py
neural-tangents
neural-tangents-main/tests/function_space_test.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
1,010
27.083333
74
py
neural-tangents
neural-tangents-main/tests/weight_space_test.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
999
27.571429
74
py
neural-tangents
neural-tangents-main/tests/imdb_test.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
925
25.457143
74
py
neural-tangents
neural-tangents-main/tests/batching_test.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
18,750
31.107877
80
py
neural-tangents
neural-tangents-main/tests/predict_test.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
44,227
36.197645
115
py
neural-tangents
neural-tangents-main/tests/empirical_test.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
55,785
32.009467
214
py
neural-tangents
neural-tangents-main/tests/monte_carlo_test.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
9,216
31.340351
80
py
neural-tangents
neural-tangents-main/tests/infinite_fcn_test.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
1,002
26.861111
74
py
neural-tangents
neural-tangents-main/tests/elementwise_numerical_test.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
1,045
28.055556
74
py
neural-tangents
neural-tangents-main/tests/test_utils.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
13,913
30.622727
80
py
neural-tangents
neural-tangents-main/tests/stax/elementwise_test.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
31,260
29.058654
83
py
neural-tangents
neural-tangents-main/tests/stax/stax_test.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
30,440
29.38024
80
py
neural-tangents
neural-tangents-main/tests/stax/combinators_test.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
4,604
26.909091
80
py
neural-tangents
neural-tangents-main/tests/stax/branching_test.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
7,845
28.946565
80
py
neural-tangents
neural-tangents-main/tests/stax/linear_test.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
58,065
30.782157
80
py
neural-tangents
neural-tangents-main/tests/stax/requirements_test.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
15,503
31.099379
80
py
neural-tangents
neural-tangents-main/tests/experimental/empirical_tf_test.py
# Copyright 2022 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
10,792
26.96114
78
py
neural-tangents
neural-tangents-main/docs/conf.py
# -*- coding: utf-8 -*- # # Configuration file for the Sphinx documentation builder. # # This file does only contain a selection of the most common options. For a # full list see the documentation: # http://www.sphinx-doc.org/en/master/config # -- Path setup ------------------------------------------------------------...
6,268
27.889401
79
py
neural-tangents
neural-tangents-main/neural_tangents/stax.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
4,458
25.861446
79
py
neural-tangents
neural-tangents-main/neural_tangents/__init__.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
1,238
35.441176
80
py
neural-tangents
neural-tangents-main/neural_tangents/_src/empirical.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
85,801
35.325995
117
py
neural-tangents
neural-tangents-main/neural_tangents/_src/batching.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
27,509
35.102362
81
py
neural-tangents
neural-tangents-main/neural_tangents/_src/predict.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
49,629
35.817507
127
py
neural-tangents
neural-tangents-main/neural_tangents/_src/monte_carlo.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
14,540
40.784483
151
py
neural-tangents
neural-tangents-main/neural_tangents/_src/stax/combinators.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
8,959
34
87
py
neural-tangents
neural-tangents-main/neural_tangents/_src/stax/requirements.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
39,172
33.913547
125
py
neural-tangents
neural-tangents-main/neural_tangents/_src/stax/linear.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
133,918
34.223304
115
py
neural-tangents
neural-tangents-main/neural_tangents/_src/stax/branching.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
16,445
33.623158
80
py
neural-tangents
neural-tangents-main/neural_tangents/_src/stax/elementwise.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
42,542
29.940364
109
py
neural-tangents
neural-tangents-main/neural_tangents/_src/utils/typing.py
# Copyright 2020 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
6,397
25.114286
103
py
neural-tangents
neural-tangents-main/neural_tangents/_src/utils/utils.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
19,310
28.618098
110
py
neural-tangents
neural-tangents-main/neural_tangents/_src/utils/rules.py
"""Structured derivatives rules.""" from .dataclasses import dataclass, field import functools from typing import Callable, Optional, Tuple, Dict, List, Union, Any from . import utils import jax from jax import lax from jax.core import JaxprEqn, ShapedArray, Primitive, Jaxpr, Var, AbstractValue, Literal from jax.inte...
31,709
27.3125
138
py
neural-tangents
neural-tangents-main/neural_tangents/_src/utils/dataclasses.py
# Copyright 2020 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
4,106
31.338583
80
py
neural-tangents
neural-tangents-main/neural_tangents/_src/utils/kernel.py
# Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
19,210
36.742633
103
py
neural-tangents
neural-tangents-main/neural_tangents/experimental/empirical_tf/empirical.py
# Copyright 2022 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
13,523
43.633663
168
py
CS-Unet
CS-Unet-main/test.py
import argparse import logging import os import random import sys import numpy as np import torch import torch.backends.cudnn as cudnn import torch.nn as nn from torch.utils.data import DataLoader from tqdm import tqdm from datasets.dataset_synapse import Synapse_dataset from datasets.dataset_ACDC import ACDCdataset fr...
7,236
46.300654
159
py
CS-Unet
CS-Unet-main/trainer_ACDC.py
#!/usr/bin/env python # -*- coding:utf-8 -*- import sys import logging import torch import torch.nn as nn import torch.optim as optim from torch.nn.modules.loss import CrossEntropyLoss import torchvision # import matplotlib.pyplot as plt from utils.utils import DiceLoss from torch.utils.data import DataLoader from data...
8,164
42.663102
132
py
CS-Unet
CS-Unet-main/metrics.py
import torch import numpy as np from hausdorff import hausdorff_distance from medpy.metric.binary import hd, dc def dice(pred, target): pred = pred.contiguous() target = target.contiguous() smooth = 0.00001 # intersection = (pred * target).sum(dim=2).sum(dim=2) pred_flat = pred.view(1, -1) tar...
4,492
29.773973
120
py
CS-Unet
CS-Unet-main/train.py
import argparse import logging import os import random import numpy as np import torch import torch.backends.cudnn as cudnn from networks.vision_transformer import CS_Unet as ViT_seg from trainer import trainer_synapse from trainer_ACDC import trainer_acdc from config import get_config parser = argparse.ArgumentParse...
5,517
43.144
110
py
CS-Unet
CS-Unet-main/trainer.py
import argparse import logging import os import random import sys import time import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from tensorboardX import SummaryWriter from torch.nn.modules.loss import CrossEntropyLoss from torch.utils.data import DataLoade...
9,360
45.572139
118
py
CS-Unet
CS-Unet-main/networks/vision_transformer.py
# coding=utf-8 from __future__ import absolute_import from __future__ import division from __future__ import print_function import copy import logging import math from os.path import join as pjoin import torch import torch.nn as nn import numpy as np from torch.nn import CrossEntropyLoss, Dropout, Softmax, Linear, ...
3,953
42.450549
113
py
CS-Unet
CS-Unet-main/networks/conv_swin_transformer_unet_skip_expand_decoder_sys.py
import torch import torch.nn as nn import torch.utils.checkpoint as checkpoint from einops import rearrange from timm.models.layers import DropPath, to_2tuple, trunc_normal_ from einops.layers.torch import Rearrange class Mlp(nn.Module): def __init__(self, dim, drop_path=0.2, layer_scale_init_value=0.7): ...
32,474
43.123641
217
py
CS-Unet
CS-Unet-main/datasets/dataset_synapse.py
import os import random import h5py import numpy as np import torch from scipy import ndimage from scipy.ndimage.interpolation import zoom from torch.utils.data import Dataset import json import torchvision.transforms as T from .aug import RandomAffine, GaussianBlur, To_PIL_Image,JointCompose, JointTo_Tensor def norma...
4,893
34.463768
106
py
CS-Unet
CS-Unet-main/datasets/dataset_ACDC.py
#!/usr/bin/env python # -*- coding:utf-8 -*- import os import random import numpy as np import torch from scipy import ndimage from scipy.ndimage.interpolation import zoom from torch.utils.data import Dataset from .aug import RandomAffine, GaussianBlur, To_PIL_Image,JointCompose, JointTo_Tensor import torchvision.tran...
2,871
34.02439
106
py
CS-Unet
CS-Unet-main/datasets/aug.py
import numpy as np import random import numbers from torchvision.transforms import functional as F from PIL import Image, ImageFilter import torch _pil_interpolation_to_str = { Image.NEAREST: 'PIL.Image.NEAREST', Image.BILINEAR: 'PIL.Image.BILINEAR', Image.BICUBIC: 'PIL.Image.BICUBIC', Image.LANCZOS: '...
9,525
39.194093
160
py
CS-Unet
CS-Unet-main/utils/test_ACDC.py
#!/usr/bin/env python # -*- coding:utf-8 -*- import logging import numpy as np import torch from torch.utils.data import DataLoader from tqdm import tqdm from utils.utils import test_single_volume def inference(args, model, testloader, test_save_path=None): logging.info("{} test iterations per epoch".format(len(...
1,585
45.647059
151
py
CS-Unet
CS-Unet-main/utils/utils.py
#!/usr/bin/env python # -*- coding:utf-8 -*- import numpy as np import torch from medpy import metric import torch.nn as nn from PIL import Image from torchvision import transforms import SimpleITK as sitk from scipy.ndimage import zoom class Normalize(): def __call__(self, sample): function = transforms...
6,398
35.152542
127
py
CS-Unet
CS-Unet-main/utils/test_Synapse.py
#!/usr/bin/env python # -*- coding:utf-8 -*- import logging import numpy as np import torch from torch.utils.data import DataLoader from tqdm import tqdm from utils.utils import test_single_volume def inference(args, model, testloader, test_save_path=None): logging.info("{} test iterations per epoch".format(len(...
1,598
50.580645
151
py
DeepPersonality
DeepPersonality-main/dpcv/__init__.py
import torch import sys import os current_path = os.path.dirname(os.path.abspath(__file__)) sys.path.append(current_path) # optionally print the sys.path for debugging) # print("in _ _init_ _.py sys.path:\n ",sys.path) device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
290
28.1
69
py
DeepPersonality
DeepPersonality-main/dpcv/tools/utils.py
# Copyright (C) 2020-2021, François-Guillaume Fernandez. # This program is licensed under the Apache License version 2. # See LICENSE or go to <https://www.apache.org/licenses/LICENSE-2.0.txt> for full license details. import torch from torch import Tensor from torch import nn from typing import List, Optional, Tuple...
2,449
29.246914
115
py
DeepPersonality
DeepPersonality-main/dpcv/tools/excitation_bp.py
import weakref import torch import math import torch.nn.functional as F # EPSILON_DOUBLE = torch.tensor(2.220446049250313e-16, dtype=torch.float64) EPSILON_SINGLE = torch.tensor(1.19209290E-07, dtype=torch.float32) SQRT_TWO_DOUBLE = torch.tensor(math.sqrt(2), dtype=torch.float32) SQRT_TWO_SINGLE = SQRT_TWO_DOUBLE.to(t...
21,113
33.726974
79
py
DeepPersonality
DeepPersonality-main/dpcv/tools/common.py
import os import torch import random import numpy as np import argparse def setup_config(args, cfg): # cfg.DATA_ROOT = args.data_root_dir if args.data_root_dir else cfg.DATA_ROOT cfg.LR_INIT = args.lr if args.lr else cfg.LR_INIT cfg.TRAIN_BATCH_SIZE = args.bs if args.bs else cfg.TRAIN_BATCH_SIZE cfg.M...
2,633
24.085714
81
py
DeepPersonality
DeepPersonality-main/dpcv/tools/cam.py
""" # Copyright (C) 2020-2021, François-Guillaume Fernandez. # This program is licensed under the Apache License version 2. # See LICENSE or go to <https://www.apache.org/licenses/LICENSE-2.0.txt> for full license details. # code modified from https://github.com/frgfm/torch-cam/tree/master/torchcam/cams """ from typing...
16,934
38.567757
117
py
DeepPersonality
DeepPersonality-main/dpcv/tools/draw.py
import math import os import matplotlib.pyplot as plt import numpy as np from PIL import Image import torch def show_confMat(confusion_mat, classes, set_name, out_dir, epoch=999, verbose=False, perc=False): cls_num = len(classes) confusion_mat_tmp = confusion_mat.copy() for i in range(len(classes)): ...
5,948
33.189655
114
py
DeepPersonality
DeepPersonality-main/dpcv/tools/cam_vis.py
""" code modified from https://github.com/frgfm/torch-cam/tree/master/torchcam """ import torch from matplotlib import cm import numpy as np from PIL import Image def to_pil_image(pic, mode=None): """Convert a tensor or an ndarray to PIL Image. See :class:`~torchvision.transforms.ToPILImage` for more details...
4,942
35.88806
112
py
DeepPersonality
DeepPersonality-main/dpcv/checkpoint/save.py
import os import torch def save_model(epoch, best_acc, model, optimizer, output_dir, cfg): if isinstance(optimizer, list): optimizer = optimizer[1] # for cr net checkpoint = { "model_state_dict": model.state_dict(), "optimizer_state_dict": optimizer.state_dict(), "epoch": epoc...
1,025
30.090909
107
py
DeepPersonality
DeepPersonality-main/dpcv/checkpoint/load.py
import re from collections import OrderedDict def load_state_dict(module, state_dict, strict=False, logger=None): """Load state_dict to a module. This method is modified from :meth:`torch.nn.Module.load_state_dict`. Default value for ``strict`` is set to ``False`` and the message for param mismatch w...
7,798
35.787736
79
py
DeepPersonality
DeepPersonality-main/dpcv/experiment/exp_runner.py
import os import json import numpy as np import torch from datetime import datetime from dpcv.data.datasets.build import build_dataloader from dpcv.modeling.networks.build import build_model from dpcv.modeling.loss.build import build_loss_func from dpcv.modeling.solver.build import build_solver, build_scheduler from dp...
6,336
36.720238
119
py
DeepPersonality
DeepPersonality-main/dpcv/exps_first_stage/13_tpn_on_personality.py
import torch.nn as nn import torch.optim as optim from dpcv.config.tpn_cfg import cfg from dpcv.modeling.networks.TSN2D import get_tpn_model from dpcv.tools.common import setup_seed, setup_config from dpcv.tools.logger import make_logger from dpcv.tools.common import parse_args from dpcv.evaluation.summary import Train...
1,291
31.3
101
py
DeepPersonality
DeepPersonality-main/dpcv/exps_first_stage/04_cr_audiovisual_network.py
import torch.nn as nn import torch.optim as optim from datetime import datetime from dpcv.config.crnet_cfg import cfg as cr_cfg from dpcv.engine.crnet_trainer import CRNetTrainer from dpcv.tools.logger import make_logger from dpcv.modeling.networks.cr_net import get_crnet_model from dpcv.checkpoint.save import save_mod...
3,449
40.071429
119
py
DeepPersonality
DeepPersonality-main/dpcv/exps_first_stage/08_senet_on_personality.py
import torch.optim as optim import torch.nn as nn from dpcv.config.senet_cfg import cfg from dpcv.modeling.module.se_resnet import se_resnet50 from dpcv.tools.common import setup_seed, setup_config from dpcv.tools.logger import make_logger from dpcv.tools.common import parse_args from dpcv.evaluation.summary import Tra...
1,314
31.875
101
py
DeepPersonality
DeepPersonality-main/dpcv/exps_first_stage/09_hrnet_on_personality.py
import torch.optim as optim import torch.nn as nn from dpcv.config.hrnet_cls_cfg import cfg from dpcv.modeling.networks.hr_net_cls import get_hr_net_model from dpcv.tools.common import setup_seed, setup_config from dpcv.tools.logger import make_logger from dpcv.tools.common import parse_args from dpcv.evaluation.summar...
1,330
32.275
101
py
DeepPersonality
DeepPersonality-main/dpcv/exps_first_stage/01_deep_bimodal_regression_image.py
import torch.nn as nn import torch.optim as optim from dpcv.config.deep_bimodal_regression_cfg import cfg from dpcv.engine.bi_modal_trainer import ImageModalTrainer from dpcv.modeling.networks.dan import get_model from dpcv.tools.common import setup_seed, setup_config from dpcv.tools.logger import make_logger from dpcv...
1,337
33.307692
101
py
DeepPersonality
DeepPersonality-main/dpcv/exps_first_stage/05_persEmoN.py
import torch.optim as optim from dpcv.config.per_emo_cfg import cfg from dpcv.modeling.networks.sphereface_net import get_pers_emo_model from dpcv.tools.common import setup_seed, setup_config from dpcv.tools.logger import make_logger from dpcv.tools.common import parse_args from dpcv.evaluation.summary import TrainSumm...
1,363
33.1
101
py
DeepPersonality
DeepPersonality-main/dpcv/exps_first_stage/07_interpret_audio_net.py
import torch import torch.nn as nn import torch.optim as optim import torchaudio from dpcv.config.interpret_aud_cfg import cfg from dpcv.engine.bi_modal_trainer import AudioTrainer from dpcv.modeling.networks.audio_interpretability_net import get_model from dpcv.tools.common import setup_seed, setup_config from dpcv.to...
3,415
34.583333
101
py