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 |
|---|---|---|---|---|---|---|
ttt_for_deep_learning_cs | ttt_for_deep_learning_cs-master/unet/functions/common/test_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 numpy as np
import pytest
import torch
from common.subsample import MaskFunc
@pytest.mark.parametrize("center_fracs, accelerations,... | 1,506 | 30.395833 | 74 | py |
ttt_for_deep_learning_cs | ttt_for_deep_learning_cs-master/unet/functions/common/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 numpy as np
import torch
def create_mask_for_mask_type(mask_type_str, center_fractions, accelerations):
if mask_type_str == 'ran... | 7,423 | 42.415205 | 112 | py |
ttt_for_deep_learning_cs | ttt_for_deep_learning_cs-master/unet/functions/common/__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.
"""
| 178 | 24.571429 | 63 | py |
ttt_for_deep_learning_cs | ttt_for_deep_learning_cs-master/unet/functions/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 pathlib
import random
import h5py
from torch.utils.data import Dataset
class SliceData(Dataset):
"""
A PyTorch Dataset that... | 2,181 | 35.983051 | 95 | py |
ttt_for_deep_learning_cs | ttt_for_deep_learning_cs-master/unet/functions/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.
"""
| 178 | 24.571429 | 63 | py |
ttt_for_deep_learning_cs | ttt_for_deep_learning_cs-master/unet/functions/data/test_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.
"""
import numpy as np
import pytest
import torch
from common import utils
from common.subsample import RandomMaskFunc
from data import transfor... | 5,497 | 28.244681 | 83 | py |
ttt_for_deep_learning_cs | ttt_for_deep_learning_cs-master/unet/functions/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.
"""
import numpy as np
import torch
def to_tensor(data):
"""
Convert numpy array to PyTorch tensor. For complex arrays, the real and ima... | 11,863 | 32.047354 | 155 | py |
ttt_for_deep_learning_cs | ttt_for_deep_learning_cs-master/unet/functions/include/__init__.py | from .transforms import *
from .helpers import *
from .mri_helpers import * | 75 | 24.333333 | 26 | py |
ttt_for_deep_learning_cs | ttt_for_deep_learning_cs-master/unet/functions/include/mri_helpers.py | import torch
import torch.nn as nn
import torchvision
import sys
import numpy as np
from PIL import Image
import PIL
import numpy as np
from torch.autograd import Variable
import random
import numpy as np
import torch
import matplotlib.pyplot as plt
from PIL import Image
import PIL
from torch.autograd import Vari... | 4,616 | 32.215827 | 106 | py |
ttt_for_deep_learning_cs | ttt_for_deep_learning_cs-master/unet/functions/include/helpers.py | import torch
import torch.nn as nn
import torchvision
import sys
import numpy as np
from PIL import Image
import PIL
import numpy as np
from torch.autograd import Variable
import random
import numpy as np
import torch
import matplotlib.pyplot as plt
from PIL import Image
import PIL
from torch.autograd import Vari... | 4,860 | 26.308989 | 84 | py |
ttt_for_deep_learning_cs | ttt_for_deep_learning_cs-master/unet/functions/include/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.
"""
import numpy as np
import torch
def to_tensor(data):
"""
Convert numpy array to PyTorch tensor. For complex arrays, the real and ima... | 11,673 | 31.70028 | 155 | py |
ttt_for_deep_learning_cs | ttt_for_deep_learning_cs-master/unet/functions/include/pytorch_ssim/__init__.py | import torch
import torch.nn.functional as F
from torch.autograd import Variable
import numpy as np
from math import exp
def gaussian(window_size, sigma):
gauss = torch.Tensor([exp(-(x - window_size//2)**2/float(2*sigma**2)) for x in range(window_size)])
return gauss/gauss.sum()
def create_window(window_size,... | 2,641 | 34.702703 | 104 | py |
mechanical-power | mechanical-power-master/analysis/add-neuroblock.py | # Import libraries
from __future__ import print_function
import pandas as pd
import psycopg2
import getpass
import argparse
from collections import OrderedDict
# define the queries used to get neuromuscular blocks
queries = {"eicu": """
set search_path to public,eicu_crd;
with has_vent as
(
select
distinct... | 5,264 | 31.5 | 221 | py |
major-system | major-system-master/ngram_evaluator.py | # ngram_evaluator.py
# By Vincent Fiorentini and Megan Shao, (c) 2016.
from ngram_model import NgramModel
from nltk.util import ngrams
from math import e
class NgramEvaluator(object):
'''
Evaluates the likelihood of a given list of words appearing in text based on an N-gram
language model.
'''
de... | 2,009 | 32.5 | 96 | py |
major-system | major-system-master/number_encoder.py | # number_encoder.py
# By Vincent Fiorentini and Megan Shao, (c) 2016.
from pronouncer import Pronouncer # note: we could instead use nltk.corpus.cmudict
from ngram_model import NgramModel
from random import sample # for RandomGreedyEncoder
from itertools import product # for RandomGreedyEncoder
from nltk.corpus import... | 44,876 | 48.424009 | 103 | py |
major-system | major-system-master/major_system.py | # major_system.py
# By Vincent Fiorentini and Megan Shao, (c) 2016.
from pronouncer import Pronouncer
from number_encoder import (NumberEncoder, RandomGreedyEncoder, UnigramGreedyEncoder,
NgramContextEncoder, NgramPOSContextEncoder, ParserEncoder,
SentenceTaggerE... | 7,270 | 52.463235 | 102 | py |
major-system | major-system-master/pronouncer.py | # pronouncer.py
# By Vincent Fiorentini and Megan Shao, (c) 2016.
# This class uses the CMU Pronouncing Dictionary: http://www.speech.cs.cmu.edu/cgi-bin/cmudict
import codecs # for reading the CMU dictionary file
from nltk.corpus import brown
class Pronouncer(object):
'''
Pronouncer knows how to pronounce wor... | 5,352 | 50.970874 | 100 | py |
major-system | major-system-master/ngram_model.py | # ngram_model.py
# By Vincent Fiorentini and Megan Shao, (c) 2016.
from nltk.corpus import brown
from nltk.probability import ConditionalFreqDist, FreqDist, MLEProbDist, ConditionalProbDist
from nltk.util import ngrams
from math import log
class NgramBase(object):
'''
NgramBase is the base class for any N-gra... | 3,324 | 32.928571 | 100 | py |
major-system | major-system-master/stat_parser/parser.py | """
CKY algorithm from the "Natural Language Processing" course by Michael Collins
https://class.coursera.org/nlangp-001/class
"""
from collections import defaultdict
from pprint import pprint
try:
from nltk import Tree
def nltk_tree(t):
return Tree(t[0], [c if isinstance(c, str) else nltk_tree(c)... | 3,702 | 27.929688 | 85 | py |
major-system | major-system-master/stat_parser/learn.py | from os.path import exists
from glob import glob
from os import makedirs
from json import loads
from time import time
from stat_parser.treebanks.parse import normalize_questionbank
from stat_parser.treebanks.normalize import gen_norm
from stat_parser.treebanks.extract import get_sentence
from stat_parser.pcfg import P... | 2,059 | 33.333333 | 104 | py |
major-system | major-system-master/stat_parser/pcfg.py |
from collections import Counter, defaultdict
from json import loads, dumps
from stat_parser.word_classes import word_class
class PCFG:
RARE_WORD_COUNT = 5
def __init__(self):
self.q1 = defaultdict(float)
self.q2 = defaultdict(float)
self.well_known_words = set()
def nor... | 3,409 | 30.284404 | 81 | py |
major-system | major-system-master/stat_parser/word_classes.py | import re
CAP = re.compile('^[A-Z][a-z]+$')
def is_cap_word(word):
return CAP.match(word) is not None
PATTERNS = {
'_CAP_': CAP,
'_LY_' : re.compile('^[a-z]+ly$'),
'_NUM_': re.compile('^[0-9\.,/-]+$'),
'_ED_' : re.compile('^[a-z]+ed$'),
'_ING_': re.compile('^[a-z]+ing$'),
}
def word_class(... | 448 | 18.521739 | 41 | py |
major-system | major-system-master/stat_parser/tokenizer.py | # Natural Language Toolkit: Tokenizers
#
# Copyright (C) 2001-2013 NLTK Project
# Author: Edward Loper <edloper@gradient.cis.upenn.edu>
# Michael Heilman <mheilman@cmu.edu> (re-port from http://www.cis.upenn.edu/~treebank/tokenizer.sed)
import re
SYM_MAP = {
'(': '-LRB-',
')': '-RRB-',
}
class PennT... | 4,793 | 37.352 | 130 | py |
major-system | major-system-master/stat_parser/__init__.py | from stat_parser.parser import Parser, display_tree
| 52 | 25.5 | 51 | py |
major-system | major-system-master/stat_parser/paths.py | from os.path import join, dirname, abspath
ROOT = abspath(dirname(__file__))
TREEBANKS_DIR = join(ROOT, "treebanks")
TEMP_DIR = join(ROOT, "temp")
QUESTIONBANK_DIR = join(TREEBANKS_DIR, "QuestionBank")
QUESTIONBANK_DATA = join(QUESTIONBANK_DIR, "4000qs.txt")
QUESTIONBANK_PENN_DATA = join(TEMP_DIR, "penn_4000qs.txt")... | 706 | 31.136364 | 58 | py |
major-system | major-system-master/stat_parser/eval_parser.py | """
Parses evaluator from the "Natural Language Processing" course by Michael Collins
https://class.coursera.org/nlangp-001/class
"""
import re
from collections import defaultdict
class ParseError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return self.v... | 5,930 | 32.698864 | 160 | py |
major-system | major-system-master/stat_parser/treebanks/extract.py | """
Extract the words from a tree and reverse the tokenization
"""
def get_words(tree):
# Assume well formed
if len(tree) == 2:
return [tree[1]]
else:
return get_words(tree[1]) + get_words(tree[2])
LEFT = {
'``': '"',
'-LRB-': '(',
'$': '$',
}
RIGHT = {
"''": '"',
"-RR... | 930 | 19.23913 | 72 | py |
major-system | major-system-master/stat_parser/treebanks/__init__.py | 0 | 0 | 0 | py | |
major-system | major-system-master/stat_parser/treebanks/parse.py | # http://bulba.sdsu.edu/jeanette/thesis/PennTags.html
TAGS = set((
'S', # simple declarative clause, i.e. one that is not introduced by a (possible empty) subordinating conjunction or a wh-word and that does not exhibit subject-verb inversion.
'SBAR', # Clause introduced by a (possibly empty) subordinati... | 6,588 | 35.605556 | 225 | py |
major-system | major-system-master/stat_parser/treebanks/normalize.py | from json import dumps
from stat_parser.treebanks.parse import parse_treebank
from stat_parser.word_classes import is_cap_word
def chomsky_normal_form(tree):
if not isinstance(tree, list):
raise Exception("Rule should be a list")
n = len(tree)
if n < 2:
raise Exception("Rule should h... | 3,700 | 27.469231 | 84 | py |
DCEC | DCEC-master/ConvAE.py | from keras.layers import Conv2D, Conv2DTranspose, Dense, Flatten, Reshape
from keras.models import Sequential, Model
from keras.utils.vis_utils import plot_model
import numpy as np
def CAE(input_shape=(28, 28, 1), filters=[32, 64, 128, 10]):
model = Sequential()
if input_shape[0] % 8 == 0:
pad3 = 'sam... | 3,398 | 38.068966 | 121 | py |
DCEC | DCEC-master/datasets.py | import numpy as np
def load_mnist():
# the data, shuffled and split between train and test sets
from keras.datasets import mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()
x = np.concatenate((x_train, x_test))
y = np.concatenate((y_train, y_test))
x = x.reshape(-1, 28, 28, 1).as... | 1,619 | 33.468085 | 113 | py |
DCEC | DCEC-master/metrics.py | import numpy as np
from sklearn.metrics import normalized_mutual_info_score, adjusted_rand_score
nmi = normalized_mutual_info_score
ari = adjusted_rand_score
def acc(y_true, y_pred):
"""
Calculate clustering accuracy. Require scikit-learn installed
# Arguments
y: true labels, numpy.array with sh... | 859 | 30.851852 | 77 | py |
DCEC | DCEC-master/DCEC.py | from time import time
import numpy as np
import keras.backend as K
from keras.engine.topology import Layer, InputSpec
from keras.models import Model
from keras.utils.vis_utils import plot_model
from sklearn.cluster import KMeans
import metrics
from ConvAE import CAE
class ClusteringLayer(Layer):
"""
Clusterin... | 11,131 | 40.849624 | 122 | py |
text_style_transfer | text_style_transfer-master/zclassifiershiftedae/main.py | # -*- coding: utf-8 -*-
# Copyright 2019 "Style Transfer for Texts: to Err is Human, but Error Margins Matter" Authors. All Rights Reserved.
#
# It's a modified code from
# Toward Controlled Generation of Text, ICML2017
# Zhiting Hu, Zichao Yang, Xiaodan Liang, Ruslan Salakhutdinov, Eric Xing
# https://github.com/asym... | 14,784 | 41.002841 | 138 | py |
text_style_transfer | text_style_transfer-master/zclassifiershiftedae/manual_BLEU.py | # -*- coding: utf-8 -*-
# Copyright 2019 "Style Transfer for Texts: to Err is Human, but Error Margins Matter" Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#... | 2,020 | 35.089286 | 116 | py |
text_style_transfer | text_style_transfer-master/zclassifiershiftedae/ctrl_gen_model.py | # -*- coding: utf-8 -*-
# Copyright 2019 "Style Transfer for Texts: to Err is Human, but Error Margins Matter" Authors. All Rights Reserved.
#
# It's a modified code from
# Toward Controlled Generation of Text, ICML2017
# Zhiting Hu, Zichao Yang, Xiaodan Liang, Ruslan Salakhutdinov, Eric Xing
# https://github.com/asym... | 10,613 | 36.772242 | 116 | py |
text_style_transfer | text_style_transfer-master/zclassifiershiftedae/prepare_data.py | # -*- coding: utf-8 -*-
# It's a code from
# Toward Controlled Generation of Text, ICML2017
# Zhiting Hu, Zichao Yang, Xiaodan Liang, Ruslan Salakhutdinov, Eric Xing
# https://github.com/asyml/texar/tree/master/examples/text_style_transfer
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may n... | 1,228 | 26.931818 | 74 | py |
text_style_transfer | text_style_transfer-master/zclassifiershiftedae/config.py | # -*- coding: utf-8 -*-
# Copyright 2019 "Style Transfer for Texts: to Err is Human, but Error Margins Matter" Authors. All Rights Reserved.
#
# It's a modified code from
# Toward Controlled Generation of Text, ICML2017
# Zhiting Hu, Zichao Yang, Xiaodan Liang, Ruslan Salakhutdinov, Eric Xing
# https://github.com/asym... | 4,385 | 26.936306 | 116 | py |
text_style_transfer | text_style_transfer-master/zclassifiershiftedae/result_table.py | # -*- coding: utf-8 -*-
# Copyright 2019 "Style Transfer for Texts: to Err is Human, but Error Margins Matter" Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#... | 2,084 | 39.096154 | 117 | py |
text_style_transfer | text_style_transfer-master/zclassifiershiftedae/prepare_manual.py | # -*- coding: utf-8 -*-
# Copyright 2019 "Style Transfer for Texts: to Err is Human, but Error Margins Matter" Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#... | 2,576 | 32.038462 | 116 | py |
text_style_transfer | text_style_transfer-master/shiftedae/main.py | # -*- coding: utf-8 -*-
# Copyright 2019 "Style Transfer for Texts: to Err is Human, but Error Margins Matter" Authors. All Rights Reserved.
#
# It's a modified code from
# Toward Controlled Generation of Text, ICML2017
# Zhiting Hu, Zichao Yang, Xiaodan Liang, Ruslan Salakhutdinov, Eric Xing
# https://github.com/asym... | 13,630 | 40.306061 | 127 | py |
text_style_transfer | text_style_transfer-master/shiftedae/manual_BLEU.py | # -*- coding: utf-8 -*-
# Copyright 2019 "Style Transfer for Texts: to Err is Human, but Error Margins Matter" Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#... | 2,021 | 35.107143 | 116 | py |
text_style_transfer | text_style_transfer-master/shiftedae/ctrl_gen_model.py | # -*- coding: utf-8 -*-
# Copyright 2019 "Style Transfer for Texts: to Err is Human, but Error Margins Matter" Authors. All Rights Reserved.
#
# It's a modified code from
# Toward Controlled Generation of Text, ICML2017
# Zhiting Hu, Zichao Yang, Xiaodan Liang, Ruslan Salakhutdinov, Eric Xing
# https://github.com/asym... | 9,010 | 36.235537 | 116 | py |
text_style_transfer | text_style_transfer-master/shiftedae/prepare_data.py | # -*- coding: utf-8 -*-
# It's a code from
# Toward Controlled Generation of Text, ICML2017
# Zhiting Hu, Zichao Yang, Xiaodan Liang, Ruslan Salakhutdinov, Eric Xing
# https://github.com/asyml/texar/tree/master/examples/text_style_transfer
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may n... | 1,227 | 27.55814 | 74 | py |
text_style_transfer | text_style_transfer-master/shiftedae/config.py | # -*- coding: utf-8 -*-
# Copyright 2019 "Style Transfer for Texts: to Err is Human, but Error Margins Matter" Authors. All Rights Reserved.
#
# It's a modified code from
# Toward Controlled Generation of Text, ICML2017
# Zhiting Hu, Zichao Yang, Xiaodan Liang, Ruslan Salakhutdinov, Eric Xing
# https://github.com/asym... | 4,187 | 27.297297 | 116 | py |
text_style_transfer | text_style_transfer-master/shiftedae/result_table.py | # -*- coding: utf-8 -*-
# Copyright 2019 "Style Transfer for Texts: to Err is Human, but Error Margins Matter" Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#... | 2,084 | 39.096154 | 117 | py |
text_style_transfer | text_style_transfer-master/shiftedae/prepare_manual.py | # -*- coding: utf-8 -*-
# Copyright 2019 "Style Transfer for Texts: to Err is Human, but Error Margins Matter" Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#... | 2,576 | 32.038462 | 116 | py |
text_style_transfer | text_style_transfer-master/zclassifier/main.py | # -*- coding: utf-8 -*-
# Copyright 2019 "Style Transfer for Texts: to Err is Human, but Error Margins Matter" Authors. All Rights Reserved.
#
# It's a modified code from
# Toward Controlled Generation of Text, ICML2017
# Zhiting Hu, Zichao Yang, Xiaodan Liang, Ruslan Salakhutdinov, Eric Xing
# https://github.com/asym... | 13,971 | 39.973607 | 116 | py |
text_style_transfer | text_style_transfer-master/zclassifier/manual_BLEU.py | # -*- coding: utf-8 -*-
# Copyright 2019 "Style Transfer for Texts: to Err is Human, but Error Margins Matter" Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#... | 2,093 | 33.9 | 116 | py |
text_style_transfer | text_style_transfer-master/zclassifier/ctrl_gen_model.py | # -*- coding: utf-8 -*-
# Copyright 2019 "Style Transfer for Texts: to Err is Human, but Error Margins Matter" Authors. All Rights Reserved.
#
# It's a modified code from
# Toward Controlled Generation of Text, ICML2017
# Zhiting Hu, Zichao Yang, Xiaodan Liang, Ruslan Salakhutdinov, Eric Xing
# https://github.com/asym... | 9,214 | 34.856031 | 116 | py |
text_style_transfer | text_style_transfer-master/zclassifier/prepare_data.py | # -*- coding: utf-8 -*-
# It's a code from
# Toward Controlled Generation of Text, ICML2017
# Zhiting Hu, Zichao Yang, Xiaodan Liang, Ruslan Salakhutdinov, Eric Xing
# https://github.com/asyml/texar/tree/master/examples/text_style_transfer
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may n... | 1,227 | 26.909091 | 74 | py |
text_style_transfer | text_style_transfer-master/zclassifier/config.py | # -*- coding: utf-8 -*-
# Copyright 2019 "Style Transfer for Texts: to Err is Human, but Error Margins Matter" Authors. All Rights Reserved.
#
# It's a modified code from
# Toward Controlled Generation of Text, ICML2017
# Zhiting Hu, Zichao Yang, Xiaodan Liang, Ruslan Salakhutdinov, Eric Xing
# https://github.com/asym... | 4,349 | 27.064516 | 116 | py |
text_style_transfer | text_style_transfer-master/zclassifier/result_table.py | # -*- coding: utf-8 -*-
# Copyright 2019 "Style Transfer for Texts: to Err is Human, but Error Margins Matter" Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#... | 2,137 | 37.178571 | 117 | py |
text_style_transfer | text_style_transfer-master/zclassifier/prepare_manual.py | # -*- coding: utf-8 -*-
# Copyright 2019 "Style Transfer for Texts: to Err is Human, but Error Margins Matter" Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#... | 2,576 | 32.038462 | 116 | py |
WeakLensingDeblending | WeakLensingDeblending-master/fisher.py | #!/usr/bin/env python
"""Create plots to illustrate galaxy parameter error estimation using Fisher matrices.
"""
from __future__ import print_function, division
import argparse
import numpy as np
import matplotlib.pyplot as plt
import astropy.table
import descwl
def main():
# Initialize and parse command-lin... | 10,873 | 42.670683 | 98 | py |
WeakLensingDeblending | WeakLensingDeblending-master/setup.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from setuptools import setup
requirements = [
'fitsio',
'galsim',
'numpy',
'astropy',
'lmfit',
'six'
]
setup(
name='descwl',
version='0.3dev',
description='Weak lensing fast simulations and analysis for the LSST DESC',
long_descrip... | 730 | 21.151515 | 84 | py |
WeakLensingDeblending | WeakLensingDeblending-master/simulate.py | #!/usr/bin/env python
"""Fast image simulation using GalSim for weak lensing studies.
"""
from __future__ import print_function, division
import argparse
import descwl
def main():
# Initialize and parse command-line arguments.
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpForm... | 5,795 | 44.637795 | 205 | py |
WeakLensingDeblending | WeakLensingDeblending-master/dbquery.py | #!/usr/bin/env python
"""Query the LSST DM simulation galaxy catalog.
Documentation for this program is available at
http://weaklensingdeblending.readthedocs.io/en/latest/programs.html#dbquery
"""
from __future__ import print_function, division
import argparse
import math
#import _mssql
from sqlalchemy.orm import s... | 5,844 | 35.761006 | 146 | py |
WeakLensingDeblending | WeakLensingDeblending-master/skeleton.py | #!/usr/bin/env python
"""Skeleton program to demonstrate reading and analyzing simulation output.
This program reads a simulation output file 'demo.fits' and then loops over
all overlapping groups with exactly two members, with some additional cuts on
the galaxy properties, finally saving images of each pair to an out... | 1,750 | 35.479167 | 82 | py |
WeakLensingDeblending | WeakLensingDeblending-master/display.py | #!/usr/bin/env python
"""Display simulated images and analysis results generated by the simulate program.
"""
from __future__ import print_function, division
import math
import argparse
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.collections
import matplotlib.colors
import matplotlib.cm
impo... | 21,205 | 49.014151 | 102 | py |
WeakLensingDeblending | WeakLensingDeblending-master/descwl/render.py | """Render source models as simulated survey observations.
"""
from __future__ import print_function, division
import math
import inspect
import numpy as np
import galsim
import descwl.analysis
class SourceNotVisible(Exception):
"""Custom exception to indicate that a source has no visible pixels above threshold.
... | 28,290 | 51.005515 | 201 | py |
WeakLensingDeblending | WeakLensingDeblending-master/descwl/model.py | """Model astronomical sources.
"""
from __future__ import print_function, division
import math
import inspect
import numpy as np
import numpy.linalg
import galsim
def sersic_second_moments(n,hlr,q,beta):
"""Calculate the second-moment tensor of a sheared Sersic radial profile.
Args:
n(int): Sersic... | 24,105 | 45.898833 | 147 | py |
WeakLensingDeblending | WeakLensingDeblending-master/descwl/analysis.py | """Perform weak-lensing analysis of simulated sources.
"""
from __future__ import print_function, division
import numpy as np
import scipy.spatial
import astropy.table
import galsim
import lmfit
import descwl.model
from distutils.version import LooseVersion
from six import iteritems
def grl_equilibration(fish):... | 65,553 | 50.09431 | 345 | py |
WeakLensingDeblending | WeakLensingDeblending-master/descwl/survey.py | """Manage the parameters that define a simulated survey's camera design and observing conditions.
"""
from __future__ import print_function, division
import math
import numpy as np
import numpy.linalg
import galsim
from six import iteritems
class Survey(object):
"""Survey camera and observing parameters.
... | 24,644 | 47.996024 | 257 | py |
WeakLensingDeblending | WeakLensingDeblending-master/descwl/__init__.py | """Weak lensing fast simulations and analysis for the LSST Dark Energy Science Collaboration.
This code was primarily developed to study the effects of overlapping sources on shear estimation,
photometric redshift algorithms, and deblending algorithms.
"""
__author__ = 'WeakLensingDeblending developers'
__email__ = '... | 509 | 27.333333 | 98 | py |
WeakLensingDeblending | WeakLensingDeblending-master/descwl/catalog.py | """Load source parameters from catalog files.
There is a separate :doc:`catalog page </catalog>` with details on the expected catalog
contents and formatting.
"""
from __future__ import print_function, division
import math
import inspect
import os.path
import astropy.table
class Reader(object):
"""Read source p... | 13,020 | 47.405204 | 110 | py |
WeakLensingDeblending | WeakLensingDeblending-master/descwl/output.py | """Configure and handle simulation output.
There is a separate :doc:`output page </output>` with details on what goes into the
output and how it is formatted.
"""
from __future__ import print_function, division
import os
import os.path
import inspect
import numpy as np
import astropy.table
import astropy.io.fits
i... | 12,745 | 44.848921 | 100 | py |
WeakLensingDeblending | WeakLensingDeblending-master/descwl/trace.py | """Trace program resource usage.
"""
from __future__ import print_function, division
import os
class Memory(object):
"""Trace memory usage for the current program.
Args:
enabled(bool): Enable memory tracing.
"""
def __init__(self,enabled):
self.enabled = enabled
if self.enable... | 1,249 | 29.487805 | 73 | py |
WeakLensingDeblending | WeakLensingDeblending-master/docs/conf.py | # -*- coding: utf-8 -*-
#
# WeakLensingDeblending documentation build configuration file, created by
# sphinx-quickstart on Wed Dec 3 17:14:11 2014.
#
# 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
# autogenerat... | 11,160 | 29.083558 | 98 | py |
evaluation-autoguide | evaluation-autoguide-main/utils.py | import os
import numpy, numpyro, pyro
import pathlib
from typing import Any, Dict, IO
from dataclasses import dataclass, field
from pandas import DataFrame, Series
from posteriordb import PosteriorDatabase
from os.path import splitext, basename
from itertools import product
from cmdstanpy import CmdStanModel
from sta... | 2,859 | 27.888889 | 73 | py |
evaluation-autoguide | evaluation-autoguide-main/eval.py | import logging, datetime, os, sys, traceback, re, argparse
import numpyro
import jax
from stannumpyro.dppl import NumPyroModel
from numpyro.infer import Trace_ELBO
from numpyro.optim import Adam
import numpyro.infer.autoguide as autoguide
from utils import (
compile_model,
get_posterior,
summary,
golds,... | 6,107 | 33.314607 | 126 | py |
DBA | DBA-master/DBA_multivariate.py | '''
/*******************************************************************************
* Copyright (C) 2018 Francois Petitjean
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of t... | 7,329 | 32.778802 | 127 | py |
DBA | DBA-master/DBA.py | '''
/*******************************************************************************
* Copyright (C) 2018 Francois Petitjean
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of t... | 6,274 | 32.026316 | 116 | py |
DBA | DBA-master/cython/test.py | from __future__ import division
import numpy as np
import matplotlib.pyplot as plt
from DBA import performDBA
def main():
#generating synthetic data
n_series = 20
length = 200
series = list()
padding_length=30
indices = range(0, length-padding_length)
main_profile_gen = np.array(list(map(l... | 1,196 | 28.925 | 116 | py |
DBA | DBA-master/cython/setup.py | from distutils.core import setup
from Cython.Build import cythonize
import numpy
setup(
ext_modules=cythonize("DBA.pyx",compiler_directives={'boundscheck':False,'wraparound':False}),
include_dirs=[numpy.get_include()]
)
| 229 | 24.555556 | 98 | py |
csshar_tfa | csshar_tfa-main/ssl_training.py | import argparse
from models.dtw import DTWModule
import os
from pytorch_lightning import Trainer, seed_everything
from models.simclr import SimCLR
from models.mlp import LinearClassifier, MLPDropout, ProjectionMLP, MLP
from models.supervised import SupervisedModel
from utils.experiment_utils import generate_experime... | 17,219 | 45.540541 | 218 | py |
csshar_tfa | csshar_tfa-main/split_dataset.py | import argparse
import math
import os
import numpy as np
import random
import shutil
from utils.experiment_utils import seed_all
def parse_arguments():
parser = argparse.ArgumentParser()
parser.add_argument('--seed', help='seed_value', default=28)
parser.add_argument("--dataset", help="dataset to split"... | 5,494 | 39.703704 | 162 | py |
csshar_tfa | csshar_tfa-main/sample_datasets.py | import argparse
import os
import matplotlib.pyplot as plt
import pandas as pd
from scipy.signal import resample
from datasets.mobi_act_data import (MOBI_ACT_COLUMNS_TO_IGNORE,
SCENARIOS_TO_IGNORE, MobiActDataset,
MobiActInstance)
from datasets.mo... | 9,914 | 39.469388 | 226 | py |
csshar_tfa | csshar_tfa-main/normalization.py | import argparse
import os
import numpy as np
import pandas as pd
def get_means(file_paths):
""" Function for calculating means for each column accross the whole training set consisting of multiple files
Parameters
----------
file_paths : array-like
a list of paths to trai... | 2,650 | 29.471264 | 119 | py |
csshar_tfa | csshar_tfa-main/callbacks/log_confusion_matrix.py | import pytorch_lightning as pl
import pytorch_lightning.loggers as loggers
import wandb
class LogConfusionMatrix(pl.Callback):
"""
A callback which caches all labels and predictions encountered during a testing epoch,
then logs a confusion matrix to WandB at the end of the test.
"""
def __init__(se... | 1,562 | 34.522727 | 139 | py |
csshar_tfa | csshar_tfa-main/callbacks/log_classifier_metrics.py | import pytorch_lightning as pl
from torch import nn
import torch
import torchmetrics
class LogClassifierMetrics(pl.Callback):
"""
A callback which logs one or more classifier-specific metrics at the end of each
validation and test epoch, to all available loggers.
The available metrics are: accuracy, pr... | 2,465 | 43.035714 | 145 | py |
csshar_tfa | csshar_tfa-main/models/attention_lstm.py | import numpy as np
from torch import nn
import torch
import torch.nn.functional as F
from .mlp import ProjectionMLP_SimCLR, SimSiamMLP
class AttnLSTM(nn.Module):
def __init__(self,
input_dim,
hidden_dim,
output_dim,
n_layers=1,
sensor_attention=False,
temporal_attention=False,
retu... | 3,995 | 29.738462 | 81 | py |
csshar_tfa | csshar_tfa-main/models/simclr.py | import torch
import torch.nn.functional as F
from pytorch_lightning.core.lightning import LightningModule
from torch import nn
from apex.parallel.LARC import LARC
class SimCLR(LightningModule):
def __init__(self,
encoder,
projection,
ssl_batch_size=128,
temperatu... | 5,350 | 37.496403 | 153 | py |
csshar_tfa | csshar_tfa-main/models/supervised.py | from pandas import lreshape
import torch
import torch.nn as nn
from pytorch_lightning.core.lightning import LightningModule
class SupervisedModel(LightningModule):
def __init__(self,
encoder,
classifier,
fine_tuning=False,
optimizer_name='adam',
metric_sc... | 3,129 | 30.938776 | 110 | py |
csshar_tfa | csshar_tfa-main/models/conv_net.py | import torch.nn as nn
class CNN1D(nn.Module):
def __init__(self,
in_channels,
len_seq=30,
out_channels=[32, 64, 128],
fc_size=256,
kernel_size=3,
stride=1,
padding=1,
pool_padding... | 2,442 | 39.716667 | 146 | py |
csshar_tfa | csshar_tfa-main/models/mlp.py | import torch
import torch.nn as nn
class MLP(nn.Module):
def __init__(self, in_size, out_size, hidden=[256, 128], relu_type='leaky'):
super().__init__()
self.name = 'MLP'
if relu_type == 'leaky':
self.relu = nn.LeakyReLU(inplace=True)
else:
self.relu = nn.ReL... | 2,209 | 25.626506 | 80 | py |
csshar_tfa | csshar_tfa-main/models/dtw.py | import torch
import torch.nn.functional as F
from apex.parallel.LARC import LARC
from libraries.pytorch_softdtw_cuda.soft_dtw_cuda import SoftDTW
from pytorch_lightning.core.lightning import LightningModule
from torch import nn
from models.simclr import NTXent
class DTWModule(LightningModule):
"""
Implementa... | 4,302 | 36.417391 | 189 | py |
csshar_tfa | csshar_tfa-main/models/vanilla_lstm.py | from torch import nn
class VanillaLSTM(nn.Module):
def __init__(self, input_dim, hidden_dim, output_dim, n_layers=1, norm_out=False, get_lstm_features=False, initialize_lstm=False):
super(VanillaLSTM, self).__init__()
self.name = 'vanilla_lstm'
self.input_dim = input_dim
self.hidden_dim = hidden_dim
self.n_... | 921 | 30.793103 | 131 | py |
csshar_tfa | csshar_tfa-main/models/cae.py | import torch
import torch.nn as nn
from models.transformer import ConvLayers, PositionalEncoding, TransformerEncoderLayerWeights, TransformerEncoderWeights
class Encoder(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, stride, padding, pooling_kernel, pooling_padding):
super(Encoder, self).__... | 6,739 | 38.186047 | 187 | py |
csshar_tfa | csshar_tfa-main/models/transformer.py | import math
from typing import Optional
import torch
import torch.nn as nn
from torch import Tensor
from pytorch_lightning.core.lightning import LightningModule
class PositionalEncoding(nn.Module):
"""
Implementation of positional encoding from https://github.com/pytorch/examples/tree/master/word_language_m... | 6,082 | 39.553333 | 176 | py |
csshar_tfa | csshar_tfa-main/datasets/sensor_torch_datamodule.py | from typing import Optional
from pytorch_lightning import LightningDataModule
from torch.utils.data.dataloader import DataLoader
from datasets.sensor_torch_dataset import SensorTorchDataset
class SensorDataModule(LightningDataModule):
def __init__(self,
train_path,
val_path,
... | 3,074 | 31.03125 | 160 | py |
csshar_tfa | csshar_tfa-main/datasets/uschad_data.py | import os
import numpy as np
import pandas as pd
from scipy.io import loadmat
FREQUENCY = 100
COLUMNS = [
'acc_x, w/ unit g (gravity)',
'acc_y, w/ unit g',
'acc_z, w/ unit g',
'gyro_x, w/ unit dps (degrees per second)',
'gyro_y, w/ unit dps',
'gyro_z, w/ unit dps'
]
class USCDataset():
"... | 3,557 | 33.882353 | 204 | py |
csshar_tfa | csshar_tfa-main/datasets/mobi_act_data.py | import os
import numpy as np
import pandas as pd
from torch.utils.data import Dataset
SCENARIOS_TO_IGNORE = {
'FOL',
'FKL',
'SDL',
'LYI',
'SLH',
'SBW',
'SLW',
'SBE',
'SRH',
'BSC'
}
MOBI_ACT_LABELS_DICT = {
'STD': 0,
'WAL': 1,
'JOG': 2,
'JUM': 3,
'STU': 4,
'STN': 5,
'SCH': 6,
'SIT': 7,
'CHU': 8,
'... | 3,950 | 25.695946 | 151 | py |
csshar_tfa | csshar_tfa-main/datasets/pamap_data.py | import os
import numpy as np
import pandas as pd
from torch.utils.data import Dataset
class PamapDataset():
""" A class for Pamap2 dataset structure inculding paths to each subject and experiment file
Attributes:
-----------
root_dir : str
Path to the root directory of the da... | 4,405 | 40.566038 | 157 | py |
csshar_tfa | csshar_tfa-main/datasets/ucihar_data.py | import numpy as np
import os
import pandas as pd
UCI_ACTIVITIES_TO_IGNORE = [7, 8, 9, 10, 11, 12]
class SmartphoneRawDataset():
""" A class for uci smartphones dataset structure inculding paths to each subject and experiment file
Attributes:
-----------
root_dir : str
Path to ... | 4,397 | 40.102804 | 126 | py |
csshar_tfa | csshar_tfa-main/datasets/motion_sense_data.py | import os
import numpy as np
import pandas as pd
from torch.utils.data import Dataset
ACTIVITIES_DICT = {
'dws': 0,
'jog': 1,
'sit': 2,
'std': 3,
'ups': 4,
'wlk': 5
}
MOTION_SENSE_COLUMNS_TO_IGNORE = [
'attitude.roll',
'attitude.pitch',
'attitude.yaw',
'gravity.x',
'gravity.y',
'gravity.z'
]
class... | 3,012 | 26.390909 | 105 | py |
csshar_tfa | csshar_tfa-main/datasets/sensor_torch_dataset.py | import os
import numpy as np
import pandas as pd
import random
from torch.utils.data import Dataset
from tqdm import tqdm
class SensorTorchDataset(Dataset):
def __init__(self, data_path, get_subjects=False, subj_act=False, ignore_subject=None, column_names=None, ssl=False, transforms=None, limited=False, limited... | 7,463 | 41.651429 | 217 | py |
csshar_tfa | csshar_tfa-main/utils/augmentation_utils.py | import numpy as np
import pandas as pd
from torchvision import transforms
class Shift():
def __init__(self, max_shift):
self.max_shift = max_shift
def __call__(self, x):
shift_len = np.random.randint(0, self.max_shift)
x = np.roll(x, shift_len, axis=0)
return x
class Jitteri... | 2,407 | 23.824742 | 88 | py |
csshar_tfa | csshar_tfa-main/utils/training_utils.py | import importlib
import itertools
import os
import shutil
import torch
from models.mlp import ProjectionMLP
from models.simclr import SimCLR
from models.mlp import MLP, MLPDropout
from models.supervised import SupervisedModel
from torchvision import transforms
from pytorch_lightning import loggers
from pytorch_lightni... | 9,115 | 38.124464 | 158 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.