repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
wsireg | wsireg-master/wsireg/utils/im_utils.py | import multiprocessing
import warnings
from concurrent.futures import ThreadPoolExecutor
from pathlib import Path
from typing import List, Optional, Tuple, Union
import cv2
import dask.array as da
import numpy as np
import SimpleITK as sitk
import zarr
from czifile import CziFile
from tifffile import (
OmeXml,
... | 45,655 | 28.173163 | 97 | py |
wsireg | wsireg-master/wsireg/utils/reg_utils.py | import json
from pathlib import Path
from typing import Dict, List, Union
import itk
import numpy as np
import SimpleITK as sitk
from wsireg.parameter_maps.reg_model import RegModel
from wsireg.utils.itk_im_conversions import itk_image_to_sitk_image
NP_TO_SITK_DTYPE = {
np.dtype(np.int8): 0,
np.dtype(np.uint... | 6,736 | 27.42616 | 109 | py |
wsireg | wsireg-master/wsireg/utils/__init__.py | 0 | 0 | 0 | py | |
wsireg | wsireg-master/wsireg/parameter_maps/preprocessing.py | from enum import Enum
from typing import Callable, Dict, List, NamedTuple, Optional, Tuple, Union
from pydantic import BaseModel, validator
class ImageType(str, Enum):
"""Set the photometric interpretation of the image
* "FL": background is black (fluorescence)
* "BF": Background is white (brightfield)
... | 4,110 | 29.007299 | 118 | py |
wsireg | wsireg-master/wsireg/parameter_maps/reg_params.py | DEFAULT_REG_PARAM_MAPS = {
'rigid': {
"AutomaticScalesEstimation": ['true'],
"AutomaticTransformInitialization": ['true'],
"BSplineInterpolationOrder": ['1'],
"CompressResultImage": ['true'],
"DefaultPixelValue": ['0'],
"ErodeMask": ['false'],
"FinalBSplineInt... | 22,148 | 35.250409 | 73 | py |
wsireg | wsireg-master/wsireg/parameter_maps/transformations.py | BASE_RIG_TFORM = dict(
{
"Transform": ["EulerTransform"],
"NumberOfParameters": ["3"],
"TransformParameters": ["0", "0", "0"],
"InitialTransformParametersFileName": ["NoInitialTransform"],
"HowToCombineTransforms": ["Compose"],
"FixedImageDimension": ["2"],
"M... | 3,312 | 33.154639 | 69 | py |
wsireg | wsireg-master/wsireg/parameter_maps/__init__.py | """Parameter maps."""
__author__ = """Nathan Heath Patterson"""
__email__ = 'heath.patterson@vanderbilt.edu'
__version__ = '0.0.1'
| 132 | 21.166667 | 44 | py |
wsireg | wsireg-master/wsireg/parameter_maps/reg_model.py | from enum import Enum, EnumMeta
from pathlib import Path
from typing import Dict, List, Tuple, Union
from wsireg.parameter_maps.reg_params import DEFAULT_REG_PARAM_MAPS
DEFAULT_REG_PARAM_MAPS.keys()
PATH_LIKE = Union[str, Path]
def _elx_lineparser(
line: str,
) -> Union[Tuple[str, List[str]], Tuple[None, None]]... | 3,622 | 32.859813 | 93 | py |
wsireg | wsireg-master/wsireg/reg_shapes/reg_shapes.py | import json
from pathlib import Path
from typing import Tuple, Union, List, Dict, Any
import cv2
import numpy as np
from wsireg.reg_transforms.reg_transform_seq import RegTransformSeq
from wsireg.utils.shape_utils import (
get_int_dtype,
insert_transformed_pts_gj,
invert_nonrigid_transforms,
scale_sha... | 8,937 | 29.505119 | 104 | py |
wsireg | wsireg-master/wsireg/reg_shapes/__init__.py | from .reg_shapes import RegShapes # noqa: F401
| 48 | 23.5 | 47 | py |
wsireg | wsireg-master/tests/test_reg_transform_seq.py | import os
from pathlib import Path
import pytest
from wsireg.reg_transforms.reg_transform_seq import RegTransformSeq
HERE = os.path.dirname(__file__)
FIXTURES_DIR = os.path.join(HERE, "fixtures")
@pytest.mark.usefixtures("complex_transform_larger")
def test_RegTransformSeq_from_dict(complex_transform_larger):
... | 2,473 | 27.767442 | 70 | py |
wsireg | wsireg-master/tests/test_im_read.py | import os
import numpy as np
import pytest
from wsireg.parameter_maps.preprocessing import ImagePreproParams
from wsireg.reg_images.loader import reg_image_loader
# private data logic borrowed from https://github.com/cgohlke/tifffile/tests/test_tifffile.py
HERE = os.path.dirname(__file__)
PRIVATE_DIR = os.path.join(... | 11,016 | 33.53605 | 93 | py |
wsireg | wsireg-master/tests/test_wsireg_config.py | import os
from pathlib import Path
from typing import Union
import cv2
import numpy as np
import pytest
import SimpleITK as sitk
from wsireg.reg_images.loader import reg_image_loader
from wsireg.reg_shapes import RegShapes
from wsireg.utils.config_utils import parse_check_reg_config
from wsireg.wsireg2d import WsiReg... | 5,460 | 28.518919 | 80 | py |
wsireg | wsireg-master/tests/conftest.py | import pytest
from tests.fixtures.im_fixtures import (
dask_im_gry_np,
dask_im_mch_np,
dask_im_rgb_np,
disk_im_gry,
disk_im_gry_pyr,
disk_im_mch,
disk_im_mch_notile,
disk_im_mch_pyr,
disk_im_rgb,
disk_im_rgb_pyr,
im_gry_np,
im_mch_np,
im_rgb_np,
im_rgb_np_uneven,... | 702 | 20.30303 | 47 | py |
wsireg | wsireg-master/tests/test_reg_image.py | import os
import itk
import pytest
import SimpleITK as sitk
from wsireg.reg_images.loader import reg_image_loader
HERE = os.path.dirname(__file__)
GEOJSON_FP = os.path.join(HERE, "fixtures/polygons.geojson")
@pytest.mark.usefixtures("disk_im_mch")
def test_reg_image_loader_image_fp_mc_std_prepro(disk_im_mch):
r... | 16,398 | 37.768322 | 79 | py |
wsireg | wsireg-master/tests/test_shapes.py | import os
from copy import deepcopy
import numpy as np
import pytest
from wsireg.reg_shapes import RegShapes
HERE = os.path.dirname(__file__)
GEOJSON_FP = os.path.join(HERE, "fixtures/polygons.geojson")
@pytest.mark.usefixtures("complex_transform")
def test_RegShapes_transform(complex_transform):
rs = RegShape... | 2,064 | 25.474359 | 74 | py |
wsireg | wsireg-master/tests/test_im_utils.py | import os
import dask.array as da
import numpy as np
import pytest
import zarr
from tifffile import imread
from wsireg.parameter_maps.preprocessing import ImagePreproParams
from wsireg.utils.im_utils import (
CziRegImageReader,
czi_tile_grayscale,
ensure_dask_array,
get_sitk_image_info,
get_tifffi... | 16,740 | 30.706439 | 93 | py |
wsireg | wsireg-master/tests/__init__.py | """Unit test package for wsireg."""
| 36 | 17.5 | 35 | py |
wsireg | wsireg-master/tests/test_writer.py | from pathlib import Path
import os
import random
import string
import numpy as np
import pytest
from tifffile import imread
import dask.array as da
from wsireg.reg_images.loader import reg_image_loader
from wsireg.reg_images.merge_reg_image import MergeRegImage
from wsireg.reg_transforms.reg_transform_seq import RegT... | 10,950 | 31.208824 | 78 | py |
wsireg | wsireg-master/tests/test_wsireg.py | import os
import random
import string
from pathlib import Path
import numpy as np
import pytest
from ome_types import from_xml
from tifffile import TiffFile, imread
import dask
from wsireg.parameter_maps.preprocessing import ImagePreproParams
from wsireg.reg_images.loader import reg_image_loader
from wsireg.wsireg2d ... | 32,409 | 26.939655 | 78 | py |
wsireg | wsireg-master/tests/test_console_scripts.py | import os
from pathlib import Path
HERE = os.path.dirname(__file__)
FIXTURES_DIR = os.path.join(HERE, "fixtures")
PRIVATE_DIR = os.path.join(HERE, "private_data")
config1_fp = str(Path(FIXTURES_DIR) / "test-config1-cmd-line.yaml")
def test_wsireg2d_entrypoint():
exit_status = os.system('wsireg2d --help')
a... | 469 | 22.5 | 70 | py |
wsireg | wsireg-master/tests/fixtures/im_fixtures.py | import pytest
import os
import dask.array as da
import numpy as np
import zarr
from tifffile import TiffWriter, imwrite
HERE = os.path.dirname(__file__)
GEOJSON_FP = os.path.join(HERE, "polygons.geojson")
@pytest.fixture
def im_gry_np():
return np.random.randint(0, 255, (2048, 2048), dtype=np.uint16)
@pytest.f... | 4,954 | 24.280612 | 79 | py |
wsireg | wsireg-master/tests/fixtures/transform_fixtures.py | import pickle
import numpy as np
import pytest
@pytest.fixture
def complex_transform():
return {
'initial': [
{
'Transform': ['EulerTransform'],
'NumberOfParameters': ['3'],
'TransformParameters': [
'1.5707963267948966',
... | 99,567 | 40.923368 | 77 | py |
wsireg | wsireg-master/tests/fixtures/__init__.py | 0 | 0 | 0 | py | |
wsireg | wsireg-master/docs/conf.py | #!/usr/bin/env python
#
# wsireg documentation build configuration file, created by
# sphinx-quickstart on Fri Jun 9 13:47:02 2017.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All ... | 4,974 | 28.790419 | 77 | py |
AT-on-AD | AT-on-AD-main/test_fmnist.py | import argparse
import logging
import numpy as np
import os
import os.path as osp
import torch
import torch.nn as nn
class MyLR(nn.Module):
def __init__(self, input_size, num_classes):
super(MyLR, self).__init__()
self.linear = nn.Linear(input_size, num_classes)
def forward(self, x):
... | 3,685 | 28.023622 | 182 | py |
AT-on-AD | AT-on-AD-main/test_cifar_vgg.py | import argparse
import logging
import numpy as np
import os
import os.path as osp
import torch
import torch.nn as nn
cfg = {
'VGG11': [64, 'M', 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M'],
'VGG13': [64, 64, 'M', 128, 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M'],
'VGG16': [64, 64, 'M',... | 4,759 | 29.709677 | 186 | py |
AT-on-AD | AT-on-AD-main/test_syn.py | import argparse
import logging
import numpy as np
import os
import os.path as osp
import torch
import torch.nn as nn
class MyLR(nn.Module):
def __init__(self, input_size, num_classes):
super(MyLR, self).__init__()
self.linear = nn.Linear(input_size, num_classes)
def forward(self, x):
... | 3,879 | 28.846154 | 182 | py |
AT-on-AD | AT-on-AD-main/train_syn.py | import argparse
import copy
import logging
import numpy as np
import os
import os.path as osp
import time
from tqdm import tqdm
import torch
import torch.nn as nn
from advertorch.attacks.one_step_gradient import GradientSignAttack, GradientAttack
from advertorch.attacks.iterative_projected_gradient import LinfPGDAttac... | 6,544 | 29.584112 | 182 | py |
AT-on-AD | AT-on-AD-main/process_data.py | import argparse
import numpy as np
import os
import os.path as osp
import torch
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('--dataset', type=str, default='syn',
choices=['syn', 'mnist', 'cifar', 'fmnist', 'cauchy', 'cauchy_2', 'levy_1.5'])
return parser.parse_arg... | 10,126 | 33.56314 | 186 | py |
AT-on-AD | AT-on-AD-main/test_cifar.py | import argparse
import logging
import numpy as np
import os
import os.path as osp
import torch
import torch.nn as nn
class CifarLR(nn.Module):
def __init__(self, input_size, hidden=200, num_classes=2):
super(CifarLR, self).__init__()
self.fc1 = nn.Linear(input_size, hidden)
self.relu = nn.R... | 3,914 | 28.43609 | 182 | py |
AT-on-AD | AT-on-AD-main/test_mnist.py | import argparse
import logging
import numpy as np
import os
import os.path as osp
import torch
import torch.nn as nn
class MyLR(nn.Module):
def __init__(self, input_size, num_classes):
super(MyLR, self).__init__()
self.linear = nn.Linear(input_size, num_classes)
def forward(self, x):
... | 3,683 | 28.007874 | 182 | py |
AT-on-AD | AT-on-AD-main/train_fmnist.py | import argparse
import copy
import logging
import numpy as np
import os
import os.path as osp
import time
from tqdm import tqdm
import torch
import torch.nn as nn
from torchvision import transforms
from advertorch.attacks.one_step_gradient import GradientSignAttack, GradientAttack
from advertorch.attacks.iterative_pro... | 6,889 | 30.176471 | 182 | py |
AT-on-AD | AT-on-AD-main/train_cifar_vgg.py | import argparse
import copy
import logging
import numpy as np
import os
import os.path as osp
import time
from tqdm import tqdm
import torch
import torch.nn as nn
from torchvision import transforms
from advertorch.attacks.one_step_gradient import GradientSignAttack, GradientAttack
from advertorch.attacks.iterative_pro... | 7,950 | 31.060484 | 186 | py |
AT-on-AD | AT-on-AD-main/train_cifar.py | import argparse
import copy
import logging
import numpy as np
import os
import os.path as osp
import time
from tqdm import tqdm
import torch
import torch.nn as nn
from torchvision import transforms
from advertorch.attacks.one_step_gradient import GradientSignAttack, GradientAttack
from advertorch.attacks.iterative_pro... | 7,120 | 30.50885 | 182 | py |
AT-on-AD | AT-on-AD-main/train_mnist.py | import argparse
import copy
import logging
import numpy as np
import os
import os.path as osp
import time
from tqdm import tqdm
import torch
import torch.nn as nn
from torchvision import transforms
from advertorch.attacks.one_step_gradient import GradientSignAttack, GradientAttack
from advertorch.attacks.iterative_pro... | 6,887 | 30.167421 | 182 | py |
aidgn | aidgn-main/domainbed/command_launchers.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
"""
A command launcher launches a list of commands on a cluster; implement your own
launcher to add support for your cluster. We've provided an example launcher
which runs all commands serially on the local machine.
"""
import subprocess
import ti... | 1,792 | 27.919355 | 79 | py |
aidgn | aidgn-main/domainbed/model_selection.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import itertools
import numpy as np
def get_test_records(records):
"""Given records with a common test env, get the test records (i.e. the
records with *only* that single test env and no other test envs)"""
return records.filter(lambda... | 5,163 | 35.366197 | 80 | py |
aidgn | aidgn-main/domainbed/networks.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision.models
import math
from domainbed.lib import wide_resnet
import copy
def remove_batch_norm_from_resnet(model):
fuse = torch.nn.utils.fusion.fuse_conv_bn_ev... | 7,258 | 30.154506 | 80 | py |
aidgn | aidgn-main/domainbed/datasets.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os
import torch
from PIL import Image, ImageFile
from torchvision import transforms
import torchvision.datasets.folder
from torch.utils.data import TensorDataset, Subset
from torchvision.datasets import MNIST, ImageFolder
from torchvision.tr... | 13,608 | 33.805627 | 105 | py |
aidgn | aidgn-main/domainbed/__init__.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
| 72 | 23.333333 | 70 | py |
aidgn | aidgn-main/domainbed/algorithms.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.autograd as autograd
from torch.autograd import Variable
import math
import copy
import numpy as np
from collections import defaultdict
from domainbed import networks... | 51,299 | 35.305732 | 232 | py |
aidgn | aidgn-main/domainbed/hparams_registry.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import numpy as np
from domainbed.lib import misc
def _define_hparam(hparams, hparam_name, default_val, random_val_fn):
hparams[hparam_name] = (hparams, hparam_name, default_val, random_val_fn)
def _hparams(algorithm, dataset, random_seed):... | 5,819 | 36.792208 | 77 | py |
aidgn | aidgn-main/domainbed/test/test_datasets.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
"""Unit tests."""
import argparse
import itertools
import json
import os
import subprocess
import sys
import time
import unittest
import uuid
import torch
from domainbed import datasets
from domainbed import hparams_registry
from domainbed impor... | 1,454 | 28.1 | 80 | py |
aidgn | aidgn-main/domainbed/test/test_hparams_registry.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import unittest
import itertools
from domainbed import hparams_registry
from domainbed import datasets
from domainbed import algorithms
from parameterized import parameterized
class TestHparamsRegistry(unittest.TestCase):
@parameterized.exp... | 815 | 36.090909 | 86 | py |
aidgn | aidgn-main/domainbed/test/test_networks.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import argparse
import itertools
import json
import os
import subprocess
import sys
import time
import unittest
import uuid
import torch
from domainbed import datasets
from domainbed import hparams_registry
from domainbed import algorithms
from d... | 1,181 | 30.105263 | 79 | py |
aidgn | aidgn-main/domainbed/test/test_models.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
"""Unit tests."""
import argparse
import itertools
import json
import os
import subprocess
import sys
import time
import unittest
import uuid
import torch
from domainbed import datasets
from domainbed import hparams_registry
from domainbed impor... | 1,427 | 31.454545 | 91 | py |
aidgn | aidgn-main/domainbed/test/__init__.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
| 73 | 17.5 | 70 | py |
aidgn | aidgn-main/domainbed/test/helpers.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import torch
DEBUG_DATASETS = ['Debug28', 'Debug224']
def make_minibatches(dataset, batch_size):
"""Test helper to make a minibatches array like train.py"""
minibatches = []
for env in dataset:
X = torch.stack([env[i][0] for i... | 509 | 30.875 | 70 | py |
aidgn | aidgn-main/domainbed/test/test_model_selection.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
"""Unit tests."""
import argparse
import itertools
import json
import os
import subprocess
import sys
import time
import unittest
import uuid
import torch
from domainbed import model_selection
from domainbed.lib.query import Q
from parameterize... | 4,334 | 29.744681 | 77 | py |
aidgn | aidgn-main/domainbed/test/scripts/test_train.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# import argparse
# import itertools
import json
import os
import subprocess
# import sys
# import time
import unittest
import uuid
import torch
# import datasets
# import hparams_registry
# import algorithms
# import networks
# from parameterize... | 1,654 | 32.1 | 83 | py |
aidgn | aidgn-main/domainbed/test/scripts/test_sweep.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import argparse
import itertools
import json
import os
import subprocess
import sys
import time
import unittest
import uuid
import torch
from domainbed import datasets
from domainbed import hparams_registry
from domainbed import algorithms
from d... | 5,273 | 39.569231 | 89 | py |
aidgn | aidgn-main/domainbed/test/scripts/__init__.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
| 73 | 17.5 | 70 | py |
aidgn | aidgn-main/domainbed/test/scripts/test_collect_results.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import argparse
import itertools
import json
import os
import subprocess
import sys
import time
import unittest
import uuid
import torch
from domainbed import datasets
from domainbed import hparams_registry
from domainbed import algorithms
from d... | 3,718 | 31.622807 | 96 | py |
aidgn | aidgn-main/domainbed/test/lib/test_misc.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import unittest
from domainbed.lib import misc
class TestMisc(unittest.TestCase):
def test_make_weights_for_balanced_classes(self):
dataset = [('A', 0), ('B', 1), ('C', 0), ('D', 2), ('E', 3), ('F', 0)]
result = misc.make_weig... | 541 | 35.133333 | 78 | py |
aidgn | aidgn-main/domainbed/test/lib/test_query.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import unittest
from domainbed.lib.query import Q, make_selector_fn
class TestQuery(unittest.TestCase):
def test_everything(self):
numbers = Q([1, 4, 2])
people = Q([
{'name': 'Bob', 'age': 40},
{'name':... | 1,513 | 29.28 | 78 | py |
aidgn | aidgn-main/domainbed/test/lib/__init__.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
| 73 | 17.5 | 70 | py |
aidgn | aidgn-main/domainbed/scripts/save_images.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
"""
Save some representative images from each dataset to disk.
"""
import random
import torch
import argparse
from domainbed import hparams_registry
from domainbed import datasets
import imageio
import os
from tqdm import tqdm
if __name__ == '__ma... | 2,029 | 38.803922 | 113 | py |
aidgn | aidgn-main/domainbed/scripts/sweep.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
"""
Run sweeps
"""
import argparse
import copy
import getpass
import hashlib
import json
import os
import random
import shutil
import time
import uuid
import numpy as np
import torch
from domainbed import datasets
from domainbed import hparams_r... | 7,332 | 36.035354 | 92 | py |
aidgn | aidgn-main/domainbed/scripts/download.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from torchvision.datasets import MNIST
import xml.etree.ElementTree as ET
from zipfile import ZipFile
import argparse
import tarfile
import shutil
import gdown
import uuid
import json
import os
from wilds.datasets.camelyon17_dataset import Camelyo... | 14,359 | 31.860412 | 109 | py |
aidgn | aidgn-main/domainbed/scripts/collect_results.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import collections
import argparse
import functools
import glob
import pickle
import itertools
import json
import os
import random
import sys
import numpy as np
import tqdm
from domainbed import datasets
from domainbed import algorithms
from do... | 6,272 | 33.092391 | 78 | py |
aidgn | aidgn-main/domainbed/scripts/__init__.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
| 72 | 23.333333 | 70 | py |
aidgn | aidgn-main/domainbed/scripts/train.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import argparse
import collections
import json
import os
import random
import sys
import time
import uuid
import numpy as np
import PIL
import torch
import torchvision
import torch.utils.data
from matplotlib import pyplot as plt
from domainbed im... | 10,857 | 37.778571 | 82 | py |
aidgn | aidgn-main/domainbed/scripts/list_top_hparams.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
"""
Example usage:
python -u -m domainbed.scripts.list_top_hparams \
--input_dir domainbed/misc/test_sweep_data --algorithm ERM \
--dataset VLCS --test_env 0
"""
import collections
import argparse
import functools
import glob
import pick... | 5,440 | 34.796053 | 79 | py |
aidgn | aidgn-main/domainbed/lib/tsne.py | import argparse
import os
import pickle
import numpy as np
import torch
from matplotlib import pyplot as plt
from sklearn.manifold import TSNE
# def plot_TNSE(X_2d_tr, tr_labels, label_target_names, filename):
# colors = ["red", "green", "blue", "black", "brown", "grey", "orange", "yellow", "pink", "cyan", "mage... | 3,525 | 37.326087 | 142 | py |
aidgn | aidgn-main/domainbed/lib/reporting.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import collections
import json
import os
import tqdm
from domainbed.lib.query import Q
def load_records(path):
records = []
for i, subdir in tqdm.tqdm(list(enumerate(os.listdir(path))),
ncols=80,
... | 1,288 | 30.439024 | 79 | py |
aidgn | aidgn-main/domainbed/lib/misc.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
"""
Things that don't belong anywhere else
"""
import hashlib
import json
import os
import sys
from shutil import copyfile
from collections import OrderedDict
from numbers import Number
import operator
import numpy as np
import torch
import torch... | 7,663 | 28.251908 | 91 | py |
aidgn | aidgn-main/domainbed/lib/wide_resnet.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
"""
From https://github.com/meliketoy/wide-resnet.pytorch
"""
import sys
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.init as init
from torch.autograd import Variable
def conv3x3(in_plane... | 3,242 | 29.885714 | 79 | py |
aidgn | aidgn-main/domainbed/lib/query.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
"""Small query library."""
import collections
import inspect
import json
import types
import unittest
import warnings
import math
import numpy as np
def make_selector_fn(selector):
"""
If selector is a function, return selector.
Oth... | 5,134 | 27.060109 | 79 | py |
aidgn | aidgn-main/domainbed/lib/fast_data_loader.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import torch
class _InfiniteSampler(torch.utils.data.Sampler):
"""Wraps another Sampler to yield an infinite stream."""
def __init__(self, sampler):
self.sampler = sampler
def __iter__(self):
while True:
fo... | 2,156 | 28.148649 | 79 | py |
VP-Net | VP-Net-master/fusion_net.py | # -*- coding: utf-8 -*-
"""
Created on Thu Jan 14 15:52:20 2021
@author: KunLi
"""
#%%
import tensorflow as tf
import numpy as np
def vp_net( n , M_input, P_input, X_output):
layers_predict = []
layers_symetric = [] ... | 6,359 | 41.4 | 152 | py |
VP-Net | VP-Net-master/test.py | # -*- coding: utf-8 -*-
"""
Created on Thu Jan 21 11:43:18 2021
@author: KunLi
"""
import os
import numpy as np
import scipy.io as sio
# =============================================================================
# ms_path = 'E:\datasets\\3_QB-Wuhan\\crop_xj_30_01_smooth_down\mat10' ... | 7,307 | 34.475728 | 134 | py |
VP-Net | VP-Net-master/utils.py | # -*- coding: utf-8 -*-
"""
License: MIT
@author: gaj
E-mail: anjing_guo@hnu.edu.cn
"""
import cv2
import numpy as np
from scipy import ndimage
from scipy import signal
import scipy.misc as misc
def upsample_bilinear(image, ratio):
h,w,c = image.shape
re_image = cv2.resize(image, (w*ratio, h*ratio), cv2.... | 13,092 | 34.675749 | 296 | py |
VP-Net | VP-Net-master/data_prepare.py | # something about making dataset
def single_mat_64_no_down(used_ref, used_ms, used_pan):
# ### '''normalization''' 已标准化
# =============================================================================
# max_patch, min_patch = np.max(used_ref, axis=(0,1)), np.min(used_ref, axis=(0,1))
# u... | 7,721 | 40.294118 | 166 | py |
VP-Net | VP-Net-master/metrics.py | # -*- coding: utf-8 -*-
"""
License: GNU-3.0
Code Reference:https://github.com/wasaCheney/IQA_pansharpening_python
"""
import numpy as np
from scipy import ndimage
import cv2
from scipy.signal import convolve2d
def partial_sums(x, kernel_size=8):
"""Calculate partial sums of array in boxes (kernel_size x kern... | 20,138 | 32.677258 | 132 | py |
VP-Net | VP-Net-master/train.py | # -*- coding: utf-8 -*-
"""
Created on Tue Jan 12 11:58:09 2021
@author: kunLi
"""
# -*- coding: utf-8 -*-
import os
import numpy as np
import scipy.io as sio
# First, you need to make your own training dataset ----
GF2_train_from_single_pic160 = sio.loadmat('E:\datasets\\4_GF1_GF2\\GF2\\crop_xj_smooth_down... | 5,434 | 37.006993 | 169 | py |
mff | mff-master/setup.py | from setuptools import find_packages, setup, Extension
import numpy
tricube_cpp_module = Extension(
'mff.interpolation.tricube_cpp._tricube',
sources=["mff/interpolation/tricube_cpp/tricube_module.c", "mff/interpolation/tricube_cpp/_tricube.c"],
include_dirs=[numpy.get_include()]
)
with open("README.md", ... | 1,386 | 29.822222 | 107 | py |
mff | mff-master/tests/test_mff.py | import unittest
import mff
class TestMFFModels(unittest.TestCase):
def test_upper(self):
self.assertEqual('foo'.upper(), 'FOO')
if __name__ == '__main__':
unittest.main()
| 192 | 13.846154 | 46 | py |
mff | mff-master/tests/__init__.py | from tests.test_mff import TestMFFModels
| 41 | 20 | 40 | py |
mff | mff-master/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,686 | 28.588496 | 79 | py |
mff | mff-master/mff/gp.py | # -*- coding: utf-8 -*-
import logging
import numpy as np
from scipy.linalg import cho_solve, cholesky, solve_triangular
from scipy.optimize import fmin_l_bfgs_b
from mff import interpolation, kernels
logger = logging.getLogger(__name__)
class GaussianProcess(object):
""" Gaussian process class
Class of G... | 32,047 | 40.89281 | 114 | py |
mff | mff-master/mff/test.py | import os
from os import listdir
from os.path import isfile, join
import logging
import numpy as np
from ase import Atoms
import mff
from mff import models, calculators, utility
from mff import configurations as cfg
def get_potential(confs):
pot = 0
for conf in confs:
el1 = conf[:, 3]
el2 = co... | 14,943 | 40.281768 | 171 | py |
mff | mff-master/mff/utility.py | import json
import os
import sys
import time
from itertools import combinations_with_replacement
from pathlib import Path
import numpy as np
from scipy.spatial.distance import cdist
from asap3.analysis import FullCNA
from ase.io import read
from mff import configurations, models
from mff.gp import GaussianProcess
# ... | 35,709 | 39.350282 | 189 | py |
mff | mff-master/mff/error_measures.py | import numpy as np
def MAEF(tst_confs, tst_forces, gp):
"""Mean Absolute Error on Force
Calculated the absolute error done on the force vectors
Args:
tst_confs (list): Configurations in the test set
tst_forces (array): Forces in the test set
gp (class): Trained gp class
Retu... | 2,356 | 27.059524 | 104 | py |
mff | mff-master/mff/configurations.py | # -*- coding: utf-8 -*-
import json
import logging
from abc import ABCMeta, abstractmethod
from pathlib import Path
from random import shuffle
import numpy as np
from scipy.spatial.distance import cdist
from asap3 import FullNeighborList
from ase.io import read
logger = logging.getLogger(__name__)
class MissingDa... | 10,423 | 35.704225 | 105 | py |
mff | mff-master/mff/advanced_sampling.py | from mff.gp import GaussianProcess
from itertools import product, combinations_with_replacement
from scipy.spatial.distance import cdist
from mff import kernels
from mff.configurations import carve_from_snapshot
from mff.models import TwoBodyTwoSpeciesModel, CombinedTwoSpeciesModel
from mff.models import TwoBodySingle... | 42,252 | 50.030193 | 198 | py |
mff | mff-master/mff/__init__.py | import os
from .gp import GaussianProcess
Mffpath = __path__[0] + "/cache/"
if not os.path.exists(Mffpath):
os.mkdir(Mffpath)
__all__ = [GaussianProcess]
| 162 | 13.818182 | 33 | py |
mff | mff-master/mff/calculators.py | # -*- coding: utf-8 -*-
import logging
from abc import ABCMeta, abstractmethod
from itertools import combinations_with_replacement, islice
from pathlib import Path
import numpy as np
from asap3 import FullNeighborList
from ase.calculators.calculator import Calculator, all_changes
logger = logging.getLogger(__name__... | 25,108 | 37.275915 | 112 | py |
mff | mff-master/mff/interpolation/spline1d.py | import numpy as np
from scipy.interpolate import InterpolatedUnivariateSpline
class Spline1D(InterpolatedUnivariateSpline):
def __init__(self, x_range, f):
"""
:param x_range: 1 dimensional array
:param f: 1-dimensional array
"""
super(Spline1D, self).__init__(x_range, f... | 1,211 | 21.444444 | 71 | py |
mff | mff-master/mff/interpolation/__init__.py | from .spline1d import Spline1D
from .tricube_cpp import Spline3D
__all__ = [Spline1D, Spline3D]
| 97 | 18.6 | 33 | py |
mff | mff-master/mff/interpolation/tricube_fortran/__init__.py | import numpy as np
# noinspection PyUnresolvedReferences
from mff.interpolation.tricube_fortran import _tricube
class Spline3D(object):
def __init__(self, x, y, z, f):
assert f.shape == (x.size, y.size, z.size), 'dimensions do not match f'
assert np.all(np.diff(x) > 0) & np.all(np.diff(y) > 0) &... | 4,225 | 31.75969 | 105 | py |
mff | mff-master/mff/interpolation/tricube_cpp/__init__.py | import numpy as np
from mff.interpolation.tricube_cpp import _tricube
class Spline3D(object):
def __init__(self, x, y, z, f):
assert f.shape == (x.size, y.size, z.size), "dimensions do not match f"
assert np.all(np.diff(x) > 0) & np.all(np.diff(y) > 0) & np.all(np.diff(z) > 0), \
"x... | 9,856 | 37.205426 | 115 | py |
mff | mff-master/mff/models/base.py | # -*- coding: utf-8 -*-
from abc import ABCMeta
from pathlib import Path
class Model(metaclass=ABCMeta):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.grid = dict()
def save(self, path: Path):
pass
@classmethod
def load(cls):
pass
... | 379 | 14.833333 | 41 | py |
mff | mff-master/mff/models/twothreeeam.py | # -*- coding: utf-8 -*-
import json
import logging
import warnings
from itertools import combinations_with_replacement
from pathlib import Path
import numpy as np
from mff import gp, interpolation, kernels, utility, models
from .base import Model
logger = logging.getLogger(__name__)
class NpEncoder(json.JSONEnco... | 62,212 | 44.477339 | 126 | py |
mff | mff-master/mff/models/twobody.py | # -*- coding: utf-8 -*-
import json
import warnings
from itertools import combinations_with_replacement
from pathlib import Path
import numpy as np
from mff import gp, interpolation, kernels, utility
from mff.models.base import Model
class NpEncoder(json.JSONEncoder):
def default(self, obj):
if isinst... | 25,131 | 36.849398 | 108 | py |
mff | mff-master/mff/models/manybody.py | # -*- coding: utf-8 -*-
import json
import warnings
from pathlib import Path
import numpy as np
from mff import gp, interpolation, kernels
from mff.models.base import Model
class NpEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, np.integer):
return int(obj)
el... | 15,695 | 35.165899 | 108 | py |
mff | mff-master/mff/models/eam.py | # -*- coding: utf-8 -*-
import json
import warnings
from itertools import combinations_with_replacement
from pathlib import Path
import numpy as np
from mff import gp, interpolation, kernels, utility
from mff.models.base import Model
class NpEncoder(json.JSONEncoder):
def default(self, obj):
if isinsta... | 20,669 | 36.718978 | 108 | py |
mff | mff-master/mff/models/__init__.py | from .twobody import TwoBodySingleSpeciesModel, TwoBodyManySpeciesModel
from .threebody import ThreeBodySingleSpeciesModel, ThreeBodyManySpeciesModel
from .manybody import ManyBodySingleSpeciesModel, ManyBodyManySpeciesModel
from .combined import CombinedSingleSpeciesModel, CombinedManySpeciesModel
from .eam import Eam... | 899 | 41.857143 | 83 | py |
mff | mff-master/mff/models/threebody.py | # -*- coding: utf-8 -*-
import json
import sys
import warnings
from itertools import combinations_with_replacement
from pathlib import Path
import numpy as np
from mff import gp, interpolation, kernels
from mff.models.base import Model
sys.setrecursionlimit(100000)
class NpEncoder(json.JSONEncoder):
def defau... | 35,154 | 41.406514 | 111 | py |
mff | mff-master/mff/models/combined.py | # -*- coding: utf-8 -*-
import json
import logging
import warnings
from itertools import combinations_with_replacement
from pathlib import Path
import numpy as np
from mff import gp, interpolation, kernels, utility, models
from .base import Model
logger = logging.getLogger(__name__)
class NpEncoder(json.JSONEnc... | 49,756 | 44.316029 | 113 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.