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 |
|---|---|---|---|---|---|---|
deep_equilibrium_inverse | deep_equilibrium_inverse-main/operators/operator.py | import torch
class LinearOperator(torch.nn.Module):
def __init__(self):
super(LinearOperator, self).__init__()
def forward(self, x):
pass
def adjoint(self, x):
pass
def gramian(self, x):
return self.adjoint(self.forward(x))
class SelfAdjointLinearOperator(LinearOpera... | 819 | 24.625 | 61 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/operators/__init__.py | 0 | 0 | 0 | py | |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/operators/singlecoil_mri.py | import torch, numbers, math
import torch.nn as nn
import torch.nn.functional as torchfunc
from operators.operator import LinearOperator
import numpy as np
import torch
def to_tensor(data):
"""
Convert numpy array to PyTorch tensor. For complex arrays, the real and imaginary parts
are stacked along the ... | 15,854 | 31.623457 | 99 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/operators/blurs.py | import numpy as np
import numbers
import math
import cv2
import torch
import torch.nn.functional as torchfunc
from operators.operator import LinearOperator
class GaussianBlur(LinearOperator):
def __init__(self, sigma, kernel_size=5, n_channels=3, n_spatial_dimensions = 2):
super(GaussianBlur, self).__init_... | 3,604 | 47.716216 | 111 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/solvers/broyd_equilibrium_utils.py | import torch.nn as nn
import torch
import matplotlib
#matplotlib.use("TkAgg")
from matplotlib import pyplot as plt
import imageio
import numpy as np
from PIL import Image
def _safe_norm(v):
if not torch.isfinite(v).all():
return np.inf
return torch.norm(v)
def scalar_search_armijo(phi, phi0, derphi0... | 17,348 | 34.478528 | 120 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/solvers/equilibrium_nets.py | import torch.nn as nn
import torch
from solvers.cg_utils import conjugate_gradient
class EquilibriumGrad(nn.Module):
def __init__(self, linear_operator, nonlinear_operator, eta_initial_val=0.1, minval = -1, maxval = 1):
super(EquilibriumGrad,self).__init__()
self.linear_op = linear_operator
... | 3,395 | 39.915663 | 123 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/solvers/proxgrad.py | import torch.nn as nn
import torch
from solvers.cg_utils import conjugate_gradient
from PIL import Image
import imageio
import numpy as np
tt=0
class ProxgradNet(nn.Module):
def __init__(self, linear_operator, nonlinear_operator, eta_initial_val=0.1):
super(ProxgradNet,self).__init__()
self.linear_... | 9,973 | 48.376238 | 134 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/solvers/gradnet.py | import torch.nn as nn
import torch
from solvers.cg_utils import conjugate_gradient
from PIL import Image
import imageio
import numpy as np
tt = 0
class GradNet(nn.Module):
def __init__(self, linear_operator, nonlinear_operator, eta_initial_val=0.1):
super(GradNet,self).__init__()
self.linear_op = li... | 6,039 | 45.10687 | 135 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/solvers/new_equilibrium_utils.py | import torch.nn as nn
import torch
import matplotlib
#matplotlib.use("TkAgg")
from matplotlib import pyplot as plt
import imageio
import numpy as np
from PIL import Image
def complex_conj(x):
assert x.shape[1] == 2
return torch.stack((x[:,0, ...], -x[:,1,...]), dim=1)
def torchdotproduct(x,y):
# if comple... | 12,873 | 33.239362 | 120 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/solvers/cg_utils.py | import torch.nn as nn
import torch
def complex_conj(x):
assert x.shape[1] == 2
return torch.stack((x[:,0, ...], -x[:,1,...]), dim=1)
def torchdotproduct(x,y):
# if complexdata:
# y = complex_conj(y)
return torch.sum(x*y,dim=[1,2,3])
def single_cg_iteration(x, d, g, b, ATA, regularization_lambda):... | 2,165 | 29.507042 | 89 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/solvers/equilibrium_solvers.py | import torch.nn as nn
import torch
import matplotlib
# matplotlib.use("TkAgg")
import matplotlib.pyplot as plt
from solvers.cg_utils import conjugate_gradient
class EquilibriumGrad(nn.Module):
def __init__(self, linear_operator, nonlinear_operator, eta, minval = -1, maxval = 1):
super(EquilibriumGrad,self... | 13,787 | 36.16442 | 122 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/utils/fastmri_dataloader.py | import torch
from torch.utils.data import Dataset, DataLoader
import numpy as np
import os, re, random, h5py, ismrmrd
from PIL import Image
from torch.utils.data import Dataset
from utils import forward_models_mri
def directory_filelist(target_directory):
file_list = [f for f in os.listdir(target_directory)
... | 6,291 | 35.581395 | 99 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/utils/celeba_dataloader.py | import torch
from torch.utils.data import Dataset, DataLoader
import numpy as np
import os, re, random
from PIL import Image
def swap_patches(batch, index1, index2, h,w, patch_top_loc, patch_left_loc):
tmp = batch[
index1,
patch_top_loc:patch_top_loc+h,
patch_left_loc:patch_left_loc+w, :].clon... | 5,423 | 33.769231 | 101 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/utils/testing_utils.py | from PIL import Image
import torch
import matplotlib.pyplot as plt
import numpy as np
import imageio
from PIL import Image
def save_tensor_as_color_img(img_tensor, filename):
np_array = img_tensor.cpu().detach().numpy()
imageio.save(filename, np_array)
def save_batch_as_color_imgs(tensor_batch, batch_size, ii... | 2,513 | 40.9 | 106 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/utils/spectral_norm.py | """
Spectral Normalization borrowed from https://arxiv.org/abs/1802.05957
Real SN by convolution. Each layer has lipschtz constant of 1
"""
import torch
from torch.nn.functional import conv2d, conv_transpose2d
from torch.nn.parameter import Parameter
# import argparse
# from ..train_realSN import opt
# import torch.ji... | 20,664 | 42.141962 | 120 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/utils/forward_models_mri.py | import torch, numbers, math
import torch.nn as nn
import torch.nn.functional as torchfunc
import numpy as np
import cv2
import numpy as np
import torch
def to_tensor(data):
"""
Convert numpy array to PyTorch tensor. For complex arrays, the real and imaginary parts
are stacked along the last dimension.
... | 21,838 | 33.446372 | 119 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/utils/__init__.py | 0 | 0 | 0 | py | |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/utils/spectral_norm_chen.py | """
Spectral Normalization borrowed from https://arxiv.org/abs/1802.05957
Real SN by convolution. Each layer has lipschtz constant of 1
"""
import torch
from torch.nn.functional import conv2d
from torch.nn.parameter import Parameter
def normalize(tensor, eps=1e-12):
norm = float(torch.sqrt(torch.sum(tensor * tenso... | 7,791 | 43.272727 | 120 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/utils/bsd500.py | import torch
import h5py
import random
import numpy as np
import os
from PIL import Image
from torchvision import transforms
class Dataset(torch.utils.data.Dataset):
def __init__(self, train=True, mode='S'):
super(Dataset, self).__init__()
self.train = train
self.mode = mode
self.da... | 3,858 | 34.731481 | 98 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/utils/cg_utils.py | import torch.nn as nn
import torch
def complex_conj(x):
assert x.shape[1] == 2
return torch.stack((x[:,0, ...], -x[:,1,...]), dim=1)
def torchdotproduct(x,y):
# if complexdata:
# y = complex_conj(y)
return torch.sum(x*y,dim=[1,2,3])
def single_cg_iteration(x, d, g, b, ATA, regularization_lambda):... | 2,165 | 29.507042 | 89 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/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,635 | 34.621622 | 104 | py |
RECON-period | RECON-period/example.py |
from mpi4py import MPI
import numpy as np
import cyrecon
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
# create a dnest sampler
sample = cyrecon.cyrecon()
# run sampler
logz = sample.run()
if rank == 0:
print(logz)
| 222 | 11.388889 | 26 | py |
RECON-period | RECON-period/setup.py | import os
from setuptools import setup
from setuptools.extension import Extension
import pkgconfig
from glob import glob
import numpy
# if CC is not set, use the default value
if not os.environ.get("CC"):
os.environ["CC"] = "mpicc"
def configure_mpi():
"""
get configurations of mpi
"""
if pkgconfig.exists('... | 2,230 | 27.974026 | 117 | py |
RECON-period | RECON-period/analysis.py | #/*
# * RECON Copyright (C) 2018 Yan-Rong Li
# * A package for measuring spectral power and reconstructing time series in AGN.
# *
# * Yan-Rong Li, liyanrong@mail.ihep.ac.cn
# *
# * implement Bayesian posterior predictive checking.
# */
import os
import copy
import numpy as np
import numpy.fft as fft
import matplotl... | 18,793 | 28.974482 | 140 | py |
RECON-period | RECON-period/psd_plot.py | #
# a python script for showing results.
#
# Yan-Rong Li, liyanrong@mail.ihep.ac.cn
# Nov 3, 2018
import numpy as np
import os
import sys
import matplotlib.pyplot as plt
import configparser as cfgpars
def read_params(fname):
"""
read parameter file
"""
config = cfgpars.RawConfigParser(delimiters=' ', comment... | 10,041 | 32.251656 | 119 | py |
open-sesame | open-sesame-master/setup.py | import os
import setuptools
setuptools.setup(
name='open-sesame',
author='Swabha Swayamdipta',
author_email='sswayamd@alumni.cmu.edu',
description='Frame-Semantic Parsing with Segmental RNNs and a Syntactic Scaffold',
url='https://github.com/swabhs/open-sesame/',
install... | 358 | 28.916667 | 90 | py |
open-sesame | open-sesame-master/sesame/raw_data.py | # coding=utf-8
# Copyright 2018 Swabha Swayamdipta. 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... | 1,604 | 37.214286 | 105 | py |
open-sesame | open-sesame-master/sesame/discrete_argid_feats.py | # coding=utf-8
# Copyright 2018 Swabha Swayamdipta. 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... | 2,692 | 29.602273 | 86 | py |
open-sesame | open-sesame-master/sesame/frameid.py | # coding=utf-8
# Copyright 2018 Swabha Swayamdipta. 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... | 17,372 | 37.779018 | 136 | py |
open-sesame | open-sesame-master/sesame/dataio.py | # coding=utf-8
# Copyright 2018 Swabha Swayamdipta. 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... | 14,806 | 34.59375 | 135 | py |
open-sesame | open-sesame-master/sesame/frame_semantic_graph.py | # coding=utf-8
# Copyright 2018 Swabha Swayamdipta. 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... | 3,889 | 31.966102 | 155 | py |
open-sesame | open-sesame-master/sesame/housekeeping.py | # coding=utf-8
# Copyright 2018 Swabha Swayamdipta. 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... | 7,866 | 32.763948 | 118 | py |
open-sesame | open-sesame-master/sesame/conll09.py | # coding=utf-8
# Copyright 2018 Swabha Swayamdipta. 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... | 10,660 | 36.146341 | 164 | py |
open-sesame | open-sesame-master/sesame/argid.py | # coding=utf-8
# Copyright 2018 Swabha Swayamdipta. 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... | 41,795 | 37.450782 | 143 | py |
open-sesame | open-sesame-master/sesame/targetid.py | # coding=utf-8
# Copyright 2018 Swabha Swayamdipta. 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... | 18,332 | 38.173077 | 128 | py |
open-sesame | open-sesame-master/sesame/sentence.py | # coding=utf-8
# Copyright 2018 Swabha Swayamdipta. 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... | 8,288 | 35.676991 | 102 | py |
open-sesame | open-sesame-master/sesame/fe_to_conll.py | # coding=utf-8
# Copyright 2018 Swabha Swayamdipta. 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... | 5,055 | 38.811024 | 112 | py |
open-sesame | open-sesame-master/sesame/semafor_evaluation.py | # coding=utf-8
# Copyright 2018 Swabha Swayamdipta. 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... | 7,966 | 36.580189 | 117 | py |
open-sesame | open-sesame-master/sesame/preprocess_syntax.py | # coding=utf-8
# Copyright 2018 Swabha Swayamdipta. 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... | 2,347 | 44.153846 | 104 | py |
open-sesame | open-sesame-master/sesame/__init__.py | '''This package contains a frame-semantic parser'''
| 52 | 25.5 | 51 | py |
open-sesame | open-sesame-master/sesame/evaluation.py | # coding=utf-8
# Copyright 2018 Swabha Swayamdipta. 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... | 8,885 | 31.911111 | 107 | py |
open-sesame | open-sesame-master/sesame/add_ensembles.py | # coding=utf-8
# Copyright 2018 Swabha Swayamdipta. 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... | 1,318 | 30.404762 | 101 | py |
open-sesame | open-sesame-master/sesame/xml_annotations.py | # coding=utf-8
# Copyright 2018 Swabha Swayamdipta. 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... | 5,756 | 31.897143 | 96 | py |
open-sesame | open-sesame-master/sesame/preprocess.py | # coding=utf-8
# Copyright 2018 Swabha Swayamdipta. 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... | 15,760 | 36.887019 | 151 | py |
open-sesame | open-sesame-master/sesame/globalconfig.py | # coding=utf-8
# Copyright 2018 Swabha Swayamdipta. 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... | 3,742 | 32.419643 | 96 | py |
GraphGAN | GraphGAN-master/src/utils.py | import numpy as np
def str_list_to_float(str_list):
return [float(item) for item in str_list]
def str_list_to_int(str_list):
return [int(item) for item in str_list]
def read_edges(train_filename, test_filename):
"""read data from files
Args:
train_filename: training file name
test... | 3,938 | 28.395522 | 83 | py |
GraphGAN | GraphGAN-master/src/GraphGAN/graph_gan.py | import os
import collections
import tqdm
import multiprocessing
import pickle
import numpy as np
import tensorflow as tf
import config
import generator
import discriminator
from src import utils
from src.evaluation import link_prediction as lp
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
class GraphGAN(object):
def ... | 13,482 | 40.486154 | 119 | py |
GraphGAN | GraphGAN-master/src/GraphGAN/discriminator.py | import tensorflow as tf
import config
class Discriminator(object):
def __init__(self, n_node, node_emd_init):
self.n_node = n_node
self.node_emd_init = node_emd_init
with tf.variable_scope('discriminator'):
self.embedding_matrix = tf.get_variable(name="embedding",
... | 1,785 | 50.028571 | 118 | py |
GraphGAN | GraphGAN-master/src/GraphGAN/config.py | modes = ["gen", "dis"]
# training settings
batch_size_gen = 64 # batch size for the generator
batch_size_dis = 64 # batch size for the discriminator
lambda_gen = 1e-5 # l2 loss regulation weight for the generator
lambda_dis = 1e-5 # l2 loss regulation weight for the discriminator
n_sample_gen = 20 # number of sam... | 1,873 | 43.619048 | 103 | py |
GraphGAN | GraphGAN-master/src/GraphGAN/__init__.py | 0 | 0 | 0 | py | |
GraphGAN | GraphGAN-master/src/GraphGAN/generator.py | import tensorflow as tf
import config
class Generator(object):
def __init__(self, n_node, node_emd_init):
self.n_node = n_node
self.node_emd_init = node_emd_init
with tf.variable_scope('generator'):
self.embedding_matrix = tf.get_variable(name="embedding",
... | 1,723 | 52.875 | 117 | py |
GraphGAN | GraphGAN-master/src/evaluation/link_prediction.py | """
The class is used to evaluate the application of link prediction
"""
import numpy as np
from sklearn.metrics import accuracy_score
from src import utils
class LinkPredictEval(object):
def __init__(self, embed_filename, test_filename, test_neg_filename, n_node, n_embed):
self.embed_filename = embed_fi... | 1,509 | 37.717949 | 92 | py |
GraphGAN | GraphGAN-master/src/evaluation/__init__.py | 0 | 0 | 0 | py | |
RELAGN | RELAGN-main/src/python_version/relagn.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Mar 10 16:50:31 2022
@author: Scott Hagen
Relativistic versions of AGNSED (RELAGN) and QSOSED (RELQSO) (Kubota & Done 2018).
The relativistic corrections are calculated using the convolution code
KYCONV (Dovciak, Karas & Yaqoob 2004)
For the Comptonis... | 60,113 | 30.391123 | 101 | py |
RELAGN | RELAGN-main/src/python_version/pyNTHCOMP.py |
"""
This was taken from https://github.com/arnauqb/qsosed/tree/master/qsosed,
which in turn was taken from https://github.com/ADThomas-astro/oxaf/blob/master/oxaf.py .
Credit to A.D. Thomas.
Code was adapted from Xspec for https://arxiv.org/pdf/1611.05165.pdf .
"""
import numpy as np
def donthcomp(ear, param):
... | 9,946 | 38.629482 | 89 | py |
RELAGN | RELAGN-main/tests/relagn_spec.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Dec 6 15:20:33 2022
@author: Scott Hagen
code to play around with the relagn model - test to see if it gives spectra,
unit handling, etc
"""
import numpy as np
import matplotlib.pyplot as plt
import os
import sys
mdir = os.path.abspath(__file__)
mdi... | 1,526 | 19.635135 | 78 | py |
RELAGN | RELAGN-main/tests/relqso_spec.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Dec 6 15:55:23 2022
@author: Scott Hagen
"""
import numpy as np
import matplotlib.pyplot as plt
import os
import sys
mdir = os.path.abspath(__file__)
mdir = mdir.replace('/tests/relagn_spec.py', '/src/python_version')
sys.path.append(mdir)
from rela... | 940 | 18.204082 | 67 | py |
RELAGN | RELAGN-main/tests/blurr_test.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Mar 14 11:46:24 2022
@author: wljw75
"""
"""
Tests the relconv convolution on a simple gaussian with a r^-3 emissivity
law - as this should (hoefully!) give the same as kdblur
"""
import numpy as np
import xspec
import matplotlib.pyplot as plt
xspe... | 5,110 | 23.81068 | 107 | py |
scootplayer | scootplayer-master/tests.py | import scootplayer
import unittest
import os
import time
import random
from mock import Mock, MagicMock
import scootplayer.player as player
import scootplayer.bandwidth as bandwidth
import scootplayer.queue as queue
import scootplayer.remote as remote
import scootplayer.reporter as reporter
import scootplayer.represen... | 6,420 | 36.115607 | 94 | py |
scootplayer | scootplayer-master/scootplayer.py | #!/usr/bin/env python2.7
"""Parses command line options and passes them to a new player."""
import scootplayer.player as player
import optparse
if __name__ == '__main__':
PARSER = optparse.OptionParser()
PARSER.set_defaults(output='out/', keep_alive=True,
max_playback_queue=60, max_do... | 5,496 | 58.75 | 80 | py |
scootplayer | scootplayer-master/scootplayer/reporter.py | #!/usr/bin/env python2.7
"""Reporter used to report periodic statistics and events."""
import time
import platform
import sys
class Reporter(object):
"""
Handles the reporting of player statistics and events to STDOUT and file.
"""
player = None
start_time = 0
report_file = None
event_... | 8,095 | 35.968037 | 80 | py |
scootplayer | scootplayer-master/scootplayer/player.py | #!/usr/bin/env python2.7
"""Experimental MPEG-DASH player emulator."""
import os
import requests
import shutil
import signal
import threading
import time
import scootplayer.bandwidth as bandwidth
import scootplayer.queue as queue
import scootplayer.remote as remote
import scootplayer.reporter as reporter
import scoo... | 13,318 | 35.291553 | 80 | py |
scootplayer | scootplayer-master/scootplayer/progressbar.py | #!/usr/bin/env python2.7
"""A visualisation of playback progress using a bar."""
from progress.bar import Bar
class NullBar(Bar):
"""Use an empty bar if in debug mode."""
def __init__(self):
"""Do nothing on initialisation."""
pass
def next(self, n=1):
"""Do nothing on update."... | 1,181 | 26.488372 | 76 | py |
scootplayer | scootplayer-master/scootplayer/__init__.py | """Empty __init__.py to enable loading of scootplayer as module."""
| 68 | 33.5 | 67 | py |
scootplayer | scootplayer-master/scootplayer/remote.py | #!/usr/bin/env python2.7
"""Remote control functionality on the player side."""
import zmq
import time
class RemoteControl(object):
"""
Receives commands from remote control application and executes
corresponding actions.
"""
run = False
socket = None
def __init__(self, player, optio... | 3,861 | 29.896 | 79 | py |
scootplayer | scootplayer-master/scootplayer/bandwidth.py | #!/usr/bin/env python2.7
"""Facilitates the measurement of current network bandwidth."""
import collections
class Bandwidth(object):
"""Object containing the current bandwidth estimation."""
def __init__(self):
self._current = 0
self._previous = 0
self._trend = collections.deque(max... | 1,201 | 26.318182 | 72 | py |
scootplayer | scootplayer-master/scootplayer/watchdog.py | #!/usr/bin/env python2.7
"""Inspects player behaviour to ensure playback is occuring."""
class Watchdog(object):
"""Aids in debugging issues caused by stalled playback."""
watch_value = 0
watch_count = False
max_seg_duration = 0
run = False
def __init__(self, player):
"""Start thre... | 3,451 | 31.261682 | 79 | py |
scootplayer | scootplayer-master/scootplayer/representations.py | #!/usr/bin/env python2.7
"""Represents the different playback levels in an MPD."""
from lxml import etree
import aniso8601
import os
import Queue
import random
import re
import requests
import threading
import time
import multiprocessing
from pymediainfo import MediaInfo
def call_it(instance, name, args=(), kwargs=... | 18,546 | 37.720251 | 90 | py |
scootplayer | scootplayer-master/scootplayer/queue/base.py | #!/usr/bin/env python2.7
"""Base class for the different queues used in Scootplayer."""
import Queue
import re
import numpy as np
class BaseQueue(object):
"""A set of common functions used on the queue classes of Scootplayer."""
window_size = 5
def __init__(self, *args, **kwargs):
"""Initiali... | 3,485 | 34.212121 | 87 | py |
scootplayer | scootplayer-master/scootplayer/queue/playlist.py | #!/usr/bin/env python2.7
"""Functions as a list of manifests to be played back in order."""
from .base import BaseQueue
class PlaylistQueue(BaseQueue):
"""Functions as a list of manifests to be played back in order."""
def __init__(self, *args, **kwargs):
"""Initialise download queue with max size... | 1,847 | 29.295082 | 71 | py |
scootplayer | scootplayer-master/scootplayer/queue/download.py | #!/usr/bin/env python2.7
"""Queue used to regulate segment downloads."""
from .base import BaseQueue
import time
class DownloadQueue(BaseQueue):
"""Object which acts as a download queue for the player."""
def __init__(self, *args, **kwargs):
"""Initialise download queue with max size and start thr... | 2,165 | 35.1 | 75 | py |
scootplayer | scootplayer-master/scootplayer/queue/__init__.py | """Import the named modules in this directory."""
from . import download
from . import playback
from . import playlist
| 120 | 19.166667 | 49 | py |
scootplayer | scootplayer-master/scootplayer/queue/playback.py | #!/usr/bin/env python2.7
"""Queue used to emulate the player playing back downloaded content."""
from .base import BaseQueue
import time
class PlaybackQueue(BaseQueue):
"""Object which acts as a playback queue for the player."""
mpd_duration = 0
def __init__(self, *args, **kwargs):
"""
... | 3,450 | 36.51087 | 94 | py |
scootplayer | scootplayer-master/remote/scootplayer_remote_control.py | #!/usr/bin/env python2.7
"""Remote control for multiple remote Scootplayer clients."""
import zmq
import sys
import cmd
class ScootplayerRemoteControl(cmd.Cmd):
"""Remote control for multiple remote Scootplayer clients."""
intro = """Welcome to the Scootplayer Remote Control.
Type help or ? to lis... | 1,859 | 24.135135 | 77 | py |
scootplayer | scootplayer-master/remote/__init__.py | 0 | 0 | 0 | py | |
federated-boosted-dp-trees | federated-boosted-dp-trees-master/federated_gbdt/__init__.py | 0 | 0 | 0 | py | |
federated-boosted-dp-trees | federated-boosted-dp-trees-master/federated_gbdt/core/plotting.py | import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import gaussian_kde
from federated_gbdt.models.gbdt.private_gbdt import PrivateGBDT
from experiments.experiment_helpers.data_loader import DataLoader
def plot_feature_importance(model, feature_names, method="gain"):
"""
... | 4,042 | 41.557895 | 128 | py |
federated-boosted-dp-trees | federated-boosted-dp-trees-master/federated_gbdt/core/loss_functions.py | import numpy as np
def sigmoid(x):
return 1.0 / (1.0 + np.exp(-x))
class Sigmoid():
def __call__(self, x):
return 1 / (1 + np.exp(-x))
def gradient(self, x):
return self.__call__(x) * (1 - self.__call__(x))
def softmax(x, axis=-1):
y = np.exp(x - np.max(x, axis, keepdims=True))
r... | 4,025 | 24.006211 | 112 | py |
federated-boosted-dp-trees | federated-boosted-dp-trees-master/federated_gbdt/core/__init__.py | 0 | 0 | 0 | py | |
federated-boosted-dp-trees | federated-boosted-dp-trees-master/federated_gbdt/core/baseline_constants.py |
ACCURACY_KEY = 'accuracy'
BYTES_WRITTEN_KEY = 'bytes_written'
BYTES_READ_KEY = 'bytes_read'
LOCAL_COMPUTATIONS_KEY = 'local_computations'
NUM_ROUND_KEY = 'round_number'
NUM_SAMPLES_KEY = 'num_samples'
CLIENT_ID_KEY = 'client_id'
FLOAT_ZERO = 1e-8
QUANTILE = 'quantile'
DEFAULT_COMPRESS_THRESHOLD = 10000
DEFAULT_HEAD_S... | 638 | 23.576923 | 91 | py |
federated-boosted-dp-trees | federated-boosted-dp-trees-master/federated_gbdt/core/pure_ldp/__init__.py | 0 | 0 | 0 | py | |
federated-boosted-dp-trees | federated-boosted-dp-trees-master/federated_gbdt/core/pure_ldp/core/prob_simplex.py | import numpy as np
#simplex projection
def project_probability_simplex(p_estimate):
k = len(p_estimate) # Infer the size of the alphabet.
p_estimate_sorted = np.sort(p_estimate)
p_estimate_sorted[:] = p_estimate_sorted[::-1]
p_sorted_cumsum = np.cumsum(p_estimate_sorted)
i = 1
while i < k:
... | 525 | 34.066667 | 81 | py |
federated-boosted-dp-trees | federated-boosted-dp-trees-master/federated_gbdt/core/pure_ldp/core/_freq_oracle_client.py |
class FreqOracleClient:
def __init__(self, epsilon, d, index_mapper=None):
"""
Args:
epsilon (float): Privacy budget
d (int): domain size - not all freq oracles need this, so can be None
index_mapper (func): Optional function - maps data items to indexes in the ... | 1,609 | 34.777778 | 148 | py |
federated-boosted-dp-trees | federated-boosted-dp-trees-master/federated_gbdt/core/pure_ldp/core/_freq_oracle_server.py | import warnings
import numpy as np
from federated_gbdt.core.pure_ldp.core.prob_simplex import project_probability_simplex
class FreqOracleServer:
def __init__(self, epsilon, d, index_mapper=None):
"""
Args:
epsilon: privacy budget
d: domain size - not all freq oracles need ... | 6,145 | 35.583333 | 141 | py |
federated-boosted-dp-trees | federated-boosted-dp-trees-master/federated_gbdt/core/pure_ldp/core/fo_creator.py | from federated_gbdt.core.pure_ldp.frequency_oracles import *
import copy
import inspect
# Used to create a list of possible frequency oracles in the pure-LDP library
client_class_list = []
server_class_list = []
globs = list(globals().keys()).copy() # Create copy, since globals updates too much to iterate through
... | 2,674 | 29.397727 | 114 | py |
federated-boosted-dp-trees | federated-boosted-dp-trees-master/federated_gbdt/core/pure_ldp/core/__init__.py | import xxhash
import hashlib
from bitarray import bitarray
# Base classes for frequency oracles
from ._freq_oracle_client import FreqOracleClient
from ._freq_oracle_server import FreqOracleServer
# Helper functions for generating hash funcs
def generate_hash_funcs(k, m):
"""
Generates k hash functions that m... | 1,630 | 23.343284 | 74 | py |
federated-boosted-dp-trees | federated-boosted-dp-trees-master/federated_gbdt/core/pure_ldp/frequency_oracles/local_hashing/fast_lh_server.py | import xxhash
import numpy as np
from federated_gbdt.core.pure_ldp.frequency_oracles.local_hashing import LHServer
# Server-side for fast local-hashing
class FastLHServer(LHServer):
def __init__(self, epsilon, d, k, g=2, use_olh=True, index_mapper=None, hash_matrix=None):
"""
Args:
ep... | 3,718 | 41.261364 | 141 | py |
federated-boosted-dp-trees | federated-boosted-dp-trees-master/federated_gbdt/core/pure_ldp/frequency_oracles/local_hashing/fast_lh_client.py | import random
from federated_gbdt.core.pure_ldp.frequency_oracles.local_hashing import LHClient
# Client-side for fast local-hashing
# Heuristic fast variant of OLH
class FastLHClient(LHClient):
def __init__(self, epsilon, d, k, g=2, use_olh=False, index_mapper=None):
"""
Fast heuristic versio... | 1,479 | 35.097561 | 141 | py |
federated-boosted-dp-trees | federated-boosted-dp-trees-master/federated_gbdt/core/pure_ldp/frequency_oracles/local_hashing/lh_client.py | import numpy as np
import math
import xxhash
from sys import maxsize
import random
from federated_gbdt.core.pure_ldp.core import FreqOracleClient
# Client-side for local-hashing
# Very loosely based on code by Wang (https://github.com/vvv214/LDP_Protocols/blob/master/olh.py)
class LHClient(FreqOracleClient):
def... | 3,426 | 34.697917 | 142 | py |
federated-boosted-dp-trees | federated-boosted-dp-trees-master/federated_gbdt/core/pure_ldp/frequency_oracles/local_hashing/__init__.py | from .lh_server import LHServer
from .lh_client import LHClient
from .fast_lh_client import FastLHClient
from .fast_lh_server import FastLHServer | 146 | 28.4 | 40 | py |
federated-boosted-dp-trees | federated-boosted-dp-trees-master/federated_gbdt/core/pure_ldp/frequency_oracles/local_hashing/lh_server.py | import math
import xxhash
from federated_gbdt.core.pure_ldp.core import FreqOracleServer
# Server-side for local-hashing
# Loosely based on https://github.com/vvv214/LDP_Protocols/blob/master/olh.py
class LHServer(FreqOracleServer):
def __init__(self, epsilon, d, g=2, use_olh=False, index_mapper=None):
"... | 3,197 | 35.758621 | 141 | py |
federated-boosted-dp-trees | federated-boosted-dp-trees-master/federated_gbdt/core/pure_ldp/frequency_oracles/square_wave/sw_server.py | from federated_gbdt.core.pure_ldp.core import FreqOracleServer
import numpy as np
import math
import scipy
import random
from numba import jit
class SWServer(FreqOracleServer):
def __init__(self, epsilon, d=1024, d_prime=1024, smooth=True, smc=False, index_mapper=None):
super().__init__(epsilon, d=None, i... | 6,944 | 41.607362 | 112 | py |
federated-boosted-dp-trees | federated-boosted-dp-trees-master/federated_gbdt/core/pure_ldp/frequency_oracles/square_wave/sw_client.py | from federated_gbdt.core.pure_ldp.core import FreqOracleClient
import numpy as np
import random
import math
class SWClient(FreqOracleClient):
def __init__(self, epsilon, index_mapper=None):
super().__init__(epsilon=epsilon, d=None, index_mapper=index_mapper)
self.update_params(epsilon, d=None, ind... | 1,251 | 35.823529 | 88 | py |
federated-boosted-dp-trees | federated-boosted-dp-trees-master/federated_gbdt/core/pure_ldp/frequency_oracles/square_wave/__init__.py | from .sw_server import SWServer
from .sw_client import SWClient | 63 | 31 | 31 | py |
federated-boosted-dp-trees | federated-boosted-dp-trees-master/federated_gbdt/core/pure_ldp/frequency_oracles/hybrid_mechanism/hybrid_mech_server.py | from federated_gbdt.core.pure_ldp.core import FreqOracleServer
import numpy as np
class HMServer(FreqOracleServer):
def __init__(self, epsilon, d, index_mapper=None):
super().__init__(epsilon, d, index_mapper=index_mapper)
self.update_params(epsilon, d, index_mapper=index_mapper)
self.aggr... | 1,102 | 33.46875 | 106 | py |
federated-boosted-dp-trees | federated-boosted-dp-trees-master/federated_gbdt/core/pure_ldp/frequency_oracles/hybrid_mechanism/hybrid_mech_client.py | from federated_gbdt.core.pure_ldp.core import FreqOracleClient
import numpy as np
import random
import math
class HMClient(FreqOracleClient):
def __init__(self, epsilon, max, min, index_mapper=None, perturb_type="hybrid"):
super().__init__(epsilon=epsilon, d=None, index_mapper=index_mapper)
self.u... | 3,710 | 38.063158 | 166 | py |
federated-boosted-dp-trees | federated-boosted-dp-trees-master/federated_gbdt/core/pure_ldp/frequency_oracles/hybrid_mechanism/__init__.py | 0 | 0 | 0 | py | |
federated-boosted-dp-trees | federated-boosted-dp-trees-master/federated_gbdt/core/moments_accountant/compute_noise_from_budget_lib.py | # Copyright 2019 The TensorFlow 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... | 3,656 | 40.556818 | 134 | py |
federated-boosted-dp-trees | federated-boosted-dp-trees-master/federated_gbdt/core/moments_accountant/dp_params.py | from federated_gbdt.core.moments_accountant.compute_noise_from_budget_lib import compute_noise
import math
# Sam Comment:
# Method uses the RDP moments accountant which works as follows
# 1) For a fixed eps,delta compute the (alpha, tau)-RDP guarantee of the Gaussian mechanism
# 2) Perform a binary search ... | 4,779 | 53.942529 | 255 | py |
federated-boosted-dp-trees | federated-boosted-dp-trees-master/federated_gbdt/core/moments_accountant/__init__.py | 0 | 0 | 0 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.