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 |
|---|---|---|---|---|---|---|
hypercontractivity | hypercontractivity-master/HC_estimator.py | #Copyright Weihao Gao, UIUC
from math import log,pi,exp,sqrt
import numpy.random as nr
import numpy as np
import numpy.linalg as la
import matplotlib.pyplot as plt
#Main Usage Function
def HC(x, y, bandwidth=1.06, n_trial = 10, n_iter=100, sigma = 0.1, eta = 0.1):
'''
Estimating Hypercontractivity s(X;Y) from sam... | 2,959 | 27.190476 | 109 | py |
hypercontractivity | hypercontractivity-master/demo.py | import numpy.random as nr
import HC_estimator as hce
def main():
sample_size = 100
x_g = nr.uniform(0,1,[sample_size,1])
y_g = nr.uniform(0,1,[sample_size,1])
print('*'*100)
print('bandwidth = 0.53')
print('uncorrelated HC:', hce.HC(x_g,y_g,0.53))
print('correlated HC', hce.HC(x_g,x_g,0.53))
print('*'*100)
pr... | 476 | 24.105263 | 48 | py |
deep_bingham | deep_bingham-master/generate_lookup_table.py | """
Generates the lookup table for the Binghasm normalization constant.
"""
from __future__ import print_function
import numpy as np
import time
import utils
def generate_bd_lookup_table():
coords = np.linspace(-500, 0, 40)
duration = time.time()
utils.build_bd_lookup_table(
"uniform", {"coords":... | 586 | 22.48 | 77 | py |
deep_bingham | deep_bingham-master/evaluate.py | import argparse
import os
import torch
import torchvision.transforms as transforms
import yaml
import data_loaders
import modules.network
from modules import angular_loss, BinghamFixedDispersionLoss, \
BinghamHybridLoss, BinghamLoss, BinghamMixtureLoss, \
CosineLoss, MSELoss, VonMisesLoss, VonMisesFixedKappaL... | 4,542 | 30.769231 | 79 | py |
deep_bingham | deep_bingham-master/bingham_distribution.py | """
Bingham Distribution
This module implements the Bingham distribution as it was proposed in:
Christopher Bingham, *"An Antipodally Symmetric Distribution on the Sphere"*,
Annals of Statistics 2(6), 1974
"""
import logging
import scipy.integrate as integrate
import scipy.optimize
import scipy.special
import numpy a... | 29,792 | 36.102117 | 80 | py |
deep_bingham | deep_bingham-master/train.py | """
Deep Orientation Estimation Training
"""
import argparse
import os
import sys
import torch
import torch.optim as optim
import torchvision.transforms as transforms
import yaml
from tensorboardX import SummaryWriter
import data_loaders
import modules.network
from modules import BinghamLoss, BinghamMixtureLoss, \
... | 6,909 | 32.543689 | 105 | py |
deep_bingham | deep_bingham-master/modules/maad.py | import torch
from modules.gram_schmidt import gram_schmidt, gram_schmidt_batched
from modules.quaternion_matrix import quaternion_matrix
from utils.utils import \
convert_euler_to_quaternion
from modules.vm_operations import *
import math
def angular_loss_single_sample(target, predicted):
""" Returns the angle... | 4,931 | 37.834646 | 80 | py |
deep_bingham | deep_bingham-master/modules/vm_operations.py | import torch
def output_to_kappas(output):
zero_vec = torch.zeros(len(output), 3)
if output.is_cuda:
device = output.get_device()
zero_vec = torch.zeros(len(output), 3).to(device)
kappas = torch.where(output[:, :3] > 0, output[:, :3], zero_vec)
return kappas
def output_to_angles(outpu... | 1,093 | 27.051282 | 75 | py |
deep_bingham | deep_bingham-master/modules/bingham_mixture_loss.py | """Implementation of the Bingham Mixture Loss"""
import torch
from .maad import angular_loss_single_sample
from .bingham_fixed_dispersion import BinghamFixedDispersionLoss
from .bingham_loss import BinghamLoss
from .gram_schmidt import gram_schmidt_batched
from utils import vec_to_bingham_z_many
class BinghamMixture... | 5,574 | 41.234848 | 83 | py |
deep_bingham | deep_bingham-master/modules/bingham_fixed_dispersion.py | import torch
from modules.gram_schmidt import gram_schmidt_batched
from modules.bingham_loss import batched_logprob
from modules.quaternion_matrix import quaternion_matrix
class BinghamFixedDispersionLoss(object):
"""
Class for calculating bingham loss assuming a fixed Z.
Parameters:
bd_z (list)... | 4,440 | 36.008333 | 80 | py |
deep_bingham | deep_bingham-master/modules/network.py | import torch.nn as nn
from torchvision import models
def get_model(name, pretrained, num_channels, num_classes):
"""
Method that returns a torchvision model given a model
name, pretrained (or not), number of channels,
and number of outputs
Inputs:
name - string corresponding to model name... | 1,587 | 32.083333 | 80 | py |
deep_bingham | deep_bingham-master/modules/von_mises.py | """Implementation of von Mises loss function
Code based on:
https://github.com/sergeyprokudin/deep_direct_stat/blob/master/utils/losses.py
"""
import numpy as np
import torch
import math
import sys
from scipy.interpolate import Rbf
import utils
from utils import generate_coordinates
from modules.maad import maad_bite... | 5,116 | 33.574324 | 79 | py |
deep_bingham | deep_bingham-master/modules/gram_schmidt.py | import torch
def gram_schmidt(input_mat, reverse=False, modified=False):
""" Carries out the Gram-Schmidt orthogonalization of a matrix.
Arguments:
input_mat (torch.Tensor): A quadratic matrix that will be turned into an
orthogonal matrix.
reverse (bool): Starts gram Schmidt metho... | 3,837 | 35.207547 | 80 | py |
deep_bingham | deep_bingham-master/modules/mse.py | import torch
import torch.nn as nn
from modules.maad import maad_mse
class MSELoss(object):
"""
Class for the MSE loss function
"""
def __init__(self):
self.loss = nn.MSELoss(reduction='sum')
def __call__(self, target, output):
"""
Calculates the MSE loss on a batch of targe... | 1,325 | 32.15 | 95 | py |
deep_bingham | deep_bingham-master/modules/bingham_loss.py | """Implementation of the Bingham loss function"""
from __future__ import print_function
import dill
import os
import bingham_distribution as ms
import numpy as np
import torch
from scipy.interpolate import Rbf
import utils
from modules.maad import maad_bingham
from modules.gram_schmidt import gram_schmidt, gram_sch... | 11,124 | 34.205696 | 94 | py |
deep_bingham | deep_bingham-master/modules/cosine.py | from modules.maad import output_to_angles, maad_cosine
from utils import radians
import torch
class CosineLoss():
"""
Class for calculating Cosine Loss assuming biternion representation of pose.
"""
def __init__(self):
self.stats = 0
def __call__(self, target, output):
"""
... | 2,160 | 33.301587 | 86 | py |
deep_bingham | deep_bingham-master/modules/__init__.py | from .maad import maad_biternion, maad_bingham, maad_mse
from .bingham_loss import BinghamLoss
from .bingham_mixture_loss import BinghamMixtureLoss
from .mse import MSELoss
from .von_mises import VonMisesLoss
from .cosine import CosineLoss
| 241 | 33.571429 | 57 | py |
deep_bingham | deep_bingham-master/modules/quaternion_matrix.py | import torch
def quaternion_matrix(quat):
""" Computes an orthogonal matrix from a quaternion.
We use the representation from the NeurIPS 2018 paper "Bayesian Pose
Graph Optimization via Bingham Distributions and Tempred Geodesic MCMC" by
Birdal et al. There, the presentation is given above eq. (6). ... | 1,042 | 27.189189 | 78 | py |
deep_bingham | deep_bingham-master/training/__init__.py | from .trainer import Trainer | 28 | 28 | 28 | py |
deep_bingham | deep_bingham-master/training/trainer.py | import time
import torch
from modules import maad
from utils import AverageMeter
class Trainer(object):
""" Trainer for Bingham Orientation Uncertainty estimation.
Arguments:
device (torch.device): The device on which the training will happen.
"""
def __init__(self, device, floating_point_t... | 8,449 | 39.430622 | 83 | py |
deep_bingham | deep_bingham-master/utils/visualization.py | import manstats as ms
import numpy as np
import quaternion
import matplotlib.pylab as plab
import matplotlib.pyplot as plt
from matplotlib.colors import ListedColormap
from mpl_toolkits.mplot3d import Axes3D
def plot_pose_bingham(bd_param_m, bd_param_z):
"""
Plots an uncertain orientation given as a 4d bingh... | 3,863 | 31.745763 | 79 | py |
deep_bingham | deep_bingham-master/utils/utils.py | """ Utilities for learning pipeline."""
from __future__ import print_function
import copy
import dill
import hashlib
import itertools
import bingham_distribution as ms
import math
import numpy as np
import os
import scipy
import scipy.integrate as integrate
import scipy.special
import sys
import torch
from pathos.mult... | 15,063 | 33.629885 | 83 | py |
deep_bingham | deep_bingham-master/utils/__init__.py | from .utils import *
| 21 | 10 | 20 | py |
deep_bingham | deep_bingham-master/utils/evaluation.py | import torch
from modules import maad
from utils import AverageMeter, eaad_bingham, eaad_von_mises
import numpy as np
def run_evaluation(model, dataset, loss_function, device, floating_point_type="float"):
model.eval()
losses = AverageMeter()
log_likelihoods = AverageMeter()
maads = AverageMeter()
... | 4,120 | 40.21 | 105 | py |
deep_bingham | deep_bingham-master/data_loaders/t_less_dataset.py | from .utils import *
from torch.utils.data import Dataset, random_split, Subset
import yaml
import os
try:
from yaml import CLoader as Loader
except ImportError:
from yaml import Loader
from PIL import Image
import numpy as np
from skimage import io
import torch
import quaternion
import cv2
import h5py
torch.... | 7,101 | 34.688442 | 103 | py |
deep_bingham | deep_bingham-master/data_loaders/utils.py | import math
import numpy as np
import quaternion
def convert_euler_to_quaternion(roll, yaw, pitch):
"""Converts roll, yaw, pitch to a quaternion.
"""
cy = math.cos(math.radians(roll) * 0.5)
sy = math.sin(math.radians(roll) * 0.5)
cp = math.cos(math.radians(yaw) * 0.5)
sp = math.sin(math.radi... | 2,407 | 27 | 92 | py |
deep_bingham | deep_bingham-master/data_loaders/upna_preprocess.py | from __future__ import print_function, division
import os
import pandas as pd
import numpy as np
import yaml
# Ignore warnings
import warnings
import csv
warnings.filterwarnings("ignore")
import cv2
TRAIN_SET = set(
["User_01", "User_02", "User_03", "User_04", "User_05", "User_06"])
TEST_SET = set(["User_07", "Us... | 7,036 | 40.639053 | 79 | py |
deep_bingham | deep_bingham-master/data_loaders/__init__.py | from .idiap_dataset import *
from .upna_dataset import *
from .t_less_dataset import *
| 87 | 21 | 29 | py |
deep_bingham | deep_bingham-master/data_loaders/upna_dataset.py | import os
import torch
from PIL import Image
from skimage import io
from torch.utils.data import Dataset
import h5py
from .upna_preprocess import *
from .utils import *
from bingham_distribution import BinghamDistribution
def make_hdf5_file(config, image_transform):
dataset_path = config["preprocess_path"]
csv... | 9,853 | 36.9 | 102 | py |
deep_bingham | deep_bingham-master/data_loaders/idiap_dataset.py | """
Data loading methods from matlab file from:
https://github.com/lucasb-eyer/BiternionNet
"""
import os
import h5py
import yaml
import torch
from PIL import Image
from skimage import io
from torch.utils.data import Dataset
from .utils import *
from bingham_distribution import BinghamDistribution
class IDIAPTrainTest... | 6,671 | 34.679144 | 95 | py |
WSLVideoDenseAnticipation | WSLVideoDenseAnticipation-main/main.py | import argparse
import time
import os
import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
from torch.utils.data import DataLoader
from sklearn.metrics import accuracy_score
from dataloader import DatasetLoader, collate_fn
from primary_pred_module import primModel
from ancill... | 23,720 | 51.596452 | 228 | py |
WSLVideoDenseAnticipation | WSLVideoDenseAnticipation-main/data_preprocessing.py | import os.path
import pickle
import numpy as np
import torch
def read_mapping_dict(mapping_file):
file_ptr = open(mapping_file, 'r')
actions = file_ptr.read().split('\n')[:-1]
actions_dict = dict()
for a in actions:
actions_dict[a.split()[1]] = int(a.split()[0])
return actions_dict
def get... | 17,121 | 48.060172 | 167 | py |
WSLVideoDenseAnticipation | WSLVideoDenseAnticipation-main/ancillary_pred_module.py | '''
input: a video and its weak label
output: predicted frame-wise action
Ancillary predction model outputs a frame-wise action prediction given a video and first second label.
This model generates an initial prediction for the weak set, which will aid training the primary model.
'''
import torch
import torch.nn as nn... | 4,229 | 51.875 | 174 | py |
WSLVideoDenseAnticipation | WSLVideoDenseAnticipation-main/dataloader.py | import torch
import torch.utils.data as data
from data_preprocessing import DataClass
class DatasetLoader(data.Dataset):
def __init__(self, args, path, mode, half=False):
self.dataset = DataClass(args, path, mode, half)
self.obs = float(args.observation[-3:]) #observation portion
self.pred ... | 4,177 | 48.152941 | 212 | py |
WSLVideoDenseAnticipation | WSLVideoDenseAnticipation-main/self_correction_module.py | '''
input: outputs from ancillary module and primary module of weak set
output: full label of weak set
Self-correction module refines predictions generated by the ancillary model and the current primary model for the weak set.
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class selfcorrModel(n... | 2,235 | 53.536585 | 217 | py |
WSLVideoDenseAnticipation | WSLVideoDenseAnticipation-main/primary_pred_module.py | '''
input: a video
output: predicted frame-wise action
Primary prediction model generates a frame-wise prediction of actions given an video.
This is the main model that is subject to the training and is used at test time.
'''
import torch.nn as nn
from blocks import TABlock
import torch
import torch.nn.functional as F... | 4,186 | 51.3375 | 173 | py |
WSLVideoDenseAnticipation | WSLVideoDenseAnticipation-main/blocks.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class NONLocalBlock(nn.Module):
#Non Local Block
def __init__(self, args, dim_1, dim_2, video_feat_dim):
super(NONLocalBlock, self).__init__()
self.dim_1 = dim_1
self.dim_2 = dim_2
self.video_feat_dim = video_fe... | 7,659 | 41.555556 | 153 | py |
fmm2d | fmm2d-main/src/modified-biharmonic/jinjaroot.yaml.py |
fname="jinjaroot.yaml"
file = open(fname,"w")
file.write("mbhevalRouts:\n")
file.write(" -\n")
file.write(" out: p\n")
file.write(" -\n")
file.write(" out: g\n")
file.write(" -\n")
file.write(" out: h\n\n")
file.write("mbhDirectRouts:\n")
outs=["p","g","h"]
for out in outs:
for i in range(16):
... | 862 | 21.710526 | 72 | py |
fmm2d | fmm2d-main/python/setup.py | import setuptools
import string
import os
from numpy.distutils.core import setup
from numpy.distutils.core import Extension
from sys import platform
pkg_name = "fmm2dpy"
## TODO: this should be automatically populated using "read directory, or whatever"
## TODO: fix problem with relative location for executable
list... | 3,971 | 31.826446 | 167 | py |
fmm2d | fmm2d-main/python/cfmmexample.py | #!/usr/bin/env python
import fmm2dpy as fmm
import numpy as np
#
# This is a sample code to demonstrate how to use
# the fmm libraries
#
# sample with one density, sources to sources,
# charge interactions, and potential only
#
n = 2000000
nd = 1
sources = np.random.uniform(0,1,(2,n))
eps = 10**(-5)
charges = np... | 776 | 21.852941 | 69 | py |
fmm2d | fmm2d-main/python/example1.py | import fmm2d as fmm
import numpy as np
n = 2000
sources = np.random.uniform(0,1,(2,n))
m = 1000
targets = np.random.uniform(0,1,(2,m))
zk = 1.1+ 1j*0
charges = np.random.uniform(0,1,n) + 1j*np.random.uniform(0,1,n)
eps = 10**(-5)
pottarg,ier = fmm.hfmm2d_t_c_p(eps,zk,sources,charges,targets)
print(pottarg[1:3])
| 320 | 15.894737 | 64 | py |
fmm2d | fmm2d-main/python/rfmmexample.py | #!/usr/bin/env python
import fmm2dpy as fmm
import numpy as np
#
# This is a sample code to demonstrate how to use
# the fmm libraries
#
# sample with one density, sources to sources,
# charge interactions, and potential only
#
n = 2000000
nd = 1
sources = np.random.uniform(0,1,(2,n))
eps = 10**(-5)
charges = np... | 774 | 21.142857 | 72 | py |
fmm2d | fmm2d-main/python/lfmmexample.py | #!/usr/bin/env python
import fmm2dpy as fmm
import numpy as np
#
# This is a sample code to demonstrate how to use
# the fmm libraries
#
# sample with one density, sources to sources,
# charge interactions, and potential only
#
n = 2000000
nd = 1
sources = np.random.uniform(0,1,(2,n))
eps = 10**(-5)
charges = np... | 834 | 22.857143 | 72 | py |
fmm2d | fmm2d-main/python/fmm2dpy/fmm2d.py | from . import hfmm2d_fortran as hfmm
from . import lfmm2d_fortran as lfmm
from . import bhfmm2d_fortran as bhfmm
import numpy as np
import numpy.linalg as la
class Output():
pot = None
grad = None
hess = None
pottarg = None
gradtarg = None
hesstarg = None
ier = 0
def hfmm2d(*,eps,zk,sourc... | 83,367 | 45.264151 | 198 | py |
fmm2d | fmm2d-main/python/fmm2dpy/__init__.py | from .fmm2d import hfmm2d,rfmm2d,lfmm2d,cfmm2d,bhfmm2d,h2ddir,r2ddir,l2ddir,c2ddir,bh2ddir,comperr,Output
| 106 | 52.5 | 105 | py |
fmm2d | fmm2d-main/python/test/test_rfmm.py | #!/usr/bin/env python
import fmm2dpy as fmm
import numpy as np
import numpy.linalg as la
def main():
test_rfmm()
def test_rfmm():
ntests = 36
testres = np.zeros(ntests)
#
# This is a testing code for making sure all the
# fmm routines are accessible through fmm2d.py
#
n = 2000
... | 19,099 | 32.333333 | 101 | py |
fmm2d | fmm2d-main/python/test/test_lfmm.py | #!/usr/bin/env python
import fmm2dpy as fmm
import numpy as np
import numpy.linalg as la
def main():
test_lfmm()
def test_lfmm():
ntests = 36
testres = np.zeros(ntests)
#
# This is a testing code for making sure all the
# fmm routines are accessible through fmm2d.py
#
n = 2000
... | 19,155 | 32.431065 | 101 | py |
fmm2d | fmm2d-main/python/test/test_hfmm.py | #!/usr/bin/env python
import fmm2dpy as fmm
import numpy as np
import numpy.linalg as la
def main():
test_hfmm()
def test_hfmm():
ntests = 36
testres = np.zeros(ntests)
#
# This is a testing code for making sure all the
# fmm routines are accessible through fmm2d.py
#
n = 2000
... | 19,754 | 33.356522 | 101 | py |
fmm2d | fmm2d-main/python/test/test_bhfmm.py | #!/usr/bin/env python
import fmm2dpy as fmm
import numpy as np
import numpy.linalg as la
def main():
test_bhfmm()
def test_bhfmm():
ntests = 36
testres = np.zeros(ntests)
#
# This is a testing code for making sure all the
# fmm routines are accessible through fmm2d.py
#
n = 2000
... | 18,473 | 31.353765 | 101 | py |
fmm2d | fmm2d-main/python/test/test_cfmm.py | #!/usr/bin/env python
import fmm2dpy as fmm
import numpy as np
import numpy.linalg as la
def main():
test_cfmm()
def test_cfmm():
ntests = 36
testres = np.zeros(ntests)
#
# This is a testing code for making sure all the
# fmm routines are accessible through fmm2d.py
#
n = 2000
... | 18,577 | 31.535902 | 101 | py |
fmm2d | fmm2d-main/test/modified-biharmonic/jinjaroot.yaml.py |
fname="jinjaroot.yaml"
file = open(fname,"w")
file.write("mbhDirectRouts:\n")
outs=["p","g","h"]
for out in outs:
for i in range(16):
i1 = i % 2
i2 = (i // 2) % 2
i3 = (i // 4) % 2
i4 = (i // 8) % 2
ker = ""
if (i1 == 1): ker += "c"
if (i2 == 1): ker += "... | 688 | 21.966667 | 72 | py |
fmm2d | fmm2d-main/docs/genfortdocumentation_helm.py | from numpy import *
intro = "This subroutine evaluates the "
pgstr = ["potential ", "potential and its gradient ", "potential, its gradient, and its hessian "]
intro2 = "\n\n .. math::\n\n"
eq_start = "u(x) = "
eq_start2 = "\sum_{j=1}^{N} "
str1 = "c_{j} H_{0}^{(1)}(k\|x-x_{j}\|)"
str2 = "v_{j} d_{j}\cdot \\nabla \\... | 16,282 | 52.739274 | 140 | py |
fmm2d | fmm2d-main/docs/conf.py | # -*- coding: utf-8 -*-
#
# fmm2d documentation build configuration file, created by
# sphinx-quickstart on Wed Nov 1 16:19:13 2017.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All... | 10,222 | 32.299674 | 119 | py |
Progressive-Face-Super-Resolution | Progressive-Face-Super-Resolution-master/ssim.py | import torch
import torch.nn.functional as F
from math import exp
import numpy as np
def gaussian(window_size, sigma):
gauss = torch.Tensor([exp(-(x - window_size//2)**2/float(2*sigma**2)) for x in range(window_size)]).double()
# gauss.requires_grad = True
return gauss/gauss.sum()
def create_window(windo... | 3,447 | 30.925926 | 118 | py |
Progressive-Face-Super-Resolution | Progressive-Face-Super-Resolution-master/dataloader.py | from torch.utils.data.dataset import Dataset
import torchvision.transforms as transforms
from os.path import join
from PIL import Image
class CelebDataSet(Dataset):
"""CelebA dataset
Parameters:
data_path (str) -- CelebA dataset main directory(inculduing '/Img' and '/Anno') path
state (str)... | 3,841 | 39.87234 | 125 | py |
Progressive-Face-Super-Resolution | Progressive-Face-Super-Resolution-master/model.py | import torch
import torch.nn as nn
from torch.nn import functional as F
from math import sqrt
"""Original EqualConv2d code is at
https://github.com/rosinality/style-based-gan-pytorch/blob/master/model.py
"""
class EqualLR:
def __init__(self, name):
self.name = name
def compute_weight(self, mo... | 7,795 | 35.773585 | 132 | py |
Progressive-Face-Super-Resolution | Progressive-Face-Super-Resolution-master/demo.py | import torch
import argparse
from model import Generator
from PIL import Image
import torchvision.transforms as transforms
from torchvision import utils
if __name__ == '__main__':
parser = argparse.ArgumentParser('Demo of Progressive Face Super-Resolution')
parser.add_argument('--image-path', type=str)
par... | 2,016 | 41.020833 | 105 | py |
Progressive-Face-Super-Resolution | Progressive-Face-Super-Resolution-master/eval.py | import torch
from torch import optim, nn
import argparse
from dataloader import CelebDataSet
from torch.utils.data import DataLoader
from model import Generator
import os
from torch.autograd import Variable, grad
import sys
from torchvision import utils
from math import log10
from ssim import ssim, msssim
def test(dat... | 4,296 | 41.97 | 166 | py |
ExtendedBitPlaneCompression | ExtendedBitPlaneCompression-master/algoEvals/totalComprRatio_generate.py | # Copyright (c) 2019 ETH Zurich, Lukas Cavigelli, Georg Rutishauser, Luca Benini
import pandas as pd
import datetime
import multiprocessing
import tqdm
import bpcUtils
import dataCollect
import analysisTools
import referenceImpl
analyzer = analysisTools.Analyzer(quantMethod='fixed16', compressor=None)
def zeroRLE_... | 3,879 | 41.173913 | 111 | py |
ExtendedBitPlaneCompression | ExtendedBitPlaneCompression-master/algoEvals/groupedBarPlot.py | # Copyright (c) 2019 ETH Zurich, Lukas Cavigelli, Georg Rutishauser, Luca Benini
def groupedBarPlot(data, groupNames, legend=None, xtickRot=None):
import matplotlib.pyplot as plt
barWidth = 1/(1+len(data[0]))
xpos = list(range(len(data)))
for s in range(len(data[0])):
plt.bar([x + s*barWidth for x in xpos]... | 737 | 40 | 92 | py |
ExtendedBitPlaneCompression | ExtendedBitPlaneCompression-master/algoEvals/referenceImpl.py | # Copyright (c) 2019 ETH Zurich, Lukas Cavigelli, Georg Rutishauser, Luca Benini
import math
import numpy as np
from bpcUtils import valuesToBinary
def CSC(values, maxDist=16, wordwidth=None):
"""CSC: encode each non-zero value as (rel. pos + value)"""
#only transfer non-zero values, but with incremental coordina... | 2,994 | 26.227273 | 102 | py |
ExtendedBitPlaneCompression | ExtendedBitPlaneCompression-master/algoEvals/reporting.py | # Copyright (c) 2019 ETH Zurich, Lukas Cavigelli, Georg Rutishauser, Luca Benini
import csv
import os
def readTable(tableName='totalComprRate-alexnet-after ReLU'):
filename = './results/%s.csv' % tableName
with open(filename, 'r') as csvfile:
cr = csv.reader(csvfile)
tbl = [row for row in cr]
... | 1,061 | 34.4 | 84 | py |
ExtendedBitPlaneCompression | ExtendedBitPlaneCompression-master/algoEvals/bpcUtils.py | # Copyright (c) 2019 ETH Zurich, Lukas Cavigelli, Georg Rutishauser, Luca Benini
import numpy as np
import math
def valuesToBinary(t, wordwidth=None):
"""Converts a numpy array using its datatype to a string of 1/0 values"""
arr = t.byteswap().tobytes()
wordwidthInput = t.dtype.itemsize*8# t[0].nbytes*8
if wo... | 13,302 | 31.446341 | 130 | py |
ExtendedBitPlaneCompression | ExtendedBitPlaneCompression-master/algoEvals/analysisTools.py | # Copyright (c) 2019 ETH Zurich, Lukas Cavigelli, Georg Rutishauser, Luca Benini
import functools
import numpy as np
from bpcUtils import quantize
class Analyzer:
def __init__(self, quantMethod, compressor):
""" quantMethod: provides the default quantization method. Can e.g. in ['float32', 'float16', 'fix... | 2,209 | 35.833333 | 138 | py |
ExtendedBitPlaneCompression | ExtendedBitPlaneCompression-master/algoEvals/dataCollect.py | # Copyright (c) 2019 ETH Zurich, Lukas Cavigelli, Georg Rutishauser, Luca Benini
import torch
import numpy as np
import tensorboard
from tensorboard.backend.event_processing.event_accumulator import EventAccumulator
import os
import glob
import csv
import sys
sys.path.append('./quantLab')
def getModel(modelName, ep... | 5,473 | 33.64557 | 123 | py |
l2hmc | l2hmc-master/baseline_vae.py | # Copyright 2017 Google Inc.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,... | 5,886 | 27.57767 | 112 | py |
l2hmc | l2hmc-master/mnist_vae.py | # Copyright 2017 Google Inc.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,... | 12,163 | 33.556818 | 124 | py |
l2hmc | l2hmc-master/eval_vae.py | # Copyright 2017 Google Inc.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,... | 3,278 | 31.465347 | 192 | py |
l2hmc | l2hmc-master/eval_sampler.py | # Copyright 2017 Google Inc.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,... | 6,509 | 30 | 143 | py |
l2hmc | l2hmc-master/__init__.py | # Copyright 2017 Google Inc.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,... | 576 | 40.214286 | 74 | py |
l2hmc | l2hmc-master/utils/notebook_utils.py | import tensorflow as tf
import numpy as np
from dynamics import Dynamics
from sampler import propose
import matplotlib.pyplot as plt
def plot_grid(S, width=8):
sheet_width = width
plt.figure(figsize=(12, 12))
for i in xrange(S.shape[0]):
plt.subplot(sheet_width, sheet_width, i + 1)
plt.imsh... | 1,248 | 30.225 | 86 | py |
l2hmc | l2hmc-master/utils/distributions.py | # Copyright 2017 Google Inc.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,... | 6,397 | 28.897196 | 137 | py |
l2hmc | l2hmc-master/utils/losses.py | # Copyright 2017 Google Inc.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,... | 1,566 | 25.116667 | 74 | py |
l2hmc | l2hmc-master/utils/sampler.py | # Copyright 2017 Google Inc.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,... | 2,684 | 29.862069 | 95 | py |
l2hmc | l2hmc-master/utils/ais.py | # Copyright 2017 Google Inc.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,... | 2,843 | 33.26506 | 107 | py |
l2hmc | l2hmc-master/utils/layers.py | # Copyright 2017 Google Inc.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,... | 2,826 | 28.14433 | 133 | py |
l2hmc | l2hmc-master/utils/config.py | # Copyright 2017 Google Inc.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,... | 818 | 29.333333 | 74 | py |
l2hmc | l2hmc-master/utils/__init__.py | # Copyright 2017 Google Inc.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,... | 576 | 40.214286 | 74 | py |
l2hmc | l2hmc-master/utils/func_utils.py | # Copyright 2017 Google Inc.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,... | 3,310 | 26.363636 | 102 | py |
l2hmc | l2hmc-master/utils/dynamics.py | # Copyright 2017 Google Inc.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,... | 8,936 | 27.736334 | 135 | py |
blp | blp-master/utils.py | import torch
import logging
import models
def get_model(model, dim, rel_model, loss_fn, num_entities, num_relations,
encoder_name, regularizer):
if model == 'blp':
return models.BertEmbeddingsLP(dim, rel_model, loss_fn, num_relations,
encoder_name, regu... | 7,375 | 39.306011 | 79 | py |
blp | blp-master/data.py | import os.path as osp
import torch
from torch.utils.data import Dataset
import transformers
import string
import nltk
from tqdm import tqdm
from nltk.corpus import stopwords
import logging
UNK = '[UNK]'
nltk.download('stopwords')
nltk.download('punkt')
STOP_WORDS = stopwords.words('english')
DROPPED = STOP_WORDS + lis... | 13,290 | 36.866097 | 79 | py |
blp | blp-master/retrieval.py | import os
import os.path as osp
from collections import defaultdict
import torch
import torch.nn.functional as F
from tqdm import tqdm
from transformers import BertTokenizer
from logging import Logger
from sacred import Experiment
from sacred.observers import MongoObserver
from sacred.run import Run
import json
import ... | 11,801 | 37.194175 | 82 | py |
blp | blp-master/models.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from transformers import BertModel
class LinkPrediction(nn.Module):
"""A general link prediction model with a lookup table for relation
embeddings."""
def __init__(self, dim, rel_model, loss_fn, num_relations, regularizer):
super()... | 9,514 | 34.636704 | 79 | py |
blp | blp-master/train.py | import os
import os.path as osp
import networkx as nx
import torch
from torch.optim import Adam
from torch.utils.data import DataLoader
from sacred.run import Run
from logging import Logger
from sacred import Experiment
from sacred.observers import MongoObserver
from transformers import BertTokenizer, get_linear_schedu... | 18,945 | 38.063918 | 83 | py |
blp | blp-master/data/utils.py | import sys
from tqdm import tqdm
from argparse import ArgumentParser
import networkx as nx
import random
import os.path as osp
from collections import Counter, defaultdict
import torch
import rdflib
def parse_triples(triples_file):
"""Read a file containing triples, with head, relation, and tail
separated by ... | 14,869 | 36.455919 | 79 | py |
tilt-brush-toolkit | tilt-brush-toolkit-master/bin/normalize_sketch.py | #!/usr/bin/env python
# Copyright 2017 Google Inc. 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required... | 6,027 | 39.72973 | 154 | py |
tilt-brush-toolkit | tilt-brush-toolkit-master/bin/dump_tilt.py | #!/usr/bin/env python
# Copyright 2016 Google Inc. 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requi... | 3,576 | 31.816514 | 87 | py |
tilt-brush-toolkit | tilt-brush-toolkit-master/bin/tilt_to_strokes_dae.py | #!/usr/bin/env python
# Copyright 2016 Google Inc. 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requi... | 7,840 | 31.945378 | 112 | py |
tilt-brush-toolkit | tilt-brush-toolkit-master/bin/concatenate_tilt.py | #!/usr/bin/env python
import os
import pprint
import shutil
import sys
from tiltbrush import tilt
def destroy(filename):
try:
os.unlink(filename)
except OSError:
pass
def increment_timestamp(stroke, increment):
"""Adds *increment* to all control points in stroke."""
timestamp_idx = stroke.cp_ext_lo... | 3,076 | 29.77 | 94 | py |
tilt-brush-toolkit | tilt-brush-toolkit-master/bin/geometry_json_to_obj.py | #!/usr/bin/env python
# Copyright 2016 Google Inc. 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requi... | 4,888 | 35.214815 | 183 | py |
tilt-brush-toolkit | tilt-brush-toolkit-master/bin/unpack_tilt.py | #!/usr/bin/env python
# Copyright 2016 Google Inc. 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requi... | 1,925 | 33.392857 | 160 | py |
tilt-brush-toolkit | tilt-brush-toolkit-master/bin/geometry_json_to_fbx.py | #!/usr/bin/env python
# Copyright 2016 Google Inc. 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requi... | 10,455 | 34.686007 | 98 | py |
tilt-brush-toolkit | tilt-brush-toolkit-master/tests/test_tilt.py | # Copyright 2016 Google Inc. 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... | 3,871 | 34.851852 | 85 | py |
tilt-brush-toolkit | tilt-brush-toolkit-master/Python/tiltbrush/export.py | # Copyright 2016 Google Inc. 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 9,329 | 31.968198 | 92 | py |
tilt-brush-toolkit | tilt-brush-toolkit-master/Python/tiltbrush/tilt.py | # Copyright 2016 Google Inc. 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 19,616 | 33.235602 | 93 | py |
tilt-brush-toolkit | tilt-brush-toolkit-master/Python/tiltbrush/__init__.py | # Copyright 2016 Google Inc. 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 600 | 39.066667 | 74 | py |
tilt-brush-toolkit | tilt-brush-toolkit-master/Python/tiltbrush/unpack.py | # Copyright 2016 Google Inc. 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 5,727 | 30.300546 | 96 | py |
wikitables | wikitables-master/test.py | import json
import unittest
import mwparserfromhell as mwp
from wikitables import ftag, WikiTable
class TestWikiTables(unittest.TestCase):
def _load(self, source, lang='en'):
raw_tables = mwp.parse(source).filter_tags(matches=ftag('table'))
return WikiTable("Test Table", raw_tables[0], lang)
... | 6,273 | 23.412451 | 74 | py |
wikitables | wikitables-master/setup.py | from setuptools import setup
exec(open('wikitables/version.py').read())
setup(name='wikitables',
version=version,
packages=['wikitables'],
description='Import tables from any Wikipedia article',
author='Bradley Cicenas',
author_email='bradley@vektor.nyc',
url='https://github.com/bc... | 957 | 32.034483 | 76 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.