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 |
|---|---|---|---|---|---|---|
MICO | MICO-main/training/train_purchase100.py | import os
import argparse
import warnings
import git
import csv
import numpy as np
import torch
import torch.nn as nn
import torch.optim as optim
from torchcsprng import create_mt19937_generator, create_random_device_generator
from torch.utils.data import DataLoader
from opacus import PrivacyEngine
from opacus.valid... | 17,940 | 41.921053 | 149 | py |
MICO | MICO-main/training/accountant.py | from typing import List, Optional
from prv_accountant.dpsgd import DPSGDAccountant
from opacus.accountants.accountant import IAccountant
class PRVAccountant(IAccountant):
def __init__(self, noise_multiplier, sample_rate, max_steps, eps_error = 0.1, delta_error = 1e-9):
super().__init__()
self.noi... | 2,074 | 37.425926 | 113 | py |
MICO | MICO-main/training/train_sst2.py | import numpy as np
import pandas as pd
import os
import torch
import sys
import csv
import yaml
import warnings
import datasets
from opacus import PrivacyEngine
from dp_transformers import TrainingArguments, PrivacyArguments, PrivacyEngineCallback
from prv_accountant.dpsgd import find_noise_multiplier, DPSGDAccounta... | 7,676 | 35.042254 | 124 | py |
MICO | MICO-main/training/train_cifar10.py | import os
import argparse
import warnings
import git
import csv
import numpy as np
import torch
import torch.nn as nn
import torch.optim as optim
from torchcsprng import create_mt19937_generator, create_random_device_generator
from torch.utils.data import DataLoader
from opacus import PrivacyEngine
from opacus.valid... | 17,963 | 41.976077 | 149 | py |
MICO | MICO-main/src/mico-competition/mico.py | from __future__ import annotations
import os
import torch
import torch.nn as nn
from collections import OrderedDict
from typing import List, Optional, Union, Type, TypeVar
from torch.utils.data import Dataset, ConcatDataset, random_split
D = TypeVar("D", bound="ChallengeDataset")
LEN_CHALLENGE = 100
class Challeng... | 10,705 | 39.55303 | 139 | py |
MICO | MICO-main/src/mico-competition/challenge_datasets.py | import os
import numpy as np
import torch
from torch.utils.data import Dataset, ConcatDataset
def load_cifar10(dataset_dir: str = ".", download=True) -> Dataset:
"""Loads the CIFAR10 dataset.
"""
from torchvision.datasets import CIFAR10
import torchvision.transforms as transforms
# Precomputed s... | 3,560 | 34.61 | 120 | py |
MICO | MICO-main/src/mico-competition/__init__.py | from .mico import ChallengeDataset, CNN, MLP, load_model
from .challenge_datasets import load_cifar10, load_purchase100, load_sst2
__all__ = [
"ChallengeDataset",
"load_model",
"load_cifar10",
"load_purchase100",
"load_sst2",
"CNN",
"MLP"
] | 269 | 21.5 | 73 | py |
MICO | MICO-main/src/mico-competition/scoring/score.py | """Scoring program for the CodaLab competition platform.
Usage:
score.py <input directory> <output directory>
This program expects the following directory structure for <input directory>:
- <input directory>/ref/: Contains the solutions directories
(e.g., cifar10/cifar10_lo, cifar10/cifar10_hi, cifar10/cifar1... | 5,923 | 41.014184 | 130 | py |
MICO | MICO-main/src/mico-competition/scoring/score_html.py | import io
import matplotlib
import pandas as pd
import matplotlib.pyplot as plt
def image_to_html(fig):
"""Converts a matplotlib plot to SVG"""
iostring = io.StringIO()
fig.savefig(iostring, format="svg", bbox_inches=0, dpi=300)
iostring.seek(0)
return iostring.read()
def generate_roc(fpr, tpr)... | 3,052 | 22.851563 | 89 | py |
MICO | MICO-main/src/mico-competition/scoring/__init__.py | from .score import tpr_at_fpr, score
from .score_html import generate_roc, generate_table, generate_html
__all__ = [
"tpr_at_fpr",
"score",
"generate_roc",
"generate_table",
"generate_html",
] | 213 | 20.4 | 67 | py |
MKIDGen3 | MKIDGen3-master/setup.py | import setuptools
from setuptools.command.install import install
from setuptools.command.develop import develop
import subprocess
import numpy
from setuptools.extension import Extension
#pip install -e git+http://github.com/mazinlab/mkiggen3.git@develop#egg=mkidgen3
with open("README.md", "r") as fh:
long_descri... | 969 | 31.333333 | 80 | py |
MKIDGen3 | MKIDGen3-master/mkidgen3/hlsinputgen_dds.py |
"""
Generate a file containing tone to bin center offsets for 2048 resonators and a file containing IQ values
for the resonators over some number of cycles
IQ values are complex numbers on the unit circle
"""
import numpy as np
from daclutgen2gen3 import SweepFile
class Testdata:
def __init__(self, iq=None, off... | 2,419 | 35.119403 | 118 | py |
MKIDGen3 | MKIDGen3-master/mkidgen3/gen2.py | from logging import getLogger
import numpy as np
ISGOOD = 0b1
ISREVIEWED = 0b10
ISBAD = 0
MAX_ML_SCORE = 1
MAX_ATTEN = 100
LOCUT = 1e9
A_RANGE_CUTOFF = 6e9
def parse_lo(lofreq, frequencies=None, sample_rate=2.048e9):
""" Sets the attribute LOFreq (in Hz) """
lo = round(lofreq / (2.0 ** -16) / 1e6) * (2.... | 7,724 | 41.679558 | 116 | py |
MKIDGen3 | MKIDGen3-master/mkidgen3/daccomb.py | import numpy as np
import scipy.special
from logging import getLogger
import logging
from .gen2 import SweepFile, parse_lo
nDacSamplesPerCycle = 8
nLutRowsToUse = 2 ** 15
dacSampleRate = 2.048e9
nBitsPerSamplePair = 32
nChannels = 1024
def generateTones(frequencies, nSamples, sampleRate, amplitudes=None, phases=None... | 12,020 | 44.707224 | 124 | py |
pineko | pineko-main/benchmarks/bench_checks.py | import eko
import numpy as np
import pineappl
import pytest
import pineko.check
def benchmark_check_grid_and_eko_compatible(test_files, tmp_path):
grid = pineappl.grid.Grid.read(
test_files / "data/grids/400/HERA_NC_225GEV_EP_SIGMARED.pineappl.lz4"
)
wrong_grid = pineappl.grid.Grid.read(
... | 1,029 | 35.785714 | 85 | py |
pineko | pineko-main/benchmarks/bench_kfactor.py | import lhapdf
import numpy as np
import pineappl
from pineko import kfactor
def benchmark_kfactor_inclusion(test_files, tmp_path, test_pdf, lhapdf_path):
fake_yaml_path = test_files / "data" / "yamldb" / "ATLAS_TTB_FAKE.yaml"
max_as = 3
pdf_name = "NNPDF40_nnlo_as_01180"
kfactor.compute_k_factor_grid... | 1,921 | 32.137931 | 78 | py |
pineko | pineko-main/benchmarks/conftest.py | import pathlib
import shutil
from contextlib import contextmanager
import pytest
import pineko
import pineko.configs
@pytest.fixture
def test_files():
return pathlib.Path(__file__).parents[0] / "data_files/"
@pytest.fixture
def test_empty_proj(test_files):
path = test_files / "empty_proj/"
yield path
... | 1,087 | 19.923077 | 78 | py |
pineko | pineko-main/benchmarks/bench_cli.py | import pathlib
import shutil
import lhapdf
from click.testing import CliRunner
from pineko.cli._base import command
def benchmark_check_cli(test_files):
grid_path = pathlib.Path(
test_files / "data/grids/400/HERA_NC_225GEV_EP_SIGMARED.pineappl.lz4"
)
wrong_grid_path = pathlib.Path(
test_... | 5,202 | 32.567742 | 88 | py |
pineko | pineko-main/benchmarks/bench_evolve.py | import pathlib
import eko
import eko.io.legacy
import numpy as np
import pineappl
import pytest
import yaml
from eko import couplings as sc
import pineko
import pineko.evolve
import pineko.theory_card
def benchmark_write_operator_card_from_file(tmp_path, test_files, test_configs):
pine_path = test_files / "data... | 3,470 | 36.322581 | 88 | py |
pineko | pineko-main/benchmarks/bench_theory_card.py | import pineko
def benchmark_load(test_files):
base_configs = pineko.configs.load(test_files)
pineko.configs.configs = pineko.configs.defaults(base_configs)
tcard = pineko.theory_card.load(208)
assert tcard["MP"] == 0.938
assert tcard["PTO"] == 1
def benchmark_construct_assumption(test_files):
... | 570 | 30.722222 | 66 | py |
pineko | pineko-main/benchmarks/bench_theory.py | import os
import pathlib
import pineko
import pineko.configs
import pineko.theory
import pineko.theory_card
theory_obj = pineko.theory.TheoryBuilder(208, ["LHCB_Z_13TEV_DIMUON"])
theory_obj_hera = pineko.theory.TheoryBuilder(400, ["HERACOMBNCEP460"])
theory_obj_test = pineko.theory.TheoryBuilder(208, ["HERACOMBCCEM"]... | 6,282 | 31.056122 | 87 | py |
pineko | pineko-main/benchmarks/bench_comparator.py | import pineappl
import pineko
def benchmark_compare(lhapdf_path, test_files, test_pdf):
pine_path = test_files / "data/grids/208/LHCB_DY_13TEV_DIMUON.pineappl.lz4"
grid = pineappl.grid.Grid.read(pine_path)
fk_path = test_files / "data/fktables/208/LHCB_DY_13TEV_DIMUON.pineappl.lz4"
fk = pineappl.fk_t... | 619 | 35.470588 | 80 | py |
pineko | pineko-main/benchmarks/bench_autosv.py | import shutil
import lhapdf
import numpy as np
import pineappl
from pineko import scale_variations
def benchmark_compute_ren_sv_grid(test_files, tmp_path, test_pdf, lhapdf_path):
to_test_grid_path = (
test_files
/ "data"
/ "grids"
/ "400"
/ "ATLAS_TTB_8TEV_LJ_TRAP_totest.... | 2,381 | 34.029412 | 82 | py |
pineko | pineko-main/benchmarks/bench_configs.py | import pytest
import pineko
def benchmark_detect(test_files):
with pytest.raises(FileNotFoundError):
pineko.configs.detect()
conf_file = pineko.configs.detect(test_files)
def benchmark_load(test_files):
conf_file = pineko.configs.load(test_files)
assert conf_file["paths"]["root"] == test_fi... | 380 | 22.8125 | 55 | py |
pineko | pineko-main/src/pineko/parser.py | """Interface to ymldb."""
# ATTENTION: this is a partial copy from
# https://github.com/NNPDF/nnpdf/blob/7cb96fc05ca2a2914bc1ccc864865e0ca4e66983/validphys2/src/validphys/pineparser.py
import yaml
EXT = "pineappl.lz4"
class YamlFileNotFound(FileNotFoundError):
"""ymldb file for dataset not found."""
class Gri... | 2,035 | 26.890411 | 117 | py |
pineko | pineko-main/src/pineko/theory.py | """Tools related to generation of a list of FK tables.
The typical use case of pineko is the generation of a list of FK tables,
all with common theory parameters. The collective list of this FK tables
together with other theory ingredients (such as C-factors) are often
commonly referred to as 'theory'.
"""
import logg... | 14,799 | 30.827957 | 95 | py |
pineko | pineko-main/src/pineko/check.py | """Tools to check compatibility of EKO and grid."""
from dataclasses import dataclass
from enum import Enum, auto
from typing import Tuple
import numpy as np
import pineappl
@dataclass
class ScaleValue:
"""Contain the information of a kind of scale variations and its index in the orders of a pineappl grid."""
... | 5,596 | 28.930481 | 190 | py |
pineko | pineko-main/src/pineko/scale_variations.py | """Module to generate scale variations."""
import pathlib
from enum import Enum
from typing import Dict, List, Optional, Tuple
import numpy as np
import pineappl
import rich
from eko import beta
from . import check
AS_NORM = 1.0 / (4.0 * np.pi)
OrderTuple = Tuple[int, int, int, int]
"""Tuple representing a PineAPPL ... | 10,171 | 37.530303 | 149 | py |
pineko | pineko-main/src/pineko/ekompatibility.py | """Compatibility layer for EKO migration."""
from typing import Any, Dict
from eko import EKO, basis_rotation
def pineappl_layout(operator: EKO) -> Dict[str, Any]:
"""Extract information required by :func:`pineappl.grid.Grid.convolute_eko`.
Parameters
----------
operator: eko.EKO
evolution o... | 1,022 | 27.416667 | 80 | py |
pineko | pineko-main/src/pineko/theory_card.py | """Tools related to theory cards."""
import pathlib
from typing import Any, Dict
import yaml
from . import configs
def path(theory_id: int) -> pathlib.Path:
"""Determine path to theory card.
Parameters
----------
theory_id : int
theory id
Returns
-------
pathlib.Path
th... | 1,734 | 19.411765 | 94 | py |
pineko | pineko-main/src/pineko/comparator.py | """Tools to compare grids and FK tables."""
import numpy as np
import pandas as pd
import pineappl
def compare(pine, fktable, max_as, max_al, pdf, xir, xif):
"""Build comparison table.
Parameters
----------
pine : pineappl.grid.Grid
uncovoluted grid
fktable : pineappl.fktable.FkTable
... | 1,639 | 25.451613 | 85 | py |
pineko | pineko-main/src/pineko/version.py | """Version information."""
__version__ = "0.0.0"
| 49 | 15.666667 | 26 | py |
pineko | pineko-main/src/pineko/evolve.py | """Tools related to evolution/eko."""
import copy
import os
import pathlib
import eko
import eko.basis_rotation as br
import numpy as np
import pineappl
import rich
import rich.box
import rich.panel
import yaml
from eko.io.types import ScaleVariationsMethod
from eko.matchings import Atlas, nf_default
from eko.quantiti... | 7,957 | 31.614754 | 88 | py |
pineko | pineko-main/src/pineko/__init__.py | """pineko = PineAPPL + EKO."""
from .cli import command
| 56 | 18 | 30 | py |
pineko | pineko-main/src/pineko/kfactor.py | """Module to include QCD K-factors in grids."""
import io
import numpy as np
import pineappl
import rich
import yaml
from pineappl import import_only_subgrid
from . import scale_variations
DEFAULT_PDF_SET = "NNPDF40_nnlo_as_01180"
def factgrid(subgrid):
"""Return the array of the factorization scales squared f... | 13,736 | 31.863636 | 133 | py |
pineko | pineko-main/src/pineko/scaffold.py | """Tools related to generation and managing of a pineko project."""
import dataclasses
import pathlib
from .configs import NEEDED_FILES, NEEDED_KEYS
@dataclasses.dataclass
class CheckResult:
"""The results of a scaffold check.
In particular it contains a bool that is True if the check has been
successf... | 2,534 | 29.914634 | 82 | py |
pineko | pineko-main/src/pineko/configs.py | """Tools related to the configuration file handling."""
import copy
import pathlib
import tomli
name = "pineko.toml"
"Name of the config file (wherever it is placed)"
# better to declare immediately the correct type
configs = {}
"Holds loaded configurations"
NEEDED_KEYS = [
"ymldb",
"operator_cards",
"g... | 3,700 | 23.509934 | 89 | py |
pineko | pineko-main/src/pineko/cli/gen_sv.py | """CLI entry point to generation of scale variations from central grid."""
import pathlib
import click
import pineappl
import rich
from .. import scale_variations
from ._base import command
@command.command("ren_sv_grid")
@click.argument("pineappl_path", type=click.Path(exists=True))
@click.argument("target_path",... | 850 | 28.344828 | 76 | py |
pineko | pineko-main/src/pineko/cli/check.py | """CLI entry point to check compatibility."""
from dataclasses import dataclass
from enum import Enum
import click
import eko
import pineappl
import rich
from .. import check
from ._base import command
@command.group("check")
def subcommand():
"""Check grid and operator properties."""
@subcommand.command("com... | 3,289 | 31.574257 | 105 | py |
pineko | pineko-main/src/pineko/cli/opcard.py | """CLI entry point to the operator card generation."""
import pathlib
import click
import rich
import yaml
from .. import evolve
from ._base import command
@command.command("opcard")
@click.argument("pineappl-path", metavar="PINEAPPL", type=click.Path(exists=True))
@click.argument(
"default-card-path", metavar=... | 1,205 | 32.5 | 87 | py |
pineko | pineko-main/src/pineko/cli/convolute.py | """CLI entry point to convolution."""
import click
import eko
import pineappl
import rich
from .. import evolve
from ._base import command
@command.command("convolute")
@click.argument("grid_path", type=click.Path(exists=True))
@click.argument("op_path", type=click.Path(exists=True))
@click.argument("fktable", type=... | 2,158 | 32.215385 | 95 | py |
pineko | pineko-main/src/pineko/cli/compare.py | """CLI entry point to comparison grid vs. FK Table."""
import click
import pineappl
import rich
from .. import comparator
from ._base import command
@command.command("compare")
@click.argument("pineappl_path", type=click.Path(exists=True))
@click.argument("fktable_path", type=click.Path())
@click.argument("max_as", ... | 1,529 | 42.714286 | 95 | py |
pineko | pineko-main/src/pineko/cli/_base.py | """Adds global CLI options."""
import click
CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])
@click.group(context_settings=CONTEXT_SETTINGS)
def command():
"""pineko: Combine PineAPPL grids and EKOs into FK tables."""
| 237 | 20.636364 | 65 | py |
pineko | pineko-main/src/pineko/cli/__init__.py | """CLI entry point."""
from . import check, compare, convolute, gen_sv, kfactor, opcard, scaffold, theory_
from ._base import command
| 134 | 32.75 | 83 | py |
pineko | pineko-main/src/pineko/cli/theory_.py | """'theory' mode of CLI."""
import pathlib
import click
from .. import configs, theory
from ._base import command
@command.group("theory")
@click.option(
"-c",
"--configs",
"cfg",
default=None,
type=click.Path(resolve_path=True, path_type=pathlib.Path),
help="Explicitly specify config file (... | 3,822 | 35.409524 | 88 | py |
pineko | pineko-main/src/pineko/cli/kfactor.py | """CLI entry point to generation of the inclusion of kfactor in a grid."""
import pathlib
import click
import rich
from .. import kfactor
from ._base import command
@command.command("kfactor")
@click.argument("grids_folder", type=click.Path(exists=True))
@click.argument("kfactor_folder", type=click.Path(exists=Tru... | 1,095 | 26.4 | 74 | py |
pineko | pineko-main/src/pineko/cli/scaffold.py | """'scaffold' mode of CLI."""
import pathlib
import click
import rich
from .. import configs, scaffold
from ._base import command
@command.group("scaffold")
@click.option(
"-c",
"--configs",
"cfg",
default=None,
type=click.Path(resolve_path=True, path_type=pathlib.Path),
help="Explicitly spe... | 1,558 | 29.568627 | 89 | py |
pineko | pineko-main/tests/test_kfactor.py | import numpy as np
import pytest
from pineko import kfactor
class FakeAlpha:
def __init__(self, const_value):
self.const_value = const_value
def alphasQ2(self, q2):
return self.const_value
class FakeGrid:
def __init__(self, nbins):
self.nbins = nbins
def bins(self):
... | 2,266 | 28.064103 | 101 | py |
pineko | pineko-main/tests/test_theory_card.py | import pineko.theory_card
def test_construct_assumptions():
fake_t_card = {
"Q0": 1.65,
"kcThr": 1.0,
"kbThr": 1.0,
"ktThr": 1.0,
"mc": 2.0,
"mb": 3.0,
"mt": 50.0,
"IC": 1,
}
assert pineko.theory_card.construct_assumptions(fake_t_card) == "Nf... | 326 | 19.4375 | 76 | py |
pineko | pineko-main/tests/test_regression.py | """
Suite of tests that go through the entire process of creating a new fktable
from a empty folder.
The target theory is 400 and the relevant `.toml`, theory runcard and eko template
are downloaded from https://github.com/NNPDF/theories during this test so this tests
has the double effect of ensur... | 4,979 | 35.617647 | 90 | py |
pineko | pineko-main/tests/test_check.py | import numpy as np
from pineappl.pineappl import PyOrder
import pineko.check
def test_islepton():
el = 21
assert pineko.check.islepton(el) == False
el = -13
assert pineko.check.islepton(el) == True
def test_in1d():
to_check = np.array([0.3])
against_this = np.array(
[1, 2, 0.3, 90, ... | 4,576 | 33.156716 | 83 | py |
pineko | pineko-main/tests/test_scaffold.py | import pytest
from pineko import configs, scaffold
def test_set_up_project(tmp_path, wrong_fake_configs, fake_configs_incomplete):
with pytest.raises(TypeError):
scaffold.set_up_project(wrong_fake_configs)
scaffold.set_up_project(fake_configs_incomplete)
assert (tmp_path / "data/ymldb").exists()
... | 1,314 | 34.540541 | 79 | py |
pineko | pineko-main/tests/conftest.py | import pytest
@pytest.fixture
def wrong_fake_configs(tmp_path):
"""This configs are wrong because under logs/fk there is a list and not a string."""
wrong_fake_configs = {
"paths": {
"ymldb": tmp_path / "data" / "ymldb",
"logs": {"eko": tmp_path / "logs" / "eko", "fk": ["someth... | 1,406 | 29.586957 | 97 | py |
pineko | pineko-main/tests/test_evolve.py | import pytest
import pineko.evolve
def test_sv_scheme():
wrong_tcard = {"XIF": 1.0, "ModSV": "expanded"}
schemeA_tcard = {
"XIF": 2.0,
"ModSV": "exponentiated",
}
schemeB_tcard = {"XIF": 0.5, "ModSV": "expanded"}
schemeC_tcard = {"XIF": 2.0, "ModSV": None}
with pytest.raises(V... | 568 | 28.947368 | 68 | py |
pineko | pineko-main/tests/test_scale_variations.py | import numpy as np
from eko.beta import beta_qcd
from pineko import scale_variations
def test_ren_sv_coeffs():
np.testing.assert_allclose(
scale_variations.ren_sv_coeffs(m=0, max_as=0, logpart=0, which_part=0, nf=5), 0
)
np.testing.assert_allclose(
scale_variations.ren_sv_coeffs(m=0, max_... | 1,304 | 29.348837 | 87 | py |
pineko | pineko-main/tests/test_configs.py | import pathlib
import pytest
import pineko
def test_enhance_paths():
# Testing with one missing key
test_configs = {
"paths": {
"ymldb": pathlib.Path(""),
"grids": pathlib.Path(""),
"theory_cards": pathlib.Path(""),
"fktables": pathlib.Path(""),
... | 1,758 | 32.826923 | 83 | py |
pineko | pineko-main/docs/source/conf.py | # Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If ex... | 3,189 | 30.27451 | 79 | py |
L0Learn | L0Learn-master/vignettes/profile/L0Learn_Profile_Run.py | import os
import pandas as pd
from mprof import read_mprofile_file
CMD_BASE = "mprof run -o {o}.dat Rscript L0Learn_Profile.R --n {n} --p {p} --k {k} --s {s} --t {t} --w {w} --m {m} --f {f}"
file_name = 'test_run3'
run = {"n":1000, "p":10000, "k":10, "s":1, "t":2.1, "w":4, "m":1, "f":file_name, "o":file_name}
cmd ... | 648 | 31.45 | 123 | py |
Latent-Spectral-Models | Latent-Spectral-Models-main/exp_elas.py | import torch.nn.functional as F
import matplotlib.pyplot as plt
from timeit import default_timer
from utils.utilities3 import *
from utils.adam import Adam
from utils.params import get_args
from model_dict import get_model
import math
import os
torch.manual_seed(0)
np.random.seed(0)
torch.cuda.manual_seed(0)
torch.bac... | 4,143 | 33.823529 | 103 | py |
Latent-Spectral-Models | Latent-Spectral-Models-main/exp_airfoils.py | import torch.nn.functional as F
import matplotlib.pyplot as plt
from timeit import default_timer
from utils.utilities3 import *
from utils.adam import Adam
from utils.params import get_args
from model_dict import get_model
import math
import os
torch.manual_seed(0)
np.random.seed(0)
torch.cuda.manual_seed(0)
torch.bac... | 4,794 | 32.767606 | 115 | py |
Latent-Spectral-Models | Latent-Spectral-Models-main/exp_elas_interp.py | import torch.nn.functional as F
import matplotlib.pyplot as plt
from timeit import default_timer
from utils.utilities3 import *
from utils.adam import Adam
from utils.params import get_args
from model_dict import get_model
import math
import os
torch.manual_seed(0)
np.random.seed(0)
torch.cuda.manual_seed(0)
torch.bac... | 3,753 | 30.283333 | 115 | py |
Latent-Spectral-Models | Latent-Spectral-Models-main/exp_pipe.py | import torch.nn.functional as F
import matplotlib.pyplot as plt
from timeit import default_timer
from utils.utilities3 import *
from utils.adam import Adam
from utils.params import get_args
from model_dict import get_model
import math
import os
torch.manual_seed(0)
np.random.seed(0)
torch.cuda.manual_seed(0)
torch.bac... | 4,190 | 31.238462 | 115 | py |
Latent-Spectral-Models | Latent-Spectral-Models-main/exp_darcy.py | import torch.nn.functional as F
import matplotlib.pyplot as plt
from timeit import default_timer
from utils.utilities3 import *
from utils.adam import Adam
from utils.params import get_args
from model_dict import get_model
import math
import os
torch.manual_seed(0)
np.random.seed(0)
torch.cuda.manual_seed(0)
torch.bac... | 3,958 | 30.927419 | 115 | py |
Latent-Spectral-Models | Latent-Spectral-Models-main/model_dict.py | from models import LSM_2D, LSM_3D, LSM_Irregular_Geo, FNO_2D, FNO_3D, FNO_Irregular_Geo
def get_model(args):
model_dict = {
'FNO_2D': FNO_2D,
'FNO_3D': FNO_3D,
'FNO_Irregular_Geo': FNO_Irregular_Geo,
'LSM_2D': LSM_2D,
'LSM_3D': LSM_3D,
'LSM_Irregular_Geo': LSM_Irregu... | 576 | 35.0625 | 94 | py |
Latent-Spectral-Models | Latent-Spectral-Models-main/exp_ns.py | import torch.nn.functional as F
import matplotlib.pyplot as plt
from timeit import default_timer
from utils.utilities3 import *
from utils.params import get_args
from model_dict import get_model
from utils.adam import Adam
import math
import os
torch.manual_seed(0)
np.random.seed(0)
torch.cuda.manual_seed(0)
torch.bac... | 4,624 | 31.118056 | 115 | py |
Latent-Spectral-Models | Latent-Spectral-Models-main/exp_plas.py | import torch.nn.functional as F
import matplotlib.pyplot as plt
from timeit import default_timer
from utils.utilities3 import *
from utils.adam import Adam
from utils.params import get_args
from model_dict import get_model
import math
import os
torch.manual_seed(0)
np.random.seed(0)
torch.cuda.manual_seed(0)
torch.bac... | 5,411 | 37.935252 | 115 | py |
Latent-Spectral-Models | Latent-Spectral-Models-main/models/LSM_Irregular_Geo.py | """
@author: Haixu Wu
"""
import torch.nn.functional as F
import torch.nn as nn
import torch
import numpy as np
import math
################################################################
# Multiscale modules 2D
################################################################
class DoubleConv(nn.Module):
"""(con... | 17,899 | 39.134529 | 130 | py |
Latent-Spectral-Models | Latent-Spectral-Models-main/models/FNO_Irregular_Geo.py | """
@author: Zongyi Li
modified by Haixu Wu to adapt to this code base
"""
import torch.nn.functional as F
import torch.nn as nn
import torch
import numpy as np
import math
################################################################
# fourier layer
################################################################... | 11,055 | 36.733788 | 130 | py |
Latent-Spectral-Models | Latent-Spectral-Models-main/models/FNO_3D.py | """
@author: Zongyi Li
modified by Haixu Wu to adapt to this code base
"""
import torch.nn.functional as F
import torch.nn as nn
import torch
import numpy as np
import math
################################################################
# 3d fourier layers
############################################################... | 6,128 | 41.86014 | 103 | py |
Latent-Spectral-Models | Latent-Spectral-Models-main/models/FNO_2D.py | """
@author: Zongyi Li
modified by Haixu Wu to adapt to this code base
"""
import torch.nn.functional as F
import torch.nn as nn
import torch
import numpy as np
import math
################################################################
# fourier layer
################################################################... | 4,586 | 36.598361 | 111 | py |
Latent-Spectral-Models | Latent-Spectral-Models-main/models/LSM_2D.py | """
@author: Haixu Wu
"""
import torch.nn.functional as F
import torch.nn as nn
import torch
import numpy as np
import math
################################################################
# Multiscale modules 2D
################################################################
class DoubleConv(nn.Module):
"""(con... | 9,905 | 40.103734 | 122 | py |
Latent-Spectral-Models | Latent-Spectral-Models-main/models/LSM_3D.py | """
@author: Haixu Wu
"""
import torch.nn.functional as F
import torch.nn as nn
import torch
import numpy as np
import math
################################################################
# Multiscale modules 3D
################################################################
class DoubleConv(nn.Module):
"""(co... | 9,849 | 41.094017 | 126 | py |
Latent-Spectral-Models | Latent-Spectral-Models-main/utils/adam.py | import math
import torch
from torch import Tensor
from typing import List, Optional
from torch.optim.optimizer import Optimizer
def adam(params: List[Tensor],
grads: List[Tensor],
exp_avgs: List[Tensor],
exp_avg_sqs: List[Tensor],
max_exp_avg_sqs: List[Tensor],
state_steps... | 6,563 | 39.02439 | 120 | py |
Latent-Spectral-Models | Latent-Spectral-Models-main/utils/utilities3.py | import torch
import numpy as np
import scipy.io
import h5py
import torch.nn as nn
import operator
from functools import reduce
#################################################
# Utilities
#################################################
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
# readi... | 10,440 | 28.246499 | 116 | py |
Latent-Spectral-Models | Latent-Spectral-Models-main/utils/params.py | import argparse
def get_args():
parser = argparse.ArgumentParser('Latent Spectral Models', add_help=False)
# dataset
parser.add_argument('--data-path', default='./dataset', type=str, help='dataset folder')
parser.add_argument('--ntotal', default=1200, type=int, help='number of overall data')
parser.... | 2,633 | 66.538462 | 107 | py |
FaceChat | FaceChat-main/app.py | async_mode = None
if async_mode is None:
try:
import eventlet
async_mode = "eventlet"
except ImportError:
pass
if async_mode is None:
try:
from gevent import monkey
async_mode = "gevent"
except ImportError:
pass
if async_mo... | 21,580 | 31.748103 | 194 | py |
GraphCAD | GraphCAD-main/gin_conv_weight.py | from typing import Callable, Optional, Union
import torch
from torch import Tensor
from torch_sparse import SparseTensor, matmul
from torch_geometric.nn.conv import MessagePassing
from torch_geometric.nn.dense.linear import Linear
from torch_geometric.typing import Adj, OptPairTensor, OptTensor, Size
from ..inits im... | 3,471 | 35.166667 | 102 | py |
GraphCAD | GraphCAD-main/MAG/main.py | import os
import argparse
import numpy as np
import torch
import torch.nn as nn
from tqdm import tqdm
import random
import json
import pickle
from collections import defaultdict
from operator import itemgetter
import logging
from torch_geometric.data import Data, DataLoader
from torch.optim.lr_scheduler import _LRSch... | 9,336 | 46.637755 | 213 | py |
GraphCAD | GraphCAD-main/MAG/utils.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import math, copy, time
from torch.autograd import Variable
import multiprocessing
from sklearn.metrics import roc_auc_score, auc, roc_curve
from torch_geometric.utils import add_self_loops, degree, softmax, to_dense_adj, dense_to_spa... | 2,237 | 27.329114 | 96 | py |
GraphCAD | GraphCAD-main/MAG/models.py | from random import sample
import torch
import torch.nn as nn
import torch.nn.functional as F
from sklearn.metrics.pairwise import euclidean_distances, cosine_similarity
import pickle
from torch_geometric.nn import GCNConv, MessagePassing, GINConv, GATConv
from torch_geometric.utils import add_self_loops, degree, softm... | 9,780 | 37.507874 | 189 | py |
GraphCAD | GraphCAD-main/AMiner/main.py | import os
import argparse
import numpy as np
import torch
import torch.nn as nn
from tqdm import tqdm
import random
import json
import pickle
from collections import defaultdict
from operator import itemgetter
import logging
from torch_geometric.data import Data, DataLoader
from torch.optim.lr_scheduler import _LRSch... | 9,342 | 46.668367 | 213 | py |
GraphCAD | GraphCAD-main/AMiner/utils.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import math, copy, time
from torch.autograd import Variable
import multiprocessing
from sklearn.metrics import roc_auc_score, auc, roc_curve
from torch_geometric.utils import add_self_loops, degree, softmax, to_dense_adj, dense_to_spa... | 2,237 | 27.329114 | 96 | py |
GraphCAD | GraphCAD-main/AMiner/models.py | from random import sample
import torch
import torch.nn as nn
import torch.nn.functional as F
from sklearn.metrics.pairwise import euclidean_distances, cosine_similarity
import pickle
from torch_geometric.nn import GCNConv, MessagePassing, GINConv, GATConv
from torch_geometric.utils import add_self_loops, degree, softm... | 9,780 | 37.507874 | 189 | py |
GraphCAD | GraphCAD-main/Yelp/main.py | import os
import argparse
import numpy as np
import torch
import torch.nn as nn
from tqdm import tqdm
import random
import json
import pickle
from collections import defaultdict
from operator import itemgetter
import logging
from torch_geometric.data import Data, DataLoader
from torch.optim.lr_scheduler import _LRSch... | 9,996 | 46.379147 | 213 | py |
GraphCAD | GraphCAD-main/Yelp/utils.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import math, copy, time
from torch.autograd import Variable
import multiprocessing
from sklearn.metrics import roc_auc_score, auc, roc_curve
from torch_geometric.utils import add_self_loops, degree, softmax, to_dense_adj, dense_to_spa... | 2,237 | 27.329114 | 96 | py |
GraphCAD | GraphCAD-main/Yelp/models.py | from random import sample
import torch
import torch.nn as nn
import torch.nn.functional as F
from sklearn.metrics.pairwise import euclidean_distances, cosine_similarity
import pickle
from torch_geometric.nn import GINConv_w as GINConv
from torch_geometric.utils import add_self_loops, degree, softmax, to_dense_adj, den... | 9,770 | 37.317647 | 189 | py |
GraphCAD | GraphCAD-main/Alpha/main.py | import os
import argparse
import numpy as np
import torch
import torch.nn as nn
from tqdm import tqdm
import random
import json
import pickle
from collections import defaultdict
from operator import itemgetter
import logging
from torch_geometric.data import Data, DataLoader
from torch.optim.lr_scheduler import _LRSch... | 10,052 | 46.419811 | 213 | py |
GraphCAD | GraphCAD-main/Alpha/utils.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import math, copy, time
from torch.autograd import Variable
import multiprocessing
from sklearn.metrics import roc_auc_score, auc, roc_curve
from torch_geometric.utils import add_self_loops, degree, softmax, to_dense_adj, dense_to_spa... | 2,237 | 27.329114 | 96 | py |
GraphCAD | GraphCAD-main/Alpha/models.py | from random import sample
import torch
import torch.nn as nn
import torch.nn.functional as F
from sklearn.metrics.pairwise import euclidean_distances, cosine_similarity
import pickle
from torch_geometric.nn import GINConv_w as GINConv
from torch_geometric.utils import add_self_loops, degree, softmax, to_dense_adj, den... | 9,763 | 37.290196 | 189 | py |
CoordFill | CoordFill-master/test.py | import argparse
import os
import math
from functools import partial
import yaml
import torch
from torch.utils.data import DataLoader
from tqdm import tqdm
import datasets
import models
import utils
from PIL import Image
from torchvision import transforms
from torchsummary import summary
import numpy as np
def batch... | 4,752 | 31.333333 | 90 | py |
CoordFill | CoordFill-master/utils.py | import os
import time
import shutil
import math
import torch
import numpy as np
from torch.optim import SGD, Adam
from tensorboardX import SummaryWriter
from skimage.measure import compare_ssim
from skimage.measure import compare_psnr
class Averager():
def __init__(self):
self.n = 0.0
self.v = 0... | 3,801 | 24.346667 | 87 | py |
CoordFill | CoordFill-master/train_parallel.py | import argparse
import os
import yaml
import torch
import torch.nn as nn
from tqdm import tqdm
from torch.utils.data import DataLoader
from torch.utils.data.distributed import DistributedSampler
from torch.optim.lr_scheduler import MultiStepLR, LambdaLR
from torchvision import transforms
import random
import dataset... | 7,851 | 35.52093 | 202 | py |
CoordFill | CoordFill-master/demo.py | import argparse
import os
from PIL import Image
import torch
from torchvision import transforms
import models
def resize_fn(img, size):
return transforms.ToTensor()(
transforms.Resize(size)(
transforms.ToPILImage()(img)))
def to_mask(mask):
return transforms.ToTensor()(
transfor... | 1,668 | 28.280702 | 94 | py |
CoordFill | CoordFill-master/train.py | import argparse
import os
import yaml
import torch
import torch.nn as nn
from tqdm import tqdm
from torch.utils.data import DataLoader
import datasets
import models
import utils
from test import eval_psnr, batched_predict
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
def make_data_loader(spe... | 6,360 | 33.570652 | 105 | py |
CoordFill | CoordFill-master/models/replicate.py | # -*- coding: utf-8 -*-
# File : replicate.py
# Author : Jiayuan Mao
# Email : maojiayuan@gmail.com
# Date : 27/01/2018
#
# This file is part of Synchronized-BatchNorm-PyTorch.
# https://github.com/vacancy/Synchronized-BatchNorm-PyTorch
# Distributed under MIT License.
import functools
from torch.nn.parallel.dat... | 3,218 | 35.579545 | 115 | py |
CoordFill | CoordFill-master/models/comm.py | # -*- coding: utf-8 -*-
# File : comm.py
# Author : Jiayuan Mao
# Email : maojiayuan@gmail.com
# Date : 27/01/2018
#
# This file is part of Synchronized-BatchNorm-PyTorch.
# https://github.com/vacancy/Synchronized-BatchNorm-PyTorch
# Distributed under MIT License.
import queue
import collections
import threading
... | 4,439 | 33.418605 | 117 | py |
CoordFill | CoordFill-master/models/modules.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from .networks import BaseNetwork
from .networks import get_nonspade_norm_layer
from .networks import MySeparableBilinearDownsample as BilinearDownsample
import torch.nn.utils.spectral_norm as spectral_norm
import torch as th
from math import pi
from ma... | 12,294 | 36.257576 | 143 | py |
CoordFill | CoordFill-master/models/misc.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import models
from models import register
from utils import make_coord
@register('metasr')
class MetaSR(nn.Module):
def __init__(self, encoder_spec):
super().__init__()
self.encoder = models.make(encoder_spec)
imnet_spec... | 2,303 | 31.450704 | 78 | py |
CoordFill | CoordFill-master/models/gan.py | import random
import torch
import torch.nn as nn
import torch.nn.functional as F
import models
from models import register
import math
import numpy as np
from torch.autograd import Variable
import os
import logging
logger = logging.getLogger(__name__)
from .coordfill import CoordFill
from .ffc_baseline import FFC
fro... | 6,804 | 36.185792 | 162 | py |
CoordFill | CoordFill-master/models/networks.py | import torch.nn as nn
from torch.nn import init
import torch.nn.utils.spectral_norm as spectral_norm
import torch
import torch.nn.functional as F
import functools
import numpy as np
class MySeparableBilinearDownsample(torch.nn.Module):
def __init__(self, stride, channels, use_gpu):
super().__init__()
... | 7,259 | 43 | 120 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.