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 |
|---|---|---|---|---|---|---|
rllab | rllab-master/rllab/optimizers/lbfgs_optimizer.py | from rllab.misc.ext import compile_function, lazydict, flatten_tensor_variables
from rllab.core.serializable import Serializable
import theano
import scipy.optimize
import time
class LbfgsOptimizer(Serializable):
"""
Performs unconstrained optimization via L-BFGS.
"""
def __init__(self, max_opt_itr=2... | 3,102 | 34.666667 | 114 | py |
rllab | rllab-master/rllab/plotter/__init__.py | from .plotter import *
| 23 | 11 | 22 | py |
rllab | rllab-master/rllab/plotter/plotter.py | import atexit
from queue import Empty
from multiprocessing import Process, Queue
from rllab.sampler.utils import rollout
import numpy as np
__all__ = [
'init_worker',
'init_plot',
'update_plot'
]
process = None
queue = None
def _worker_start():
env = None
policy = None
max_length = None
... | 1,664 | 23.485294 | 94 | py |
rllab | rllab-master/rllab/viskit/core.py | import csv
from rllab.misc import ext
import os
import numpy as np
import base64
import pickle
import json
import itertools
# import ipywidgets
# import IPython.display
# import plotly.offline as po
# import plotly.graph_objs as go
import pdb
def unique(l):
return list(set(l))
def flatten(l):
return [item f... | 10,040 | 32.47 | 119 | py |
rllab | rllab-master/rllab/viskit/__init__.py | __author__ = 'dementrock'
| 26 | 12.5 | 25 | py |
rllab | rllab-master/rllab/viskit/frontend.py |
import sys
sys.path.append('.')
import matplotlib
import os
matplotlib.use('Agg')
import flask # import Flask, render_template, send_from_directory
from rllab.misc.ext import flatten
from rllab.viskit import core
from rllab.misc import ext
import sys
import argparse
import json
import numpy as np
# import threading,... | 25,940 | 43.648881 | 131 | py |
rllab | rllab-master/contrib/__init__.py | 0 | 0 | 0 | py | |
rllab | rllab-master/contrib/alexbeloi/is_sampler.py | from rllab.algos.batch_polopt import BatchSampler
from math import exp, log
from numpy import var
import random
import copy
class ISSampler(BatchSampler):
"""
Sampler which alternates between live sampling iterations using BatchSampler
and importance sampling iterations.
"""
def __init__(
self,... | 6,004 | 33.119318 | 92 | py |
rllab | rllab-master/contrib/alexbeloi/__init__.py | 0 | 0 | 0 | py | |
rllab | rllab-master/contrib/alexbeloi/examples/trpois_cartpole.py | from rllab.algos.trpo import TRPO
from rllab.algos.tnpg import TNPG
from rllab.baselines.linear_feature_baseline import LinearFeatureBaseline
from rllab.envs.box2d.cartpole_env import CartpoleEnv
from rllab.envs.normalized_env import normalize
from rllab.policies.gaussian_mlp_policy import GaussianMLPPolicy
from contri... | 1,096 | 23.931818 | 89 | py |
rllab | rllab-master/contrib/alexbeloi/examples/__init__.py | 0 | 0 | 0 | py | |
rllab | rllab-master/contrib/alexbeloi/examples/vpgis_cartpole.py | from rllab.algos.vpg import VPG
from rllab.baselines.linear_feature_baseline import LinearFeatureBaseline
from rllab.envs.box2d.cartpole_env import CartpoleEnv
from rllab.envs.normalized_env import normalize
from rllab.policies.gaussian_mlp_policy import GaussianMLPPolicy
from contrib.alexbeloi.is_sampler import ISSamp... | 938 | 25.083333 | 89 | py |
rllab | rllab-master/contrib/rllab_hyperopt/core.py | import os
import sys
sys.path.append('.')
import threading
import time
import warnings
import multiprocessing
import importlib
from rllab import config
from rllab.misc.instrument import run_experiment_lite
import polling
from hyperopt import fmin, tpe, STATUS_OK, STATUS_FAIL
from hyperopt.mongoexp import MongoTrials
... | 10,043 | 42.107296 | 144 | py |
rllab | rllab-master/contrib/rllab_hyperopt/__init__.py | 0 | 0 | 0 | py | |
rllab | rllab-master/contrib/rllab_hyperopt/example/main.py | '''
Main module to launch an example hyperopt search on EC2.
Launch this from outside the rllab main dir. Otherwise, rllab will try to ship the logfiles being written by this process,
which will fail because tar doesn't want to tar files that are being written to. Alternatively, disable the packaging of
log files by r... | 2,177 | 57.864865 | 122 | py |
rllab | rllab-master/contrib/rllab_hyperopt/example/score.py | import os
import pandas as pd
from rllab import config
def process_result(exp_prefix, exp_name):
# Open the default rllab path for storing results
result_path = os.path.join(config.LOG_DIR, "s3", exp_prefix, exp_name, 'progress.csv')
print("Processing result from",result_path)
# This example use... | 911 | 38.652174 | 128 | py |
rllab | rllab-master/contrib/rllab_hyperopt/example/task.py | from rllab.algos.trpo import TRPO
from rllab.baselines.linear_feature_baseline import LinearFeatureBaseline
from rllab.envs.box2d.cartpole_env import CartpoleEnv
from rllab.envs.normalized_env import normalize
from rllab.policies.gaussian_mlp_policy import GaussianMLPPolicy
def run_task(v):
env = normalize(Cartpol... | 918 | 29.633333 | 93 | py |
rllab | rllab-master/contrib/rllab_hyperopt/example/__init__.py | 0 | 0 | 0 | py | |
rllab | rllab-master/contrib/bichengcao/__init__.py | 0 | 0 | 0 | py | |
rllab | rllab-master/contrib/bichengcao/examples/trpo_gym_MountainCar-v0.py | # This doesn't work. After 150 iterations still didn't learn anything.
from rllab.algos.trpo import TRPO
from rllab.baselines.linear_feature_baseline import LinearFeatureBaseline
from rllab.envs.gym_env import GymEnv
from rllab.envs.normalized_env import normalize
from rllab.misc.instrument import run_experiment_lite
... | 965 | 22.560976 | 73 | py |
rllab | rllab-master/contrib/bichengcao/examples/trpo_gym_CartPole-v0.py | from rllab.algos.trpo import TRPO
from rllab.baselines.linear_feature_baseline import LinearFeatureBaseline
from rllab.envs.gym_env import GymEnv
from rllab.envs.normalized_env import normalize
from rllab.misc.instrument import run_experiment_lite
from rllab.policies.categorical_mlp_policy import CategoricalMLPPolicy
... | 890 | 21.846154 | 73 | py |
rllab | rllab-master/contrib/bichengcao/examples/trpo_gym_CartPole-v1.py | from rllab.algos.trpo import TRPO
from rllab.baselines.linear_feature_baseline import LinearFeatureBaseline
from rllab.envs.gym_env import GymEnv
from rllab.envs.normalized_env import normalize
from rllab.misc.instrument import run_experiment_lite
from rllab.policies.categorical_mlp_policy import CategoricalMLPPolicy
... | 890 | 21.846154 | 73 | py |
rllab | rllab-master/contrib/bichengcao/examples/trpo_gym_Acrobot-v1.py | from rllab.algos.trpo import TRPO
from rllab.baselines.linear_feature_baseline import LinearFeatureBaseline
from rllab.envs.gym_env import GymEnv
from rllab.envs.normalized_env import normalize
from rllab.misc.instrument import run_experiment_lite
from rllab.policies.categorical_mlp_policy import CategoricalMLPPolicy
... | 889 | 21.820513 | 73 | py |
rllab | rllab-master/contrib/bichengcao/examples/trpo_gym_Pendulum-v0.py | from rllab.algos.trpo import TRPO
from rllab.baselines.linear_feature_baseline import LinearFeatureBaseline
from rllab.envs.gym_env import GymEnv
from rllab.envs.normalized_env import normalize
from rllab.misc.instrument import run_experiment_lite
from rllab.policies.gaussian_mlp_policy import GaussianMLPPolicy
def r... | 881 | 21.615385 | 73 | py |
rllab | rllab-master/contrib/bichengcao/examples/__init__.py | 0 | 0 | 0 | py | |
complex | complex-master/wn18_run.py | #import scipy.io
import efe
from efe.exp_generators import *
import efe.tools as tools
if __name__ =="__main__":
#Load data, ensure that data is at path: 'path'/'name'/[train|valid|test].txt
wn18exp = build_data(name = 'wn18',path = tools.cur_path + '/datasets/')
#SGD hyper-parameters:
params = Parameters(lear... | 2,420 | 42.232143 | 115 | py |
complex | complex-master/fb15k_run.py | #import scipy.io
import efe
from efe.exp_generators import *
import efe.tools as tools
if __name__ =="__main__":
#Load data, ensure that data is at path: 'path'/'name'/[train|valid|test].txt
fb15kexp = build_data(name = 'fb15k',path = tools.cur_path + '/datasets/')
#SGD hyper-parameters:
params = Parameters(le... | 2,332 | 42.203704 | 122 | py |
complex | complex-master/efe/experiment.py | import uuid
import time
import subprocess
import numpy as np
from .tools import *
from .evaluation import *
from . import models
class Experiment(object):
def __init__(self, name, train, valid, test, positives_only = False, compute_ranking_scores = False, entities_dict = None, relations_dict =None) :
"""
An ex... | 4,954 | 33.172414 | 171 | py |
complex | complex-master/efe/tools.py | import sys,os
import logging
import numpy as np
import colorsys
#Current path
cur_path = os.path.dirname(os.path.realpath( os.path.basename(__file__)))
#Logging
logger = logging.getLogger("EFE")
logger.setLevel(logging.DEBUG)
logger.propagate = False
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
formatter... | 2,662 | 31.084337 | 153 | py |
complex | complex-master/efe/batching.py | from .tools import *
class Batch_Loader(object):
def __init__(self, train_triples, n_entities, batch_size=100, neg_ratio = 0.0, contiguous_sampling = False):
self.train_triples = train_triples
self.batch_size = batch_size
self.n_entities = n_entities
self.contiguous_sampling = contiguous_sampling
self.neg_... | 3,033 | 35.119048 | 163 | py |
complex | complex-master/efe/models.py | """
Define all model classes following the definition of Abstract_Model.
"""
import downhill
import theano
import theano.tensor as TT
data_type = 'float32'
#Single precision:
theano.config.floatX = data_type
theano.config.mode = 'FAST_RUN' # 'Mode', 'ProfileMode'(deprecated), 'DebugMode', 'FAST_RUN', 'FAST_COMPILE'
... | 18,636 | 30.481419 | 191 | py |
complex | complex-master/efe/__init__.py | 0 | 0 | 0 | py | |
complex | complex-master/efe/evaluation.py | import operator
import sklearn
import sklearn.metrics
from .tools import *
class Result(object):
"""
Store one test results
"""
def __init__(self, preds, true_vals, ranks, raw_ranks):
self.preds = preds
self.ranks = ranks
self.true_vals = true_vals
self.raw_ranks = raw_ranks
#Test if not all the predi... | 10,160 | 32.314754 | 162 | py |
complex | complex-master/efe/exp_generators.py | import scipy
import scipy.io
import random
from .experiment import *
def parse_line(filename, line,i):
line = line.strip().split("\t")
sub = line[0]
rel = line[1]
obj = line[2]
val = 1
return sub,obj,rel,val
def load_triples_from_txt(filenames, entities_indexes = None, relations_indexes = None, add_sameas_r... | 3,978 | 24.837662 | 167 | py |
wakenet | wakenet-master/Code/turbine_scaling.py | from neuralWake import *
from superposition import *
from synth_and_train import *
from optimisation import *
import synth_and_train as dat
if train_net == 1:
# Plot wake dataset sample
dat.Create(plots=True)
else:
# ------------ Computational time vs Superimposed turbines scaling ------------ #
i... | 2,171 | 22.608696 | 102 | py |
wakenet | wakenet-master/Code/example_main.py | from neuralWake import *
from optimisation import *
import synth_and_train as st
def florisPw(u_stream, tis, xs, ys, yws):
# Initialise FLORIS for initial configuraiton
if curl == True:
fi.floris.farm.set_wake_model("curl")
fi.reinitialize_flow_field(wind_speed=u_stream)
fi.reinitialize_flow_f... | 4,399 | 30.884058 | 105 | py |
wakenet | wakenet-master/Code/packages.py | # Package list
import os
import time
import json
import random
import warnings
import numpy as np
import scipy.stats as stats
from matplotlib import rc
import matplotlib.pyplot as plt
from matplotlib.pyplot import gca
import torch
import torch.nn as nn
import torch.optim as optim
from torch import nn, optim
from tor... | 840 | 21.72973 | 69 | py |
wakenet | wakenet-master/Code/superposition.py | from re import S
from neuralWake import *
from torch import cpu
from CNNWake.FCC_model import *
warnings.filterwarnings("ignore")
# Synth value
if train_net == 0:
# Load model
model = wakeNet().to(device)
model.load_state_dict(torch.load(weights_path, map_location=device))
model.eval().to(device)
# Us... | 19,926 | 37.469112 | 101 | py |
wakenet | wakenet-master/Code/optimisation.py | from superposition import *
import floris
def florisOptimiser(
ws,
ti,
layout_x,
layout_y,
min_yaw=-30,
max_yaw=30,
resx=dimx,
resy=dimy,
plots=False,
mode="yaw",
results=True
):
"""
Calls the Floris optimiser to calculate the optimal yaws of a turbine farm.
Ar... | 20,767 | 29.541176 | 118 | py |
wakenet | wakenet-master/Code/synth_and_train.py | from neuralWake import *
def set_seed(seed):
"""
Use this to set ALL the random seeds to a fixed value and remove randomness from cuda kernels
"""
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
# Uses the inbuilt cudnn auto-tuner to fin... | 15,305 | 31.916129 | 102 | py |
wakenet | wakenet-master/Code/__init__.py | # __init__.py | 13 | 13 | 13 | py |
wakenet | wakenet-master/Code/neuralWake.py | from packages import *
from initialisations import *
class wakeNet(nn.Module):
"""
wakeNet class definition
"""
def __init__(self, inputs=3, hidden_neurons=[100, 200]):
"""
wakeNet initializations
Args:
u_stream (torch float array) Inputs of training step.
... | 12,814 | 32.372396 | 97 | py |
wakenet | wakenet-master/Code/initialisations.py | import numpy as np
from packages import json
from packages import torch
import floris.tools as wfct
from floris.tools import static_class as sc
# Initialisation of variables #
# =======================================================================... | 4,417 | 28.065789 | 100 | py |
wakenet | wakenet-master/Code/CNNWake/FCC_model.py | import torch
import torch.nn as nn
import numpy as np
import random
import floris.tools as wfct
import torch.optim as optim
import matplotlib.pyplot as plt
from torch.utils.data import TensorDataset, DataLoader
from torch.optim import lr_scheduler
__author__ = "Jens Bauer"
__copyright__ = "Copyright 2021, CNNwake"
__c... | 24,254 | 42.467742 | 97 | py |
wakenet | wakenet-master/Code/CNNWake/visualise.py | import torch
import matplotlib.pyplot as plt
import numpy as np
import time
import floris.tools as wfct
from .superposition import super_position
__author__ = "Jens Bauer"
__copyright__ = "Copyright 2021, CNNwake"
__credits__ = ["Jens Bauer"]
__license__ = "MIT"
__version__ = "1.0"
__email__ = "jens.bauer20@imperial.... | 13,979 | 42.6875 | 131 | py |
wakenet | wakenet-master/Code/CNNWake/train_CNN.py | import torch
import torch.nn as nn
import torch.optim as optim
import matplotlib.pyplot as plt
from torch.utils.data import TensorDataset, DataLoader
from torch.optim import lr_scheduler
from .CNN_model import Generator
__author__ = "Jens Bauer"
__copyright__ = "Copyright 2021, CNNwake"
__credits__ = ["Jens Bauer"]
_... | 5,251 | 38.19403 | 78 | py |
wakenet | wakenet-master/Code/CNNWake/train_FCNN.py | import torch
import torch.nn as nn
import torch.optim as optim
import matplotlib.pyplot as plt
from torch.utils.data import TensorDataset, DataLoader
from torch.optim import lr_scheduler
from FCC_model import FCNN
__author__ = "Jens Bauer"
__copyright__ = "Copyright 2021, CNNwake"
__credits__ = ["Jens Bauer"]
__licen... | 5,082 | 38.1 | 79 | py |
wakenet | wakenet-master/Code/CNNWake/superposition.py | import torch
from torch.backends import cudnn
import matplotlib.pyplot as plt
import numpy as np
import time
import floris.tools as wfct
__author__ = "Jens Bauer"
__copyright__ = "Copyright 2021, CNNwake"
__credits__ = ["Jens Bauer"]
__license__ = "MIT"
__version__ = "1.0"
__email__ = "jens.bauer20@imperial.ac.uk"
__s... | 12,291 | 43.375451 | 130 | py |
wakenet | wakenet-master/Code/CNNWake/optimisation.py | from scipy.optimize import minimize
import numpy as np
import torch
import time
import floris.tools as wfct
from .superposition import CNNWake_farm_power, FLORIS_farm_power
from .CNN_model import Generator
from .FCC_model import FCNN
__author__ = "Jens Bauer"
__copyright__ = "Copyright 2021, CNNwake"
__credits__ = ["J... | 8,797 | 42.554455 | 79 | py |
wakenet | wakenet-master/Code/CNNWake/__init__.py | 0 | 0 | 0 | py | |
wakenet | wakenet-master/Code/CNNWake/CNN_model.py | import torch
import torch.nn as nn
import numpy as np
import random
import floris.tools as wfct
__author__ = "Jens Bauer"
__copyright__ = "Copyright 2021, CNNwake"
__credits__ = ["Jens Bauer"]
__license__ = "MIT"
__version__ = "1.0"
__email__ = "jens.bauer20@imperial.ac.uk"
__status__ = "Development"
class Generator... | 14,425 | 42.583082 | 79 | py |
wakenet | wakenet-master/Code/CNNWake/in/__init__.py | from .CNN_model import Generator
from .FCC_model import FCNN
from .superposition import super_position, FLORIS_farm_power, CNNWake_farm_power
from .train_FCNN import train_FCNN_model
from .train_CNN import train_CNN_model
from .visualise import Compare_CNN_FLORIS, visualize_farm
from .optimisation import FLORIS_wake_st... | 349 | 49 | 80 | py |
Enhancement-Coded-Speech | Enhancement-Coded-Speech-master/CepsDomCNN_Train.py | #####################################################################################
# Training the CNN for cepstral domain approach III.
# Input:
# 1- Training input: Train_inputSet_g711.mat
# 2- Training target: Train_targetSet_g711.mat
# 3- Validation input: Validation_inputSet_g711.mat
# 4-... | 6,716 | 35.112903 | 151 | py |
Enhancement-Coded-Speech | Enhancement-Coded-Speech-master/CepsDomCNN_Test.py | #####################################################################################
# Use the trained CNN for cepstral domain approach III.
# Input:
# 1- CNN input: type_3_cnn_input_ceps.mat
# 2- Trained CNN weights: cnn_weights_ceps_g711_best.h5
# Output:
# 1- CNN output: type_3_cnn_output_ceps.mat... | 4,173 | 31.866142 | 151 | py |
kl_sample | kl_sample-master/plot_data.py | import os, sys, fnmatch
import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
from astropy.io import fits
import kl_sample.io as io
import kl_sample.reshape as rsh
import kl_sample.settings as set
data_path = os.path.expanduser("~")+'/data_project/kl_sample/data/data_fourier.fits'
... | 860 | 26.774194 | 84 | py |
kl_sample | kl_sample-master/kl_sample.py | """
kl_sample: a code that sample cosmological parameters using
lensing data (for now CFHTlens). It performs a KL transform
to compress data. There are three main modules:
a - prep_real: prepare data in real space and store them
inside the repository. Once they are there it is no
longer needed to rerun it;
b - ... | 1,429 | 33.878049 | 69 | py |
kl_sample | kl_sample-master/plot_triangles_2pt.py | import numpy as np
from astropy.io import fits
import kl_sample.io as io
io.print_info_fits('/users/groups/damongebellini/kl_sample/data/data_real.fits')
io.print_info_fits('/users/groups/damongebellini/kl_sample/data/data_fourier.fits')
'''
d_r=fits.open("/users/groups/damongebellini/kl_sample/data/data_real.fits")... | 529 | 24.238095 | 83 | py |
kl_sample | kl_sample-master/kl_sample/likelihood.py | """
This module contains all the relevant functions
used to compute the likelihood.
Functions:
- how_many_sims(data, settings)
- select_sims(data, settings)
- compute_kl(cosmo, data, settings)
- apply_kl(kl_t, corr, settings)
- compute_inv_covmat(data, settings)
- lnprior(var, full, mask)
- lnlike(var, full, m... | 9,782 | 27.438953 | 79 | py |
kl_sample | kl_sample-master/kl_sample/prep_fourier.py | """
This module contains the pipeline to prepare data in
fourier space for run. It should be used only once. Then
the data will be stored in the repository.
The only mandatory argument to run this module is the path
of an input folder. It should contain:
- cat_full.fits: full catalogue in fits format
- mask_arcsec_N.... | 59,387 | 36.706667 | 79 | py |
kl_sample | kl_sample-master/kl_sample/settings.py | """
General settings: default variables.
WARNING: if you modify this file you may
have to rerun prep_real.py or prep_fourier.py.
"""
import numpy as np
# Photo-z Bins (minimum, maximum and intermediate bins)
Z_BINS = [0.15, 0.29, 0.43, 0.57, 0.70, 0.90, 1.10, 1.30]
# Z_BINS = [0.5,0.85,1.30]
Z_BINS = np.vstack((Z... | 4,995 | 34.432624 | 79 | py |
kl_sample | kl_sample-master/kl_sample/checks.py | """
This module contains checks that needs to be performed
to ensure that the input is consistent.
Functions:
- unused_params(cosmo, settings, path)
- sanity_checks(cosmo, settings, path)
- kl_consistent(E, S, N, L, eigval, tol)
"""
import re
import sys
import numpy as np
from astropy.io import fits
import kl_sa... | 8,676 | 36.562771 | 79 | py |
kl_sample | kl_sample-master/kl_sample/sampler.py | """
This module contains all the samplers implemented.
Functions:
- run_emcee()
- run_single_point()
"""
import sys
import numpy as np
import emcee
import kl_sample.likelihood as lkl
import kl_sample.cosmo as cosmo_tools
# ------------------- emcee --------------------------------------------------#
def run_em... | 3,731 | 29.096774 | 79 | py |
kl_sample | kl_sample-master/kl_sample/prep_fourier_tools.py | """
This module contains the tools to prepare
data in fourier space.
Functions:
- get_map(w, mask, cat)
"""
import sys
import os
import re
import numpy as np
import pymaster as nmt
import kl_sample.io as io
def get_map(w, mask, cat, pos_in=None):
""" Generate a map from a catalogue, a mask
and a WCS ... | 13,806 | 35.720745 | 79 | py |
kl_sample | kl_sample-master/kl_sample/plots_b.py | import os
import sys
import numpy as np
import matplotlib
# matplotlib.use('Agg')
import matplotlib.pyplot as plt
import kl_sample.io as io
import kl_sample.reshape as rsh
import kl_sample.settings as set
import kl_sample.cosmo as cosmo_tools
def plots(args):
""" Generate plots for the papers.
Args:
... | 6,006 | 36.310559 | 104 | py |
kl_sample | kl_sample-master/kl_sample/cosmo.py | """
Module containing all the relevant functions
to compute and manipulate cosmology.
Functions:
- get_cosmo_mask(params)
- get_cosmo_ccl(params)
- get_cls_ccl(params, cosmo, pz, ell_max)
- get_xipm_ccl(cosmo, cls, theta)
"""
import numpy as np
import pyccl as ccl
import kl_sample.reshape as rsh
import kl_sampl... | 8,962 | 27.453968 | 79 | py |
kl_sample | kl_sample-master/kl_sample/reshape.py | """
This module contains functions to reshape and manipulate
the correlation function and power spectra.
Functions:
- mask_cl(cl)
- unify_fields_cl(cl, sims)
- position_xipm(n, n_bins, n_theta)
- unflatten_xipm(array)
- flatten_xipm(corr, settings)
- mask_xipm(array, mask, settings)
- unmask_xipm(array, mask)
... | 14,672 | 31.973034 | 79 | py |
kl_sample | kl_sample-master/kl_sample/run.py | """
This module contains the main function run, from where
it is possible to run an MCMC (emcee), or evaluate the
likelihood at one single point (single_point).
"""
import numpy as np
import kl_sample.io as io
import kl_sample.cosmo as cosmo_tools
import kl_sample.checks as checks
import kl_sample.likelihood as lkl
... | 8,964 | 39.565611 | 79 | py |
kl_sample | kl_sample-master/kl_sample/get_kl.py | """
This module calculates the KL transform given a fiducial cosmology.
"""
import numpy as np
import kl_sample.io as io
import kl_sample.likelihood as lkl
import kl_sample.reshape as rsh
import kl_sample.settings as set
def get_kl(args):
""" Calculate the KL transform
Args:
args: the arguments re... | 2,480 | 32.986301 | 79 | py |
kl_sample | kl_sample-master/kl_sample/plots.py | import os
import sys
import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import kl_sample.io as io
import kl_sample.reshape as rsh
import kl_sample.settings as set
import kl_sample.cosmo as cosmo_tools
import kl_sample.likelihood as lkl
def plots(args):
""" Generate plots fo... | 7,931 | 36.239437 | 104 | py |
kl_sample | kl_sample-master/kl_sample/__init__.py | 0 | 0 | 0 | py | |
kl_sample | kl_sample-master/kl_sample/prep_real.py | """
This module contains the main function to prepare data in
real space for run. It should be used only once. Then
the data will be stored in the repository.
"""
import os
import numpy as np
import kl_sample.settings as set
import kl_sample.io as io
import kl_sample.reshape as rsh
def prep_real(args):
""" Pre... | 2,061 | 30.723077 | 73 | py |
kl_sample | kl_sample-master/kl_sample/io.py | """
Module containing all the input/output related functions.
Functions:
- argument_parser()
- path_exists_or_error(path)
- path_exists_or_create(path)
- read_param(fname, par, type)
- read_cosmo_array(fname, pars)
- read_from_fits(fname, name)
- read_header_from_fits(fname, name)
- write_to_fits(fname, array... | 16,499 | 31.608696 | 79 | py |
kl_sample | kl_sample-master/fourier_analysis/maps2cls.py | from __future__ import print_function
import numpy as np
import matplotlib.pyplot as plt
import astropy.io.fits as fits
import pymaster as nmt
import flatmaps as fm
from optparse import OptionParser
def opt_callback(option, opt, value, parser):
setattr(parser.values, option.dest, value.split(','))
parser = OptionPa... | 3,271 | 35.764045 | 99 | py |
kl_sample | kl_sample-master/fourier_analysis/flatmaps.py | from __future__ import print_function
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
import pymaster as nmt
from astropy.io import fits
from astropy.wcs import WCS
class FlatMapInfo(object) :
def __init__(self,wcs,nx=None,ny=None,lx=None,ly=None) :
"""
Creates a flat m... | 15,536 | 34.799539 | 122 | py |
ilmart | ilmart-main/src/__init__.py | 0 | 0 | 0 | py | |
ilmart | ilmart-main/src/ilmart/ilmart_distill.py | import itertools
import numpy as np
from collections import defaultdict
import lightgbm as lgbm
class IlmartDistill:
def __init__(self, model: lgbm.Booster, distill_mode="full", n_sample=None):
self.model = model
self.feat_name_to_index = {feat: i for i, feat in enumerate(self.model.dump_model()[... | 7,538 | 47.019108 | 119 | py |
ilmart | ilmart-main/src/ilmart/utils.py | from collections import defaultdict
import os
from rankeval.dataset.dataset import Dataset as RankEvalDataset
from rankeval.dataset.datasets_fetcher import load_dataset
from tqdm import tqdm
DATA_HOME = os.environ.get('RANKEVAL_DATA', os.path.join('~', 'rankeval_data'))
DATA_HOME = os.path.expanduser(DATA_HOME)
DICT... | 2,681 | 35.243243 | 102 | py |
ilmart | ilmart-main/src/ilmart/__init__.py | from .ilmart_distill import IlmartDistill
from .ilmart import Ilmart
| 69 | 22.333333 | 41 | py |
ilmart | ilmart-main/src/ilmart/ilmart.py | import lightgbm as lgbm
import rankeval
from .ilmart_distill import IlmartDistill
from .utils import is_interpretable
class Ilmart():
def __init__(self, verbose, feat_inter_boosting_rounds=2000, inter_rank_strategy="greedy"):
self.verbose = verbose
self._model_main_effects = None
self._mo... | 7,560 | 42.454023 | 116 | py |
ilmart | ilmart-main/experiments/download_files.py | import requests
from tqdm import tqdm
import math
import zipfile
import os.path
def convert_size(size_bytes: int):
if size_bytes == 0:
return "0B"
size_name = ("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB")
i = int(math.floor(math.log(size_bytes, 1024)))
p = math.pow(1024, i)
s = rou... | 1,857 | 27.584615 | 79 | py |
ilmart | ilmart-main/experiments/ilmart/ilmart_evaluate.py | #!/usr/bin/env python
# coding: utf-8
from pathlib import Path
import lightgbm as lgbm
import argparse
import json
import pickle
from collections import defaultdict
from ilmart.utils import load_datasets, is_interpretable
from rankeval.metrics import NDCG
def evaluate(models_dir, rankeval_datasets, path_out):
bo... | 2,327 | 33.235294 | 117 | py |
ilmart | ilmart-main/experiments/ilmart/ilmart_train.py | #!/usr/bin/env python
# coding: utf-8
import typing
import argparse
import rankeval.dataset
import json
from ilmart.utils import load_datasets
from pathlib import Path
from tqdm import tqdm
from sklearn.model_selection import ParameterGrid
from ilmart import Ilmart
from rankeval.metrics import NDCG
def hyperparams_gr... | 4,762 | 42.3 | 129 | py |
ilmart | ilmart-main/experiments/ebm/ebm_train.py | #!/usr/bin/env python
# coding: utf-8
import pickle
import argparse
from ilmart.utils import load_datasets
import json
from interpret.glassbox import ExplainableBoostingRegressor
from rankeval.metrics import NDCG
from pathlib import Path
from tqdm import tqdm
def train(rankeval_datasets, outerbags, models_dir, n_inte... | 4,480 | 36.974576 | 117 | py |
ilmart | ilmart-main/experiments/ebm/ebm_evaluate.py | from pathlib import Path
from rankeval.metrics import NDCG
from ilmart.utils import load_datasets
import argparse
import pickle
import json
def evaluate_and_save(models_dict, rankeval_datasets, file_out):
cutoffs = [1, 5, 10]
ndcgs_ebm = {}
for name, model in models_dict.items():
print(f"Evaluat... | 2,479 | 34.428571 | 118 | py |
ilmart | ilmart-main/experiments/nrgam/nrgam_evaluate.py | #!/usr/bin/env python
# coding: utf-8
import tensorflow as tf
import tensorflow_datasets as tfds
import tensorflow_ranking as tfr
import pickle
import argparse
from tqdm import tqdm
from rankeval.metrics.ndcg import NDCG
from collections import defaultdict
import yahoo_dataset
import numpy as np
DATASET_DICT = {
... | 3,771 | 34.92381 | 118 | py |
ilmart | ilmart-main/experiments/nrgam/nrgam_train.py | import tensorflow as tf
import tensorflow_datasets as tfds
import tensorflow_ranking as tfr
import argparse
import pickle
from pathlib import Path
tf.config.threading.set_inter_op_parallelism_threads(40)
tf.config.threading.set_intra_op_parallelism_threads(40)
DATSET_DICT = {
"mslr_web/30k_fold1": "web30k",
"... | 5,534 | 39.698529 | 118 | py |
ilmart | ilmart-main/experiments/nrgam/yahoo_dataset/yahoo_test.py | """yahoo dataset."""
import tensorflow_datasets as tfds
from . import yahoo
class YahooTest(tfds.testing.DatasetBuilderTestCase):
"""Tests for yahoo dataset."""
# TODO(yahoo):
DATASET_CLASS = yahoo.Yahoo
SPLITS = {
'train': 3, # Number of fake train example
'test': 1, # Number of fake test exam... | 688 | 26.56 | 73 | py |
ilmart | ilmart-main/experiments/nrgam/yahoo_dataset/yahoo.py | """yahoo dataset."""
import tensorflow_datasets as tfds
import tensorflow as tf
from tensorflow_datasets.ranking.libsvm_ranking_parser import LibSVMRankingParser
import os
"""
The dataset cannot be shared online due to license constraint, so the download phase is skipped and the data will be
loaded from the folder ... | 3,718 | 35.460784 | 119 | py |
ilmart | ilmart-main/experiments/nrgam/yahoo_dataset/__init__.py | """yahoo dataset."""
from .yahoo import Yahoo
| 47 | 11 | 24 | py |
ilmart | ilmart-main/experiments/lmart/lmart_full.py | from pathlib import Path
import numpy as np
import lightgbm as lgbm
from tqdm import tqdm
from rankeval.metrics import NDCG
from sklearn.model_selection import ParameterGrid
from ilmart.utils import load_datasets
def fine_tuning(train_lgbm, vali_lgbm, common_params, param_grid, verbose=True):
param_grid_list = li... | 3,335 | 34.489362 | 107 | py |
pytorch-darknet19 | pytorch-darknet19-master/demo/darknet19_demo.py | import numpy as np
import torch
import torchvision.datasets as dset
import torchvision.transforms as transforms
import matplotlib.pyplot as plt
from model import darknet
def main():
imageNet_label = [line.strip() for line in open("demo/imagenet.shortnames.list", 'r')]
dataset = dset.ImageFolder(root="demo/sam... | 995 | 31.129032 | 90 | py |
pytorch-darknet19 | pytorch-darknet19-master/base/base_model.py | import logging
import torch.nn as nn
import numpy as np
class BaseModel(nn.Module):
"""
Base class for all models
"""
def __init__(self):
super(BaseModel, self).__init__()
self.logger = logging.getLogger(self.__class__.__name__)
def forward(self, *input):
"""
Forwa... | 1,076 | 26.615385 | 93 | py |
pytorch-darknet19 | pytorch-darknet19-master/base/__init__.py | from .base_model import *
| 27 | 8.333333 | 25 | py |
pytorch-darknet19 | pytorch-darknet19-master/model/darknet.py | from collections import OrderedDict
from torch import nn
import torch.nn.functional as F
import torch.utils.model_zoo as model_zoo
from base import BaseModel
model_paths = {
'darknet19': 'https://s3.ap-northeast-2.amazonaws.com/deepbaksuvision/darknet19-deepBakSu-e1b3ec1e.pth'
}
class GlobalAvgPool2d(nn.Module):
... | 5,509 | 46.094017 | 107 | py |
RBNN | RBNN-master/imagenet/main.py | import argparse
import os
import time
import logging
import random
import torch
import torch.nn as nn
import torch.backends.cudnn as cudnn
import models_cifar
import models_imagenet
import numpy as np
from torch.autograd import Variable
from utils.options import args
from utils.common import *
from modules import *
fro... | 17,019 | 40.111111 | 161 | py |
RBNN | RBNN-master/imagenet/modules/binarized_modules.py | import torch
import torch.nn as nn
import math
import numpy as np
import torch.nn.functional as F
from torch.autograd import Function, Variable
from scipy.stats import ortho_group
from utils.options import args
class BinarizeConv2d(nn.Conv2d):
def __init__(self, *kargs, **kwargs):
super(BinarizeConv2d, se... | 3,835 | 34.518519 | 101 | py |
RBNN | RBNN-master/imagenet/modules/__init__.py | from .binarized_modules import * | 32 | 32 | 32 | py |
RBNN | RBNN-master/imagenet/dataset/dataset.py | from datetime import datetime
import os
import torch
from torch import nn
import torch.nn.functional as F
from torchvision import transforms, datasets
from torch.utils.data import DataLoader
def load_data(type='both',dataset='cifar10',data_path='/data',batch_size = 256,batch_size_test=256,num_workers=0):
# load da... | 3,858 | 37.59 | 134 | py |
RBNN | RBNN-master/imagenet/dataset/__init__.py | from .dataset import load_data, add_module_fromdict
from .imagenet import get_imagenet_iter_dali as get_imagenet
from .imagenet import get_imagenet_iter_torch as get_imagenet_torch | 180 | 59.333333 | 67 | py |
RBNN | RBNN-master/imagenet/dataset/imagenet.py | import time
import torch.utils.data
import nvidia.dali.ops as ops
import nvidia.dali.types as types
import torchvision.datasets as datasets
from nvidia.dali.pipeline import Pipeline
import torchvision.transforms as transforms
from nvidia.dali.plugin.pytorch import DALIClassificationIterator, DALIGenericIterator
class... | 6,531 | 51.677419 | 131 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.