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
StyleFusion
StyleFusion-master/src/shared.py
import os, random, sys, datetime, time, socket, io, h5py, argparse, shutil, io import queue import numpy as np import scipy from nltk.translate.bleu_score import sentence_bleu from nltk.translate.bleu_score import SmoothingFunction import matplotlib.pyplot as plt """ AUTHOR: Sean Xiang Gao (xiag@microsoft.com) at Mic...
3,632
25.326087
78
py
StyleFusion
StyleFusion-master/data/arXiv/arxiv.py
""" AUTHOR: Xiang Gao (xiag@microsoft.com) at Microsoft Research """ import re, os, subprocess from nltk.tokenize import TweetTokenizer EQN_token = '_eqn_' CITE_token = '_cite_' IX_token = '_ix_' MAX_UTT_LEN = 30 # maximum length of utterance allowed. if longer, ignore def norm_sentence(txt): txt = txt.lower() ...
5,797
22.860082
111
py
NBFNet
NBFNet-master/script/run.py
import os import sys import math import pprint import torch from torchdrug import core from torchdrug.utils import comm sys.path.append(os.path.dirname(os.path.dirname(__file__))) from nbfnet import dataset, layer, model, task, util def train_and_validate(cfg, solver): if cfg.train.num_epoch == 0: retu...
1,690
25.421875
64
py
NBFNet
NBFNet-master/script/visualize.py
import os import sys import pprint import torch from torchdrug import core from torchdrug.utils import comm sys.path.append(os.path.dirname(os.path.dirname(__file__))) from nbfnet import dataset, layer, model, task, util vocab_file = os.path.join(os.path.dirname(__file__), "../data/fb15k237_entity.txt") vocab_file...
3,106
34.306818
84
py
NBFNet
NBFNet-master/nbfnet/layer.py
import torch from torch import nn from torch.nn import functional as F from torch_scatter import scatter_add, scatter_mean, scatter_max, scatter_min from torchdrug import layers from torchdrug.layers import functional class GeneralizedRelationalConv(layers.MessagePassingBase): eps = 1e-6 message2mul = { ...
7,872
46.427711
119
py
NBFNet
NBFNet-master/nbfnet/task.py
import math import torch from torch.nn import functional as F from torch.utils import data as torch_data from ogb import linkproppred from torchdrug import core, tasks, metrics from torchdrug.layers import functional from torchdrug.core import Registry as R Evaluator = core.make_configurable(linkproppred.Evaluator...
22,136
44.832298
119
py
NBFNet
NBFNet-master/nbfnet/model.py
from collections.abc import Sequence import torch from torch import nn from torch import autograd from torch_scatter import scatter_add from torchdrug import core, layers, utils from torchdrug.layers import functional from torchdrug.core import Registry as R from . import layer @R.register("model.NBFNet") class N...
11,950
44.441065
118
py
NBFNet
NBFNet-master/nbfnet/dataset.py
import os import csv import glob from tqdm import tqdm from ogb import linkproppred import torch from torch.utils import data as torch_data from torchdrug import data, datasets, utils from torchdrug.core import Registry as R class InductiveKnowledgeGraphDataset(data.KnowledgeGraphDataset): def load_inductive_t...
14,201
39.005634
105
py
NBFNet
NBFNet-master/nbfnet/util.py
import os import time import logging import argparse import yaml import jinja2 from jinja2 import meta import easydict import torch from torch.utils import data as torch_data from torch import distributed as dist from torchdrug import core, utils from torchdrug.utils import comm logger = logging.getLogger(__file__...
3,838
30.467213
119
py
NBFNet
NBFNet-master/nbfnet/__init__.py
0
0
0
py
gca-rom
gca-rom-main/main.py
import sys sys.path.append('../') import torch from gca_rom import network, pde, loader, plotting, preprocessing, training, initialization, testing, error import numpy as np if __name__ == "__main__": problem_name, variable, mu1_range, mu2_range = pde.problem(int(sys.argv[1])) print("PROBLEM: ", problem_name...
4,087
45.454545
157
py
gca-rom
gca-rom-main/examples/advection.py
import os # HYPER-PARAMETERS FOR POISSON problem_name = "advection" scalers_type = "sampling-feature" scalers_fun = "standard" skip_connection = "skip1" pn = 2 st = 4 sf = 3 sk = 1 train_rate = 30 ffc_nodes = 200 latent_nodes = 100 btt_nodes = 15 lambda_map = 1e1 hidden_channels = 2 print("\n\nRUN MAIN FOR PROBLEM ...
819
34.652174
156
py
gca-rom
gca-rom-main/examples/navier-stokes.py
import os # HYPER-PARAMETERS FOR POISSON problem_names = ["VX_navier_stokes", "VY_navier_stokes", "P_navier_stokes"] comp = 2 problem_name = problem_names[comp] scalers_type = "sampling-feature" scalers_fun = "standard" skip_connection = "skip1" pn = 4 + comp st = 4 sf = 3 sk = 1 train_rate = 10 ffc_nodes = 200 late...
919
35.8
156
py
gca-rom
gca-rom-main/examples/graetz.py
import os # HYPER-PARAMETERS FOR POISSON problem_name = "graetz" scalers_type = "sampling-feature" scalers_fun = "standard" skip_connection = "skip1" pn = 3 st = 4 sf = 3 sk = 1 train_rate = 30 ffc_nodes = 200 latent_nodes = 50 btt_nodes = 25 lambda_map = 1e1 hidden_channels = 2 print("\n\nRUN MAIN FOR PROBLEM "+pr...
815
34.478261
156
py
gca-rom
gca-rom-main/examples/poisson.py
import os # HYPER-PARAMETERS FOR POISSON problem_name = "poisson" scalers_type = "sampling-feature" scalers_fun = "standard" skip_connection = "skip1" pn = 1 st = 4 sf = 3 sk = 1 train_rate = 30 ffc_nodes = 200 latent_nodes = 50 btt_nodes = 15 lambda_map = 1e1 hidden_channels = 3 print("\n\nRUN MAIN FOR PROBLEM "+p...
816
34.521739
156
py
gca-rom
gca-rom-main/gca_rom/error.py
import numpy as np from gca_rom import scaling def save_error(error, norm, AE_Params, vars): """ save_error(error: List[float], norm: List[float], AE_Params: object, vars: str) This function takes in two lists of same length, error and norm, computed on the whole dataset for plotting reasons, and saves t...
3,215
43.666667
209
py
gca-rom
gca-rom-main/gca_rom/preprocessing.py
import numpy as np import torch from torch_geometric.data import Data from torch_geometric.loader import DataLoader from gca_rom import scaling def graphs_dataset(dataset, AE_Params): """ graphs_dataset: function to process and scale the input dataset for graph autoencoder model. Inputs: dataset: an ...
3,515
38.954545
112
py
gca-rom
gca-rom-main/gca_rom/plotting.py
import numpy as np import matplotlib.pyplot as plt from gca_rom import scaling import matplotlib.gridspec as gridspec import matplotlib.cm as cm from matplotlib import ticker from matplotlib.ticker import MaxNLocator from mpl_toolkits.axes_grid1 import make_axes_locatable params = {'legend.fontsize': 'x-large', ...
8,379
46.613636
175
py
gca-rom
gca-rom-main/gca_rom/network.py
import sys import torch from torch import nn from gca_rom import gca, scaling, pde problem_name, variable, mu1_range, mu2_range = pde.problem(int(sys.argv[1])) class AE_Params(): """Class that holds the hyperparameters for the autoencoder model. Args: sparse_method (str): The method to use for spar...
5,946
39.732877
179
py
gca-rom
gca-rom-main/gca_rom/training.py
import torch import torch.nn.functional as F def train(model, optimizer, device, scheduler, params, train_loader, train_trajectories, AE_Params, history): """Trains the autoencoder model. This function trains the autoencoder model using mean squared error (MSE) loss and a map loss, where the map loss ...
5,063
48.647059
478
py
gca-rom
gca-rom-main/gca_rom/testing.py
import torch from tqdm import tqdm import numpy as np def evaluate(VAR, model, loader, params, AE_Params, test): """ This function evaluates the performance of a trained Autoencoder (AE) model. It encodes the input data using both the model's encoder and a mapping function, and decodes the resulting l...
2,071
44.043478
110
py
gca-rom
gca-rom-main/gca_rom/initialization.py
import os import torch import numpy as np import random import warnings def set_device(): """ Returns the device to be used (GPU or CPU) Returns: device (str): The device to be used ('cuda' if GPU is available, 'cpu' otherwise) """ device = 'cuda' if torch.cuda.is_available() else 'cpu' ...
1,224
21.685185
89
py
gca-rom
gca-rom-main/gca_rom/__init__.py
0
0
0
py
gca-rom
gca-rom-main/gca_rom/pde.py
import numpy as np def problem(argument): """ problem(argument: int) -> Tuple[str, str, np.ndarray, np.ndarray] This function takes in an integer argument and returns a tuple containing the problem name (str), variable name (str), mu1 (np.ndarray) and mu2 (np.ndarray) for the specified case. The pos...
1,771
32.433962
184
py
gca-rom
gca-rom-main/gca_rom/loader.py
import sys from torch_geometric.data import Dataset import torch import scipy class LoadDataset(Dataset): """ A custom dataset class which loads data from a .mat file using scipy.io.loadmat. data_mat : scipy.io.loadmat The loaded data in a scipy.io.loadmat object. U : torch.Tensor The...
1,488
41.542857
172
py
gca-rom
gca-rom-main/gca_rom/gca.py
import torch from torch import nn import torch.nn.functional as F from torch_geometric.nn import GMMConv class Encoder(torch.nn.Module): """ Encoder Class The Encoder class is a subclass of torch.nn.Module that implements a deep neural network for encoding graph data. It uses the Gaussian Mixture co...
5,918
36.226415
139
py
gca-rom
gca-rom-main/gca_rom/scaling.py
from sklearn import preprocessing import torch import sys def scaler_functions(k): match k: case 1: sc_name = "minmax" sc_fun = preprocessing.MinMaxScaler() case 2: sc_name = "robust" sc_fun = preprocessing.RobustScaler() case 3: ...
2,869
41.205882
163
py
gca-rom
gca-rom-main/docs/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...
2,162
33.333333
79
py
gca-rom
gca-rom-main/utils/test_all_scalar.py
import os # HYPER-PARAMETERS LIST problem_names_list = ["poisson", "advection", "graetz", "VX_navier_stokes", "VY_navier_stokes", "P_navier_stokes"] scalers_type_list = ["sample", "feature", "feature-sampling", "sampling-feature"] scalers_fun_list = ["minmax", "robust", "standard"] skip_connection_list = ["skip0", "sk...
2,774
52.365385
156
py
gca-rom
gca-rom-main/utils/h5_to_mat.py
""" .. _IMPORTING_dataset_form_FEniCS_solution: IMPORTING dataset form FEniCS solution - .h5 to .mat This script is used to import a FEniCS solution in .h5 format and convert it to a .mat file. Dependencies h5py numpy scipy Functions extract_edges(triangulation) Given a triangulation, this function returns...
2,107
27.876712
131
py
gca-rom
gca-rom-main/utils/save_all_scalar.py
import subprocess import numpy as np import pandas as pd import matplotlib.pyplot as plt import matplotlib.image as mpimg import warnings import seaborn as sns import os warnings.filterwarnings("ignore") # HYPER-PARAMETERS LIST model_names_list = ["poisson", "advection", "graetz", "navier_stokes"] problem_names_list =...
13,880
51.579545
249
py
CRST
CRST-master/evaluate.py
import argparse import scipy from scipy import ndimage import numpy as np import sys from packaging import version import time import util import torch import torchvision.models as models import torch.nn.functional as F from torch.utils import data, model_zoo from deeplab.model import Res_Deeplab from deeplab.datasets...
11,168
39.762774
176
py
CRST
CRST-master/util.py
""" utilities for convenience """ import contextlib import h5py import logging import os.path as osp import yaml from io import StringIO from PIL import Image import numpy as np cfg = {} def as_list(obj): """A utility function that treat the argument as a list. Parameters ---------- obj : object ...
2,693
26.489796
86
py
CRST
CRST-master/crst_seg.py
import argparse import sys from packaging import version import time import util import os import os.path as osp import timeit from collections import OrderedDict import scipy.io import torch import torchvision.models as models import torch.nn.functional as F from torch.utils import data, model_zoo import torch.backen...
47,013
48.229319
225
py
CRST
CRST-master/train.py
import argparse import torch import torch.nn as nn from torch.utils import data import numpy as np import pickle import cv2 import torch.optim as optim import scipy.misc import torch.backends.cudnn as cudnn import sys import os import os.path as osp from deeplab.model import Res_Deeplab from deeplab.loss import CrossE...
10,806
39.324627
164
py
CRST
CRST-master/dataset/helpers/labels.py
#!/usr/bin/python # # Cityscapes labels # from collections import namedtuple #-------------------------------------------------------------------------------- # Definitions #-------------------------------------------------------------------------------- # a label and all meta information Label = namedtuple( 'Label...
10,597
57.230769
199
py
CRST
CRST-master/dataset/helpers/labels_synthia.py
#!/usr/bin/python # # Cityscapes labels # from collections import namedtuple #-------------------------------------------------------------------------------- # Definitions #-------------------------------------------------------------------------------- # a label and all meta information Label = namedtuple( 'Label...
9,012
51.707602
199
py
CRST
CRST-master/dataset/helpers/labels_cityscapes_synthia.py
#!/usr/bin/python # # Cityscapes labels # from collections import namedtuple #-------------------------------------------------------------------------------- # Definitions #-------------------------------------------------------------------------------- # a label and all meta information Label = namedtuple( 'Label...
10,597
57.230769
199
py
CRST
CRST-master/deeplab/loss.py
import torch import torch.nn.functional as F import torch.nn as nn from torch.autograd import Variable class CrossEntropy2d(nn.Module): def __init__(self, size_average=True, ignore_label=255): super(CrossEntropy2d, self).__init__() self.size_average = size_average self.ignore_label = ignor...
1,585
44.314286
103
py
CRST
CRST-master/deeplab/model.py
import torch.nn as nn import math import torch.utils.model_zoo as model_zoo import torch import numpy as np affine_par = True def outS(i): i = int(i) i = (i+1)/2 i = int(np.ceil((i+1)/2.0)) i = (i+1)/2 return i def conv3x3(in_planes, out_planes, stride=1): "3x3 convolution with padding" r...
11,127
36.217391
139
py
CRST
CRST-master/deeplab/datasets.py
import os import os.path as osp import numpy as np import random import matplotlib.pyplot as plt import collections import torch import torchvision.transforms as transforms import torchvision import cv2 from torch.utils import data import sys from PIL import Image palette = [128, 64, 128, 244, 35, 232, 70, 70, 70, 102...
62,075
43.276748
309
py
CRST
CRST-master/deeplab/__init__.py
1
0
0
py
CRST
CRST-master/deeplab/metric.py
import os, sys import numpy as np from multiprocessing import Pool import copy_reg import types def _pickle_method(m): if m.im_self is None: return getattr, (m.im_class, m.im_func.func_name) else: return getattr, (m.im_self, m.im_func.func_name) copy_reg.pickle(types.MethodType, _pickle_metho...
2,856
27.858586
112
py
quaterny_opvs
quaterny_opvs-master/emulators/emulator_ptb7_th.py
#!/usr/bin/env python #========================================================================== from abstract_emulator import AbstractEmulator #========================================================================== class Emulator_PTB7_TH(AbstractEmulator): PATH = 'details_ptb7_th' HYPERPARAMS = { ...
2,370
27.914634
90
py
quaterny_opvs
quaterny_opvs-master/emulators/model_probabilistic.py
#!/usr/bin/env python import os import pickle import numpy as np import tensorflow as tf import tensorflow_probability as tfp tf_bijs = tfp.bijectors tf_dist = tfp.distributions tf_mean_field = tfp.layers.default_mean_field_normal_fn #============================================================== class...
11,713
35.154321
185
py
quaterny_opvs
quaterny_opvs-master/emulators/abstract_emulator.py
#!/usr/bin/env python import os, sys os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' sys.path.append('Emulators') import json import pickle import numpy as np import tensorflow as tf #===================================================================== class AbstractEmulator(object): def __init__(self, num_folds = 5):...
8,804
34.22
143
py
quaterny_opvs
quaterny_opvs-master/emulators/emulator_pbq_qf.py
#!/usr/bin/env python #=============================================================================== from abstract_emulator import AbstractEmulator #=============================================================================== class Emulator_PBQ_QF(AbstractEmulator): PATH = 'details_pbq_qf' HYPERPARAM...
2,408
28.378049
90
py
quaterny_opvs
quaterny_opvs-master/emulators/details_ptb7_th/parse_grid.py
#!/usr/bin/env python import pickle import numpy as np import matplotlib.pyplot as plt import seaborn as sns file_name = 'photobleaching_mixture01_grid.csv' features = [] targets = [] with open(file_name, 'r') as content: for line in content: linecontent = line.strip().strip('\xef').strip('\xbb').strip('\...
1,125
23.478261
97
py
quaterny_opvs
quaterny_opvs-master/emulators/details_ptb7_th/generate_indices.py
#!/usr/bin/env python import numpy as np import pickle #========================================================= NUM_SPECTRA = 1040 FOLD_SIZE = 170 np.random.seed(120415) #========================================================= indices = np.arange(NUM_SPECTRA) np.random.shuffle(indices) test_indices = i...
1,082
25.414634
119
py
quaterny_opvs
quaterny_opvs-master/emulators/details_pbq_qf/parse_grid.py
#!/usr/bin/env python import pickle import numpy as np import matplotlib.pyplot as plt import seaborn as sns file_name = 'photobleaching_mixture00_grid.csv' features = [] targets = [] with open(file_name, 'r') as content: for line in content: linecontent = line.strip().strip('\xef').strip('\xbb').strip('\...
1,146
23.404255
97
py
quaterny_opvs
quaterny_opvs-master/emulators/details_pbq_qf/generate_indices.py
#!/usr/bin/env python import numpy as np import pickle #========================================================= NUM_SPECTRA = 1040 FOLD_SIZE = 170 np.random.seed(120415) #========================================================= indices = np.arange(NUM_SPECTRA) np.random.shuffle(indices) test_indices = i...
1,082
25.414634
119
py
imf
imf-master/setup.py
#!/usr/bin/env python # Licensed under a 3-clause BSD style license - see LICENSE.rst # NOTE: The configuration for the package, including the name, version, and # other information are set in the setup.cfg file. import os import sys from setuptools import setup # First provide helpful messages if contributors try...
1,952
23.721519
76
py
imf
imf-master/examples/imf_schematic.py
""" I'm not entirely sure what this figure is supposed to show; it just plots a few variants of the lognormal IMF """ from imf import imf import numpy as np if __name__ == "__main__": import pylab as pl pl.matplotlib.rc_file("/Users/adam/.matplotlib/pubfiguresrc") pl.rc('font', family='cmr10') x = np...
1,545
32.608696
110
py
imf
imf-master/examples/clustermf_figure.py
from imf import color_of_cluster,make_cluster,lum_of_cluster import numpy as np if __name__ == "__main__": import pylab as pl alpha = 2 m0 = 5e2 mmax = 5e5 cluster_mass_xax = np.logspace(np.log10(m0),np.log10(mmax),1e4) def pr(m): return (m/m0)**-alpha probabilities = pr(cluster_ma...
3,057
34.55814
110
py
imf
imf-master/examples/pmf_evolution.py
import imf.imf, imf.pmf, imp from imf.pmf import ChabrierPMF_AcceleratingSF_IS, ChabrierPMF_AcceleratingSF_TC, ChabrierPMF_AcceleratingSF_CA#, ChabrierPMF_AcceleratingSF_2CTC import pylab as pl import numpy as np imp.reload(imf.imf) imp.reload(imf.pmf) imp.reload(imf.imf) imp.reload(imf.pmf) mmin = 0.033 for mmax in ...
2,430
45.75
154
py
imf
imf-master/examples/mass_to_light.py
import numpy as np import os import json from imf import imf import pylab as pl import matplotlib from astropy.utils.console import ProgressBar pl.rc('font', size=16) if os.path.exists('synth_data_m_to_l.json'): with open('synth_data_m_to_l.json', 'r') as fh: synth_data = json.load(fh) else: synth_dat...
4,914
40.302521
130
py
imf
imf-master/examples/sampling_methods.py
from imf import make_cluster import pylab as pl import imf maxmass = [imf.make_cluster(500, verbose=False, silent=True).max() for ii in range(10000)] maxmass_sorted = [imf.make_cluster(500, stop_criterion='sorted', verbose=False, silent=True).max() for ii in range(10000)]...
967
45.095238
79
py
imf
imf-master/examples/pmf_stats.py
import imf.imf, imf.pmf, imp imp.reload(imf.imf) imp.reload(imf.pmf) imp.reload(imf.imf) imp.reload(imf.pmf) from imf.pmf import ChabrierPMF_IS, ChabrierPMF_TC, ChabrierPMF_CA, ChabrierPMF_2CTC from imf.pmf import KroupaPMF_IS, KroupaPMF_TC, KroupaPMF_CA, KroupaPMF_2CTC from imf.pmf import McKeeOffner_AcceleratingSF_PM...
2,880
36.907895
177
py
imf
imf-master/examples/chabrier_comparisons.py
""" Compare the Chabrier distribution pulled from eqn 18 of Chabrier 2003 to that quoted in McKee & Offner 2010 as "Chabrier 2005" """ import imf import numpy as np import pylab as pl chabrier = imf.chabrierpowerlaw chabrier2005 = imf.ChabrierPowerLaw(lognormal_width=0.55*np.log(10), ...
1,328
33.973684
100
py
imf
imf-master/examples/imf_figure.py
""" Script to make an IMF diagram that shows dN(M)/dM vs M, then populates the area under the curve with an appropriate number of stars colored by their "true"(ish) color and sized by their mass. """ import imf from imf import coolplot,kroupa,make_cluster from astropy.table import Table import numpy as np if __name__...
5,721
44.412698
86
py
imf
imf-master/examples/pmf_comparison.py
import imf.imf, imf.pmf, imp imp.reload(imf.imf) imp.reload(imf.pmf) imp.reload(imf.imf) imp.reload(imf.pmf) from imf.pmf import ChabrierPMF_IS, ChabrierPMF_TC, ChabrierPMF_CA, ChabrierPMF_2CTC from imf.pmf import KroupaPMF_IS, KroupaPMF_TC, KroupaPMF_CA, KroupaPMF_2CTC import pylab as pl import numpy as np pl.rc('fon...
6,437
50.504
128
py
imf
imf-master/examples/hr_diagram.py
""" Create a Hertzprung-Russell (temperature-luminosity) diagram and mass-luminosity and mass-temperature diagrams populating the main sequence only with data from Ekström+ 2012 (Vizier catalog J/A+A/537/A146/iso). Colors come from vendian.org. """ import numpy as np import imf import pylab as pl from astroquery.vizie...
5,605
28.197917
80
py
imf
imf-master/imf/imf.py
""" Various codes to work with the initial mass function """ from __future__ import print_function import numpy as np import types import scipy.integrate import scipy.integrate as integrate from scipy.integrate import quad from astropy import units as u from . import distributions class MassFunction(object): """...
34,904
33.593657
102
py
imf
imf-master/imf/distributions.py
import numpy as np import scipy.stats class Distribution: """ The main class describing the distributions, to be inherited""" def __init__(self): self.m1 = 0 # edges of the support of the pdf self.m2 = np.inf pass def pdf(self, x): """ Return the Probability density funct...
10,611
30.39645
79
py
imf
imf-master/imf/plf.py
""" Protostellar luminosity functions as described by Offner and McKee, 2011 Alternatively, perhaps try to construct a probabilistic P(L; m, m_f) given a series of stellar evolution codes? """ import numpy as np import scipy.integrate import warnings from .imf import MassFunction, ChabrierPowerLaw chabrierpowerlaw...
2,862
36.181818
97
py
imf
imf-master/imf/pmf.py
""" Protostellar mass functions as described by McKee and Offner, 2010 """ import numpy as np import scipy.integrate import warnings from .imf import MassFunction, ChabrierPowerLaw, Kroupa chabrierpowerlaw = ChabrierPowerLaw() class McKeeOffner_PMF(MassFunction): default_mmin = 0.033 default_mmax = 3.0 ...
8,608
35.634043
104
py
imf
imf-master/imf/__init__.py
from .imf import *
19
9
18
py
imf
imf-master/imf/cmf.py
from __future__ import print_function import numpy as np from astropy import units as u from astropy import constants import scipy.stats from . import imf def pn11_mf(tnow=1, mmin=0.01*u.M_sun, mmax=120*u.M_sun, T0=10*u.K, T_mean=7*u.K, L0=10*u.pc, rho0=2e-21*u.g/u.cm**3, MS0=25, beta=0.4, alp...
10,822
37.379433
89
py
imf
imf-master/imf/tests/test_imf.py
import pytest import numpy as np import itertools from .. import imf from ..imf import kroupa, chabrierpowerlaw extra_massfunc_kwargs = {'schecter': {'m1': 1.0}, 'modified_schecter': {'m1': 1.0}, 'chabrierpowerlaw': {'mmid': 0.5}, } @pytest....
5,462
37.202797
89
py
imf
imf-master/imf/tests/test_distributions.py
import numpy as np import scipy.interpolate from .. import distributions as D np.random.seed(1) def sampltest(distr, left=None, right=None, bounds=None): # check that mean and stddev from the generated sample # match what we get from integrating the PDF def FF1(x): return distr.pdf(x) * x ...
5,757
28.228426
77
py
imf
imf-master/imf/tests/__init__.py
0
0
0
py
imaging_MLPs
imaging_MLPs-master/ImageNet/config.py
#Path to original dataset original_path='/workspace/media/hdd1/image_net_mini/imagenet-mini/train/' #Path to processed dataset data_path='/workspace/media/hdd1/image_net_mini/dataset2/' #Path to store trained models models_path= "/workspace/media/hdd1/image_net_mini/trained_networks/" #Path to store tensor board dat...
342
30.181818
73
py
imaging_MLPs
imaging_MLPs-master/ImageNet/networks/linear_mixer.py
import torch import torch.nn as nn from torch.nn import init import torch.nn.init as init import einops from einops.layers.torch import Rearrange from einops import rearrange class PatchEmbedding(nn.Module): def __init__( self, patch_size: int, embed_dim: int, channels: int ...
3,644
26.613636
127
py
imaging_MLPs
imaging_MLPs-master/ImageNet/networks/original_mixer.py
import torch import torch.nn as nn from torch.nn import init import torch.nn.init as init import einops from einops.layers.torch import Rearrange from einops import rearrange class PatchEmbeddings(nn.Module): def __init__( self, patch_size: int, hidden_dim: int, channels: int ...
3,674
26.840909
93
py
imaging_MLPs
imaging_MLPs-master/ImageNet/networks/img2img_mixer.py
import torch import torch.nn as nn from torch.nn import init import torch.nn.init as init import einops from einops.layers.torch import Rearrange from einops import rearrange class PatchEmbedding(nn.Module): def __init__( self, patch_size: int, embed_dim: int, channels: int ...
3,618
27.054264
127
py
imaging_MLPs
imaging_MLPs-master/ImageNet/networks/vit.py
''' This code is modified from https://github.com/facebookresearch/convit. To adapt the vit/convit to image reconstruction, variable input sizes, and patch sizes for both spatial dimensions. ''' import torch import torch.nn as nn from functools import partial import torch.nn.functional as F from timm.models.helpers im...
15,082
39.007958
186
py
imaging_MLPs
imaging_MLPs-master/ImageNet/networks/recon_net.py
import torch.nn as nn import torch.nn.functional as F from math import ceil, floor class ReconNet(nn.Module): def __init__(self, net): super().__init__() self.net = net def pad(self, x): _, _, h, w = x.shape hp, wp = self.net.patch_size f1 = ( (wp - w % wp) % wp ) / 2 ...
810
26.033333
90
py
imaging_MLPs
imaging_MLPs-master/ImageNet/networks/unet.py
""" Copyright (c) Facebook, Inc. and its affiliates. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. """ import torch from torch import nn from torch.nn import functional as F class Unet(nn.Module): """ PyTorch implementation of a U-Net ...
5,981
32.79661
88
py
imaging_MLPs
imaging_MLPs-master/ImageNet/networks/__init__.py
from .img2img_mixer import * from .linear_mixer import * from .original_mixer import * from .u_mixer import * from .unet import * from .recon_net import ReconNet from .vit import VisionTransformer
197
23.75
34
py
imaging_MLPs
imaging_MLPs-master/ImageNet/networks/u_mixer.py
import torch import torch.nn as nn from torch.nn import init import torch.nn.init as init import einops from einops.layers.torch import Rearrange from einops import rearrange class PatchEmbeddings(nn.Module): def __init__( self, patch_size: int, embed_dim: int, channels: int ...
6,516
28.488688
127
py
imaging_MLPs
imaging_MLPs-master/SIDD/config.py
#Path to original dataset original_path='/workspace/media/hdd1/SSID/SIDD_Small_sRGB_Only/Data/' #Path to processed dataset data_path='/workspace/media/hdd1/SSID/dataset/' #Path to store trained models models_path= "/workspace/media/hdd1/SSID/trained_models/" #Path to store tensor board data logs_path= './logs/'
315
27.727273
69
py
imaging_MLPs
imaging_MLPs-master/SIDD/networks/img2img_mixer.py
import torch import torch.nn as nn from torch.nn import init import torch.nn.init as init import einops from einops.layers.torch import Rearrange from einops import rearrange class PatchEmbedding(nn.Module): def __init__( self, patch_size: int, embed_dim: int, channels: int ...
3,618
27.054264
127
py
imaging_MLPs
imaging_MLPs-master/SIDD/networks/vit.py
''' This code is modified from https://github.com/facebookresearch/convit. To adapt the vit/convit to image reconstruction, variable input sizes, and patch sizes for both spatial dimensions. ''' import torch import torch.nn as nn from functools import partial import torch.nn.functional as F from timm.models.helpers im...
15,082
39.007958
186
py
imaging_MLPs
imaging_MLPs-master/SIDD/networks/recon_net.py
import torch.nn as nn import torch.nn.functional as F from math import ceil, floor class ReconNet(nn.Module): def __init__(self, net): super().__init__() self.net = net def pad(self, x): _, _, h, w = x.shape hp, wp = self.net.patch_size f1 = ( (wp - w % wp) % wp ) / 2 ...
810
26.033333
90
py
imaging_MLPs
imaging_MLPs-master/SIDD/networks/unet.py
""" Copyright (c) Facebook, Inc. and its affiliates. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. """ import torch from torch import nn from torch.nn import functional as F class Unet(nn.Module): """ PyTorch implementation of a U-Net ...
5,981
32.79661
88
py
imaging_MLPs
imaging_MLPs-master/SIDD/networks/__init__.py
from .img2img_mixer import * from .u_mixer import * from .unet import * from .recon_net import ReconNet from .vit import VisionTransformer
140
19.142857
34
py
imaging_MLPs
imaging_MLPs-master/SIDD/networks/u_mixer.py
import torch import torch.nn as nn from torch.nn import init import torch.nn.init as init import einops from einops.layers.torch import Rearrange from einops import rearrange class PatchEmbeddings(nn.Module): def __init__( self, patch_size: int, embed_dim: int, channels: int ...
6,516
28.488688
127
py
imaging_MLPs
imaging_MLPs-master/compressed_sensing/fastmri/losses.py
""" Copyright (c) Facebook, Inc. and its affiliates. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. """ import torch import torch.nn as nn import torch.nn.functional as F class SSIMLoss(nn.Module): """ SSIM loss module. """ de...
1,671
28.857143
87
py
imaging_MLPs
imaging_MLPs-master/compressed_sensing/fastmri/coil_combine.py
""" Copyright (c) Facebook, Inc. and its affiliates. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. """ import torch import fastmri def rss(data: torch.Tensor, dim: int = 0) -> torch.Tensor: """ Compute the Root Sum of Squares (RSS). ...
996
22.186047
66
py
imaging_MLPs
imaging_MLPs-master/compressed_sensing/fastmri/evaluate.py
""" Copyright (c) Facebook, Inc. and its affiliates. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. """ import argparse import pathlib from argparse import ArgumentParser from typing import Optional import h5py import numpy as np from runstats ...
4,903
27.847059
87
py
imaging_MLPs
imaging_MLPs-master/compressed_sensing/fastmri/math.py
""" Copyright (c) Facebook, Inc. and its affiliates. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. """ import numpy as np import torch def complex_mul(x: torch.Tensor, y: torch.Tensor) -> torch.Tensor: """ Complex multiplication. ...
2,728
25.754902
77
py
imaging_MLPs
imaging_MLPs-master/compressed_sensing/fastmri/utils.py
""" Copyright (c) Facebook, Inc. and its affiliates. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. """ from pathlib import Path from typing import Dict import h5py import numpy as np def save_reconstructions(reconstructions: Dict[str, np.nda...
1,467
28.36
80
py
imaging_MLPs
imaging_MLPs-master/compressed_sensing/fastmri/__init__.py
""" Copyright (c) Facebook, Inc. and its affiliates. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. """ import torch from packaging import version from .coil_combine import rss, rss_complex from .fftc import fftshift, ifftshift, roll from .losse...
758
26.107143
63
py
imaging_MLPs
imaging_MLPs-master/compressed_sensing/fastmri/fftc.py
""" Copyright (c) Facebook, Inc. and its affiliates. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. """ from typing import List, Optional import torch from packaging import version if version.parse(torch.__version__) >= version.parse("1.7.0"):...
5,535
25.236967
80
py
imaging_MLPs
imaging_MLPs-master/compressed_sensing/fastmri/data/volume_sampler.py
""" Copyright (c) Facebook, Inc. and its affiliates. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. """ from typing import List, Optional, Union import torch import torch.distributed as dist from fastmri.data.mri_data import CombinedSliceDatase...
4,332
36.678261
82
py
imaging_MLPs
imaging_MLPs-master/compressed_sensing/fastmri/data/mri_data.py
""" Copyright (c) Facebook, Inc. and its affiliates. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. """ import logging import os import pickle import random import xml.etree.ElementTree as etree from pathlib import Path from typing import Callab...
13,630
36.759003
116
py
imaging_MLPs
imaging_MLPs-master/compressed_sensing/fastmri/data/subsample.py
""" Copyright (c) Facebook, Inc. and its affiliates. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. """ import contextlib from typing import Optional, Sequence, Tuple, Union import numpy as np import torch @contextlib.contextmanager def temp_...
8,448
36.887892
88
py
imaging_MLPs
imaging_MLPs-master/compressed_sensing/fastmri/data/__init__.py
""" Copyright (c) Facebook, Inc. and its affiliates. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. """ from .mri_data import SliceDataset, CombinedSliceDataset from .volume_sampler import VolumeSampler
278
26.9
63
py
imaging_MLPs
imaging_MLPs-master/compressed_sensing/fastmri/data/transforms.py
""" Copyright (c) Facebook, Inc. and its affiliates. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. """ from typing import Dict, Optional, Sequence, Tuple, Union import fastmri import numpy as np import torch from .subsample import MaskFunc ...
12,887
30.205811
88
py
imaging_MLPs
imaging_MLPs-master/compressed_sensing/networks/img2img_mixer.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn import init import torch.nn.init as init import numpy as np import einops from einops.layers.torch import Rearrange from einops import rearrange class PatchEmbedding(nn.Module): def __init__( self, patch_size: int, ...
3,714
26.932331
127
py