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
inversegraphics
inversegraphics-master/test.py
#!/usr/bin/env python3.4m import matplotlib matplotlib.use('Agg') import scene_io_utils from blender_utils import * from generative_models import * from tabulate import tabulate import matplotlib.pyplot as plt from matplotlib.font_manager import FontProperties import cv2 plt.ioff() numpy.random.seed(1) inchToMeter =...
29,478
47.645215
559
py
inversegraphics
inversegraphics-master/differentiable_renderer.py
import chumpy as ch from chumpy import depends_on, Ch import cv2 import numpy as np import scipy.sparse as sp from chumpy.utils import row, col from opendr.geometry import Rodrigues import warnings #Make simple experiment. def nanmean(a, axis): # don't call nan_to_num in here, unless you check that # occlusion...
14,887
40.127072
214
py
inversegraphics
inversegraphics-master/lasagne_nn.py
#!/usr/bin/env python """ Usage example employing Lasagne for digit recognition using the MNIST dataset. This example is deliberately structured as a long flat file, focusing on how to use Lasagne, instead of focusing on writing maximally modular and reusable code. It is used as the foundation for the introductory La...
63,328
40.122727
197
py
inversegraphics
inversegraphics-master/densecrf_model.py
""" Usage: python util_inference_example.py image annotations Adapted from the dense_inference.py to demonstate the usage of the util functions. """ import sys import numpy as np import cv2 import pydensecrf.densecrf as dcrf import matplotlib.pylab as plt from skimage.segmentation import relabel_sequential import skim...
4,856
31.165563
131
py
inversegraphics
inversegraphics-master/probLineSearch.py
from scipy.special import erf import numpy as np from scipy.stats import mvn import ipdb def probLineSearch(func, x0, f0, df0, search_direction, alpha0, verbosity, outs, paras, var_f0, var_df0): # probLineSearch.m -- A probabilistic line search algorithm for nonlinear # optimization problems with noisy gradie...
22,197
38.92446
151
py
inversegraphics
inversegraphics-master/render.py
#!/usr/bin/env python3.4m import matplotlib # matplotlib.use('Agg') import scene_io_utils import re from blender_utils import * from collision import * import matplotlib.pyplot as plt numpy.random.seed(1) inchToMeter = 0.0254 outputDir = '../data/output/' if not os.path.exists(outputDir): os.makedirs(outputDir) ...
15,462
41.833795
304
py
inversegraphics
inversegraphics-master/diffrender_test.py
test__author__ = 'pol' # from damascene import damascene import matplotlib # matplotlib.use('QT4Agg') import matplotlib.pyplot as plt plt.rcParams['animation.ffmpeg_path'] = '/usr/bin/ffmpeg' import scene_io_utils import mathutils from math import radians import timeit import time import opendr import chumpy as ch im...
134,439
47.586917
485
py
inversegraphics
inversegraphics-master/export_groundtruth.py
import save_exr_images from save_exr_images import exportExrImages import os print ("Reading xml ") outputDir = '../data/output/' imgDir = outputDir + "images/" lines = [line.strip() for line in open(outputDir + 'groundtruth.txt')] if not os.path.exists(imgDir): os.makedirs(imgDir) for instance in lines: ...
678
19.575758
88
py
inversegraphics
inversegraphics-master/diffrender_groundtruth_multi.py
__author__ = 'pol' import matplotlib # matplotlib.use('Qt4Agg') import bpy import scene_io_utils import mathutils from math import radians import timeit import time import opendr import chumpy as ch import geometry import image_processing import pdb import numpy as np import cv2 from blender_utils import * import gene...
106,833
48.232258
1,055
py
inversegraphics
inversegraphics-master/utils.py
import numpy as np import os import skimage import skimage.io import h5py import ipdb import scipy.spatial.distance import image_processing import matplotlib __author__ = 'pol' import recognition_models import pickle def joinExperiments(range1, range2, testSet1,methodsPred1,testOcclusions1,testPrefixBase1,parameterRe...
70,535
44.477756
456
py
inversegraphics
inversegraphics-master/extract.py
import matplotlib # matplotlib.use('Agg') import bpy import numpy import matplotlib.pyplot as plt width = 110 height = 110 scene = bpy.data.scenes[0] scene.render.resolution_x = width #perhaps set resolution in code scene.render.resolution_y = height scene.render.resolution_percentage = 100 bpy.data.objects['Cube...
1,234
24.204082
108
py
inversegraphics
inversegraphics-master/lasagne_visualize.py
from itertools import product from lasagne.layers import get_output import matplotlib.pyplot as plt import numpy as np import theano import theano.tensor as T def plot_loss(net): train_loss = [row['train_loss'] for row in net.train_history_] valid_loss = [row['valid_loss'] for row in net.train_history_] ...
7,737
31.512605
78
py
inversegraphics
inversegraphics-master/light_probes.py
from math import sin, cos, ceil, floor, pi import importlib import bpy import numpy as np import mathutils from contextlib import contextmanager from uuid import uuid4 from bpy.utils import register_module, unregister_module from bpy import props as p import json import ipdb import matplotlib.pyplot as plt # bl_info =...
22,272
33.639191
433
py
inversegraphics
inversegraphics-master/collision.py
__author__ = 'pol' #From http://blender.stackexchange.com/a/9080 import bpy import bmesh from blender_utils import * import blender_utils def bmesh_copy_from_object(obj, objTransf, transform=True, triangulate=True, apply_modifiers=False): assert (obj.type == 'MESH') if apply_modifiers and obj.modifiers: ...
7,497
37.649485
247
py
inversegraphics
inversegraphics-master/blender_utils.py
import bpy import bpy_extras import numpy import numpy as np import mathutils from math import radians import h5py import scipy.io import cv2 import sys import io import os import light_probes import imageio try: import cPickle as pickle except: import pickle import ipdb import re from collision import instancesI...
41,350
35.529152
220
py
inversegraphics
inversegraphics-master/shape_model.py
import numpy as np import pickle import chumpy as ch import ipdb from chumpy import depends_on, Ch import scipy.sparse as sp #%% Helper functions def longToPoints3D(pointsLong): nPointsLong = np.size(pointsLong) return np.reshape(pointsLong, [nPointsLong/3, 3]) def shapeParamsToVerts(shapeParams, teapotModel...
3,538
28.491667
187
py
inversegraphics
inversegraphics-master/opendr_utils.py
__author__ = 'pol' from utils import * import opendr import chumpy as ch import geometry import bpy import mathutils import numpy as np from math import radians from opendr.camera import ProjectPoints from opendr.renderer import TexturedRenderer from opendr.lighting import SphericalHarmonics from opendr.lighting impor...
36,041
42.11244
359
py
inversegraphics
inversegraphics-master/image_processing.py
__author__ = 'pol' from skimage.feature import hog from skimage import data, color, exposure import numpy as np import ipdb import skimage.color from numpy.core.umath_tests import matrix_multiply # def xyz2labCh(xyz, illuminant="D65", observer="2"): # """XYZ to CIE-LAB color space conversion. # Parameters # ...
14,461
35.428212
252
py
inversegraphics
inversegraphics-master/generative_models.py
import cv2 import numpy as np import matplotlib.pyplot as plt import ipdb import scipy import chumpy as ch from chumpy.ch import MatVecMult, Ch, depends_on def scoreImage(img, template, method, methodParams): score = 0 if method == 'chamferModelToData': sqDists = chamferDistanceModelToData(img, templa...
25,302
38.910095
213
py
inversegraphics
inversegraphics-master/var_inf.py
__author__ = 'pol' import ipdb import matplotlib matplotlib.use('Qt4Agg') from math import radians import chumpy as ch import numpy as np import cv2 import matplotlib.pyplot as plt from sklearn import mixture from numpy.random import choice plt.ion() image = cv2.imread('opendr_GT.png') image = np.float64(cv2.cvtColor...
3,755
32.837838
186
py
inversegraphics
inversegraphics-master/geometry.py
import chumpy as ch from chumpy import depends_on, Ch import cv2 import numpy as np import scipy.sparse as sp from chumpy.utils import row, col from opendr.geometry import Rodrigues class RotateZ(Ch): dterms = 'a' def compute_r(self): return np.array([[np.cos(self.a.r), -np.sin(self.a.r), 0, 0], [np...
3,023
30.831579
171
py
inversegraphics
inversegraphics-master/diffrender_analyze.py
__author__ = 'pol' import matplotlib matplotlib.use('Qt4Agg') import scene_io_utils from math import radians import timeit import time import opendr import chumpy as ch import geometry import image_processing import numpy as np import cv2 import generative_models import recognition_models import matplotlib.pyplot as p...
58,258
45.127474
466
py
inversegraphics
inversegraphics-master/export_collisions.py
#!/usr/bin/env python3.4m import scene_io_utils import re from blender_utils import * from collision import * numpy.random.seed(1) inchToMeter = 0.0254 outputDir = 'data/' width = 150 height = 150 numSamples = 100 useCycles = False distance = 0.75 scene_io_utils.loadTargetsBlendData() sceneCollisions = {} repla...
5,875
37.657895
191
py
inversegraphics
inversegraphics-master/scene_io_utils.py
from blender_utils import * from sklearn.preprocessing import normalize from collections import OrderedDict def loadTeapotsOpenDRData(renderTeapotsList, useBlender, unpackModelsFromBlender, targetModels): v_teapots = [] f_list_teapots = [] vc_teapots = [] vn_teapots = [] uv_teapots = [] haveTe...
29,860
39.905479
343
py
inversegraphics
inversegraphics-master/torch_nn.py
import ipdb import PyTorchAug import PyTorch nn = PyTorch.Nn() lua = PyTorchAug.lua lua.getGlobal("require") lua.pushString('modules/LinearCR') lua.call(1, 0) lua = PyTorchAug.lua lua.getGlobal("require") lua.pushString('modules/Reparametrize') lua.call(1, 0) lua = PyTorchAug.lua lua.getGlobal("require") lua.pushStr...
2,724
25.980198
102
py
inversegraphics
inversegraphics-master/diffrender_experiment.py
__author__ = 'pol' import matplotlib matplotlib.use('Qt4Agg') from math import radians import timeit import time import numpy as np from utils import * import matplotlib.pyplot as plt plt.ion() import h5py import ipdb import pickle ######################################### # Initialization ends here #################...
3,854
26.733813
106
py
inversegraphics
inversegraphics-master/diffrender_train.py
__author__ = 'pol' import matplotlib matplotlib.use('Qt4Agg') from math import radians import timeit import time import image_processing import numpy as np import cv2 from utils import * import generative_models import matplotlib.pyplot as plt plt.ion() import recognition_models import skimage import h5py import ipdb ...
28,634
44.524642
730
py
inversegraphics
inversegraphics-master/zernike.py
""" @file py102-example2-zernike.py @brief Fitting a surface in Python example for Python 102 lecture @author Tim van Werkhoven (t.i.m.vanwerkhoven@gmail.com) @url http://python101.vanwerkhoven.org @date 20111012 Created by Tim van Werkhoven (t.i.m.vanwerkhoven@xs4all.nl) on 2011-10-12 Copyright (c) 2011 Tim van Werkho...
1,649
27.448276
103
py
inversegraphics
inversegraphics-master/save_exr_images.py
#!/usr/bin/python import OpenEXR import Imath from PIL import Image import sys import numpy as np def exportExrImages(annotationdir, imgdir, numTeapot, frame, sceneNum, target, prefix): framestr = '{0:04d}'.format(frame) outfilename = "render" + prefix + "_obj" + str(numTeapot) + "_scene" + str(sceneNum) + ...
3,659
40.590909
154
py
inversegraphics
inversegraphics-master/diffrender_demo.py
__author__ = 'pol' import matplotlib matplotlib.use('Qt4Agg') import bpy import scene_io_utils import mathutils from math import radians import timeit import time import opendr import chumpy as ch import geometry import image_processing import numpy as np import cv2 from blender_utils import * import glfw import gener...
84,241
42.002552
357
py
sa-nmt
sa-nmt-master/Loss.py
""" This file handles the details of the loss function during training. This includes: loss criterion, training statistics, and memory optimizations. """ from __future__ import division import time import sys import math import torch import torch.nn as nn def nmt_criterion(vocab_size, pad_id=0): """ Construc...
4,092
27.227586
77
py
sa-nmt
sa-nmt-master/Iterator.py
import numpy import random import pickle as pkl import gzip from tempfile import mkstemp import os import string def fopen(filename, mode='r'): if filename.endswith('.gz'): return gzip.open(filename, mode) return open(filename, mode) class TextIterator: """Simple Bitext iterator.""" def __in...
5,911
29.474227
75
py
sa-nmt
sa-nmt-master/opts.py
import argparse def model_opts(parser): """ These options are passed to the construction of the model. Be careful with these as they will be used during translation. """ # Model options # Embedding Options parser.add_argument('-word_vec_size', type=int, default=512, ...
8,871
44.968912
84
py
sa-nmt
sa-nmt-master/translate.py
import argparse import torch import modelx as models import infer import string # build args parser parser = argparse.ArgumentParser(description='Training NMT') parser.add_argument('-checkpoint', required=True, help='saved checkpoit.') parser.add_argument('-input', required=True, ...
1,416
28.520833
71
py
sa-nmt
sa-nmt-master/Utils.py
def aeq(*args): """ Assert all arguments have the same value """ arguments = (arg for arg in args) first = next(arguments) assert all(arg == first for arg in arguments), \ "Not all arguments have the same value: " + str(args) def use_gpu(opt): return (hasattr(opt, 'gpuid') and len(...
388
26.785714
62
py
sa-nmt
sa-nmt-master/extract_tree.py
import argparse import torch from torch.autograd import Variable import modelx as models import networkx as nx from networkx.algorithms.tree import maximum_spanning_arborescence import string # build args parser parser = argparse.ArgumentParser(description='Training NMT') parser.add_argument('-checkpoint', required=T...
4,276
26.242038
70
py
sa-nmt
sa-nmt-master/models.py
import torch import torch.nn as nn from torch.autograd import Variable from attention import GlobalAttention, SelfAttention from Utils import aeq from torch.nn.utils.rnn import pack_padded_sequence as pack from torch.nn.utils.rnn import pad_packed_sequence as unpack import math class EncoderBase(nn.Module): """ ...
15,669
36.488038
79
py
sa-nmt
sa-nmt-master/infer.py
import torch from torch.autograd import Variable import pickle as pkl import math # TODO: documentation of functions class Beam(object): r"""Beam search class for NMT. This is a simple beam search object. It takes model, which can be used to compute the next probable output and dictionaries that will be u...
4,938
35.316176
78
py
sa-nmt
sa-nmt-master/attention.py
import torch import torch.nn as nn from Utils import aeq import math import torch.nn.functional as F class SelfAttention(nn.Module): """Self attention class""" def __init__(self, dim): super(SelfAttention, self).__init__() self.q = nn.Linear(dim, dim, bias=False) self.k = nn.Linear(dim...
6,737
35.032086
78
py
sa-nmt
sa-nmt-master/train.py
import argparse import torch from Iterator import TextIterator import models from itertools import zip_longest import random import Loss import opts import os import math import subprocess from infer import Beam import re from torch.optim.lr_scheduler import ReduceLROnPlateau parser = argparse.ArgumentParser(descripti...
8,797
36.598291
77
py
sa-nmt
sa-nmt-master/data/filter.py
import os import sys import random from tempfile import mkstemp from subprocess import call def main(files): tf_os, tpath = mkstemp() tf = open(tpath, 'w') fds = [open(ff) for ff in files] for l in fds[0]: lines = [l.strip()] + [ff.readline().strip() for ff in fds[1:]] lengths = [...
933
18.458333
71
py
sa-nmt
sa-nmt-master/data/shuffle.py
from __future__ import print_function import os import sys import random from tempfile import mkstemp from subprocess import call def main(files): tf_os, tpath = mkstemp() tf = open(tpath, 'w') fds = [open(ff) for ff in files] for l in fds[0]: lines = [l.strip()] + [ff.readline().strip()...
982
17.903846
71
py
sa-nmt
sa-nmt-master/data/shuffle.bak.py
from __future__ import print_function import os import sys import random from tempfile import mkstemp from subprocess import call def main(files): tf_os, tpath = mkstemp() tf = open(tpath, 'w') fds = [open(ff) for ff in files] for l in fds[0]: lines = [l.strip()] + [ff.readline().strip()...
800
16.042553
71
py
sa-nmt
sa-nmt-master/data/scan_example.py
from __future__ import print_function import numpy import theano from theano import tensor # some numbers n_steps = 10 n_samples = 5 dim = 10 input_dim = 20 output_dim = 2 # one step function that will be used by scan def oneStep(x_t, h_tm1, W_x, W_h, W_o): h_t = tensor.tanh(tensor.dot(x_t, W_x) + ...
1,709
23.782609
60
py
sa-nmt
sa-nmt-master/data/strip_sgml.py
from __future__ import print_function import sys import re def main(): fin = sys.stdin fout = sys.stdout for l in fin: line = l.strip() text = re.sub('<[^<]+>', "", line).strip() if len(text) == 0: continue print(text, file=fout) if __name__ =...
346
15.52381
50
py
sa-nmt
sa-nmt-master/data/build_dictionary.py
from __future__ import print_function import numpy import pickle as pkl import sys from collections import OrderedDict def main(): for filename in sys.argv[1:]: print('Processing', filename) word_freqs = OrderedDict() with open(filename, 'r') as f: for line in f: ...
1,087
24.904762
61
py
sa-nmt
sa-nmt-master/data/extract_files.py
#!/usr/bin/python import argparse import logging import os import tarfile TRAIN_DATA_URL = 'http://www.statmt.org/europarl/v7/fr-en.tgz' VALID_DATA_URL = 'http://matrix.statmt.org/test_sets/newstest2011.tgz' parser = argparse.ArgumentParser( description=""" This script donwloads parallel corpora given source and...
2,999
36.974684
76
py
sa-nmt
sa-nmt-master/data/length.py
from __future__ import print_function import numpy import sys for name in sys.argv[1:]: lens = [] with open(name, 'r') as f: for ll in f: lens.append(len(ll.strip().split(' '))) print(name, ' max ', numpy.max(lens), ' min ', numpy.min(lens), ' average ', numpy.mean(lens))
310
19.733333
98
py
qsft
qsft-master/synt_exp/run-tests-complexity-vs-size.py
import numpy as np import sys import pandas as pd import uuid pd.set_option('display.max_rows', 500) pd.set_option('display.max_columns', 504) pd.set_option('display.width', 1000) sys.path.append("..") sys.path.append("../src") import argparse from pathlib import Path from synt_src.synthetic_helper import SyntheticH...
3,745
31.017094
109
py
qsft
qsft-master/synt_exp/plot-complexity-vs-size.py
import numpy as np import matplotlib.pyplot as plt import sys import pandas as pd from matplotlib import ticker import matplotlib from mpl_toolkits.axes_grid1 import make_axes_locatable pd.set_option('display.max_rows', 500) pd.set_option('display.max_columns', 504) pd.set_option('display.width', 1000) sys.path.appen...
5,591
36.033113
101
py
qsft
qsft-master/synt_exp/run-tests-nmse-vs-snr.py
import numpy as np import sys import pandas as pd import uuid pd.set_option('display.max_rows', 500) pd.set_option('display.max_columns', 504) pd.set_option('display.width', 1000) sys.path.append("..") import argparse from pathlib import Path from synt_exp.synt_src.synthetic_helper import SyntheticHelper from qsft.para...
3,712
32.45045
109
py
qsft
qsft-master/synt_exp/qsft-sample-vs-nmse.py
#!/usr/bin/env python # coding: utf-8 # In[1]: import numpy as np import matplotlib.pyplot as plt import sys import pandas as pd import uuid sys.path.append("..") sys.path.append("../src") from qsft.utils import best_convex_underestimator import argparse from pathlib import Path from synt_exp.synt_src.synthetic_he...
4,482
30.131944
104
py
qsft
qsft-master/synt_exp/plot-nmse-vs-snr.py
import numpy as np import matplotlib.pyplot as plt import sys import pandas as pd pd.set_option('display.max_rows', 500) pd.set_option('display.max_columns', 504) pd.set_option('display.width', 1000) sys.path.append("..") sys.path.append("../src") from pathlib import Path if __name__ == '__main__': exp_dir = P...
1,435
27.156863
95
py
qsft
qsft-master/synt_exp/quick_example.py
import numpy as np from qsft.qsft import QSFT from qsft.query import get_reed_solomon_dec from synt_exp.synt_src.synthetic_signal import get_random_subsampled_signal if __name__ == '__main__': np.random.seed(20) q = 3 n = 40 N = q ** n sparsity = 100 a_min = 1 a_max = 1 b = 4 noise_...
2,810
32.86747
118
py
qsft
qsft-master/synt_exp/__init__.py
0
0
0
py
qsft
qsft-master/synt_exp/synt_src/synthetic_signal.py
import numpy as np from qsft.utils import igwht_tensored, random_signal_strength_model, qary_vec_to_dec, sort_qary_vecs from qsft.input_signal import Signal from qsft.input_signal_subsampled import SubsampledSignal from qsft.utils import dec_to_qary_vec from multiprocess import Pool import time def generate_signal_w(...
5,257
39.137405
124
py
qsft
qsft-master/synt_exp/synt_src/synthetic_helper.py
from qsft.test_helper import TestHelper from synt_exp.synt_src.synthetic_signal import SyntheticSubsampledSignal class SyntheticHelper(TestHelper): def generate_signal(self, signal_args): return SyntheticSubsampledSignal(**signal_args)
249
34.714286
72
py
qsft
qsft-master/rna_exp/run-tests-complexity-vs-size.py
import numpy as np import pandas as pd import uuid import argparse from pathlib import Path from rna_exp.rna_src.rna_helper import RNAHelper from qsft.parallel_tests import run_tests pd.set_option('display.max_rows', 500) pd.set_option('display.max_columns', 504) pd.set_option('display.width', 1000) if __name__ == '...
3,056
29.57
103
py
qsft
qsft-master/rna_exp/plot-complexity-vs-size.py
import numpy as np import matplotlib.pyplot as plt import sys import pandas as pd from scipy import interpolate pd.set_option('display.max_rows', 500) pd.set_option('display.max_columns', 504) pd.set_option('display.width', 1000) sys.path.append("..") sys.path.append("../src") from pathlib import Path from qsft.util...
2,831
30.120879
92
py
qsft
qsft-master/rna_exp/qspright-sample-vs-nmse.py
#!/usr/bin/env python # coding: utf-8 # In[1]: import numpy as np import matplotlib.pyplot as plt import sys sys.path.append("..") sys.path.append("../src") import pandas as pd import uuid from rna_exp.rna_src.rna_helper import RNAHelper from qsft.utils import best_convex_underestimator from qsft.parallel_tests impo...
4,317
30.289855
104
py
qsft
qsft-master/rna_exp/__init__.py
0
0
0
py
qsft
qsft-master/rna_exp/rna_src/query_iterator.py
import numpy as np from qsft.utils import dec_to_qary_vec class QueryIterator(object): nucs = np.array(["A", "U", "C", "G"]) q = 4 def __init__(self, base_seq, positions, query_indices, q): self.base_seq = np.array(list(base_seq)) self.positions = positions self.full = self.base_se...
1,466
28.34
66
py
qsft
qsft-master/rna_exp/rna_src/utils.py
import numpy as np from tqdm import tqdm from itertools import chain, combinations def divisors(num): """Returns all divisors of a given integer""" divs = [] for x in range (1, num): if (num % x) == 0: divs.append(x) return divs def powerset(iterable): """Returns the powerset...
6,463
30.842365
92
py
qsft
qsft-master/rna_exp/rna_src/data_utils.py
import pandas as pd import numpy as np import itertools from Bio import PDB from tqdm import tqdm from sklearn.linear_model import Lasso from rna_exp.rna_src import utils from rna_exp.rna_src import gnk_model from rna_exp.rna_src import structure_utils """ Utility functions for loading and processing empirical fitness...
12,224
34.537791
134
py
qsft
qsft-master/rna_exp/rna_src/rna_helper.py
import numpy as np import json from qsft.test_helper import TestHelper from qsft.utils import NpEncoder from rna_exp.rna_src.input_rna_signal_subsampled import RnaSubsampledSignal from rna_exp.rna_src.rna_utils import get_rna_base_seq class RNAHelper(TestHelper): mfe_base = 0 base_seq_list = None position...
1,466
36.615385
118
py
qsft
qsft-master/rna_exp/rna_src/rna_utils.py
import RNA import itertools import utils import linecache import tracemalloc """ Utility functions for loading and processing the quasi-empirical RNA fitness function. """ def dna_to_rna(seq): """ Converts DNA sequences to RNA sequences. """ rs = [] for s in seq: if s == 'T': ...
4,803
27.093567
122
py
qsft
qsft-master/rna_exp/rna_src/__init__.py
0
0
0
py
qsft
qsft-master/rna_exp/rna_src/input_rna_signal_subsampled.py
from qsft.input_signal_subsampled import SubsampledSignal import numpy as np from multiprocessing import Pool from qsft.utils import dec_to_qary_vec, qary_vec_to_dec import RNA class RnaSubsampledSignal(SubsampledSignal): nucs = np.array(["A", "U", "C", "G"]) def __init__(self, **kwargs): self.base_s...
2,382
28.060976
106
py
qsft
qsft-master/rna_exp/rna_src/structure_utils.py
import numpy as np from Bio import PDB """ Various utility functions for working with PDB structures. """ def binarize_contact_map(contact_map, threshold=8.0): """Returns binary version of contact map.""" return np.less(contact_map, threshold) def calc_min_dist(res1, res2): """Returns the minimum dist...
2,281
28.636364
84
py
qsft
qsft-master/rna_exp/rna_src/gnk_model.py
import numpy as np import itertools from scipy.special import binom from math import factorial from rna_exp.rna_src import utils def get_neighborhood_powerset(V): """Returns the union of powersets of a set of neighborhoods""" Vs = [sorted(Vk) for Vk in V] powersets = [tuple(utils.powerset(Vs[i])) for i in...
4,787
28.018182
91
py
qsft
qsft-master/rna_exp/rna_src/input_rna_signal.py
from qsft.input_signal import Signal import numpy as np import itertools from rna_exp.rna_src.rna_utils import insert from multiprocessing import Pool from tqdm import tqdm from functools import partial tqdm = partial(tqdm, position=0, leave=True) class RnaSignal(Signal): def __init__(self, **kwargs): sel...
1,107
31.588235
85
py
qsft
qsft-master/qsft/spright.py
''' SPRIGHT decoding main file. Logic flow: 1. Generate a signal from src/input_signal.py 2. Subsample from src/query.py 3. Peel using src/reconstruct.py ''' import numpy as np import galois import sys import tqdm import time sys.path.append("../src") from archive.qsft_rand import dec_to_bin, bin_to_dec, qary_vec_to...
12,417
42.118056
123
py
qsft
qsft-master/qsft/input_signal_subsampled.py
from qsft.utils import qary_ints, qary_vec_to_dec, gwht, load_data, save_data from qsft.input_signal import Signal from qsft.query import get_Ms_and_Ds from pathlib import Path from math import floor from tqdm import tqdm import numpy as np import random import time class SubsampledSignal(Signal): """ A shell...
11,744
42.5
122
py
qsft
qsft-master/qsft/qsft.py
''' Class for computing the q-ary fourier transform of a function/signal ''' import time import numpy as np from qsft.reconstruct import singleton_detection from qsft.input_signal_subsampled import SubsampledSignal from qsft.utils import bin_to_dec, qary_vec_to_dec, sort_qary_vecs, calc_hamming_weight, dec_to_qary_vec ...
12,144
42.067376
122
py
qsft
qsft-master/qsft/ReedSolomon.py
import galois from galois._codes._reed_solomon import decode_jit import numpy as np import math class ReedSolomon(galois.ReedSolomon): """ Class that extends galois.ReedSolomon. Mainly it is needed to implement syndrome decoding. Attributes --------- prime_field : GF.field The galois feild of...
2,356
30.426667
120
py
qsft
qsft-master/qsft/lasso.py
import numpy as np from group_lasso import GroupLasso from sklearn.linear_model import Ridge import time from group_lasso._fista import ConvergenceWarning from sklearn.utils._testing import ignore_warnings from qsft.utils import calc_hamming_weight, dec_to_qary_vec, qary_ints @ignore_warnings(category=ConvergenceWarn...
3,870
28.549618
129
py
qsft
qsft-master/qsft/utils.py
''' Utility functions. ''' import numpy as np import scipy.fft as fft from group_lasso import GroupLasso from sklearn.linear_model import Ridge import itertools import math import random import time from scipy.spatial import ConvexHull import zlib import pickle import json import matplotlib.pyplot as plt def fwht(x): ...
6,283
29.357488
116
py
qsft
qsft-master/qsft/test_helper.py
import numpy as np from qsft.lasso import lasso_decode from qsft.qsft import QSFT from qsft.utils import gwht, dec_to_qary_vec, NpEncoder import json from qsft.query import get_reed_solomon_dec class TestHelper: def __init__(self, signal_args, methods, subsampling_args, test_args, exp_dir, subsampling=True): ...
12,024
40.608997
123
py
qsft
qsft-master/qsft/parallel_tests.py
import itertools from multiprocessing import Pool from tqdm import tqdm from functools import partial import numpy as np import pandas as pd from qsft.test_helper import TestHelper tqdm = partial(tqdm, position=0, leave=True) def _test(i): """ Runs a single instance of a test Parameters ---------- ...
3,555
29.921739
138
py
qsft
qsft-master/qsft/__init__.py
0
0
0
py
qsft
qsft-master/qsft/query.py
''' Methods for the query generator: specifically, to 1. generate sparsity coefficients b and subsampling matrices M 2. get the indices of a signal subsample 3. compute a subsampled and delayed Walsh-Hadamard transform. ''' import time import numpy as np from qsft.utils import fwht, gwht, bin_to_dec, binary_ints, qary...
7,267
28.786885
122
py
qsft
qsft-master/qsft/reconstruct.py
''' Methods for the reconstruction engine; specifically, to: 1. carry out singleton detection 2. get the cardinalities of all bins in a subsampling group (debugging only). ''' import numpy as np from qsft.utils import angle_q def singleton_detection_noiseless(U_slice, **kwargs): ''' Finds the true index of ...
5,932
34.315476
131
py
qsft
qsft-master/qsft/input_signal.py
""" A shell Class for common interface to an input signal. This class should be extended when implemented """ import numpy as np from qsft.utils import gwht_tensored, igwht_tensored, save_data, load_data from pathlib import Path class Signal: """ Class to encapsulate a time domain signal and its q-ary Fourier...
3,034
30.28866
118
py
sort
sort-master/sort.py
""" SORT: A Simple, Online and Realtime Tracker Copyright (C) 2016-2020 Alex Bewley alex@bewley.ai 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, either version 3 of the License,...
11,739
34.468278
242
py
cogcn
cogcn-main/cogcn/utils.py
import pickle as pkl import os import networkx as nx import numpy as np import scipy.sparse as sp import torch import pandas as pd from sklearn.metrics import roc_auc_score, average_precision_score from matplotlib import pyplot as plt def load_data_cma(dataset): adj_file = os.path.join(dataset, "struct.csv") f...
2,240
29.69863
95
py
cogcn
cogcn-main/cogcn/model.py
import torch import torch.nn as nn import torch.nn.functional as F from layers import GraphConvolution class GCNAE(nn.Module): def __init__(self, input_feat_dim, hidden_dim1, hidden_dim2, dropout): super(GCNAE, self).__init__() self.encgc1 = GraphConvolution(input_feat_dim, hidden_dim1, dropout, a...
1,415
31.930233
93
py
cogcn
cogcn-main/cogcn/kmeans.py
import sys import torch import torch.nn as nn from sklearn.cluster import KMeans class Clustering(object): def __init__(self, K, n_init=5, max_iter=250): self.K = K self.n_init = n_init self.max_iter = max_iter self.u = None self.M = None def cluster(self, embed): ...
1,646
28.410714
109
py
cogcn
cogcn-main/cogcn/layers.py
import torch import torch.nn.functional as F from torch.nn.modules.module import Module from torch.nn.parameter import Parameter class GraphConvolution(Module): """ Simple GCN layer, similar to https://arxiv.org/abs/1609.02907 """ def __init__(self, in_features, out_features, dropout=0., act=F.relu):...
1,110
30.742857
77
py
cogcn
cogcn-main/cogcn/train.py
from __future__ import division from __future__ import print_function import argparse import time import sys import os import pickle import numpy as np import scipy.sparse as sp import torch import torch.nn as nn from torch import optim from matplotlib import pyplot as plt from model import GCNAE from optimizer impor...
5,980
39.412162
157
py
cogcn
cogcn-main/cogcn/optimizer.py
import sys import torch import torch.nn as nn import torch.nn.modules.loss import torch.nn.functional as F from sklearn.cluster import KMeans def compute_attribute_loss(lossfn, features, recon, outlier_wt): loss = lossfn(features, recon) loss = loss.sum(dim=1) outlier_wt = torch.log(1/outlier_wt) at...
1,768
23.915493
64
py
deepglo
deepglo-master/DeepGLO/DeepGLO.py
from __future__ import print_function import torch, h5py import numpy as np from scipy.io import loadmat from torch.nn.utils import weight_norm import torch.nn as nn import torch.optim as optim import numpy as np # import matplotlib from torch.autograd import Variable import sys import itertools import torch.nn.func...
25,258
32.235526
131
py
deepglo
deepglo-master/DeepGLO/data_loader.py
import torch, h5py import numpy as np from scipy.io import loadmat import torch.nn as nn import torch.optim as optim import numpy as np # import matplotlib from torch.autograd import Variable import itertools from sklearn.preprocessing import normalize import datetime import json import os, sys import pandas as pd im...
6,610
34.735135
167
py
deepglo
deepglo-master/DeepGLO/Ftree.py
import numpy as np import pandas as pd class FplusTreeSampling(object): """ F+ tree for sampling from a large population Construct in O(N) time Sample and update in O(log(N)) time """ def __init__(self, dimension, weights=None): self.dimension = dimension self.layers = int(np....
3,508
29.513043
82
py
deepglo
deepglo-master/DeepGLO/utilities.py
import pandas as pd import numpy as np import datetime def last_days(num=60, date=datetime.datetime(2018, 6, 20)): y = [str(date.year) + "%02d" % date.month + "%02d" % date.day] for i in range(1, num): d = date - datetime.timedelta(days=i) y = y + [str(d.year) + "%02d" % d.month + "%02d" % d.d...
680
29.954545
85
py
deepglo
deepglo-master/DeepGLO/time.py
import pandas as pd import numpy as np class TimeCovariates(object): def __init__(self, start_date, num_ts=100, freq="H", normalized=True): self.start_date = start_date self.num_ts = num_ts self.freq = freq self.normalized = normalized self.dti = pd.date_range(self.start_da...
2,134
30.865672
86
py
deepglo
deepglo-master/DeepGLO/metrics.py
import numpy as np def smape(P, A): nz = np.where(A > 0) Pz = P[nz] Az = A[nz] return np.mean(2 * np.abs(Az - Pz) / (np.abs(Az) + np.abs(Pz))) def mape(P, A): nz = np.where(A > 0) Pz = P[nz] Az = A[nz] return np.mean(np.abs(Az - Pz) / np.abs(Az)) def wape(P, A): return np.mea...
898
18.543478
87
py
deepglo
deepglo-master/DeepGLO/__init__.py
# Implement your code here.
28
13.5
27
py
deepglo
deepglo-master/DeepGLO/LocalModel.py
import torch, h5py import numpy as np from scipy.io import loadmat from torch.nn.utils import weight_norm import torch.nn as nn import torch.optim as optim import numpy as np # import matplotlib from torch.autograd import Variable import itertools import torch.nn.functional as F from DeepGLO.data_loader import * ...
21,683
31.804841
157
py
deepglo
deepglo-master/run_scripts/run_traffic.py
#### OS and commanline arguments import sys import multiprocessing as mp import gzip import subprocess from pathlib import Path import argparse import logging import os sys.path.append('./') #### DeepGLO model imports from DeepGLO.metrics import * from DeepGLO.DeepGLO import * from DeepGLO.LocalModel import * impor...
3,498
24.727941
87
py
deepglo
deepglo-master/run_scripts/run_wiki.py
#### OS and commanline arguments import sys import multiprocessing as mp import gzip import subprocess from pathlib import Path import argparse import logging import os sys.path.append('./') #### DeepGLO model imports from DeepGLO.metrics import * from DeepGLO.DeepGLO import * from DeepGLO.LocalModel import * import ...
3,475
24.940299
87
py