python_code stringlengths 0 83.2k |
|---|
import ctypes as ct
import os
import torch
from pathlib import Path
from warnings import warn
from bitsandbytes.cuda_setup.main import CUDASetup
setup = CUDASetup.get_instance()
if setup.initialized != True:
setup.run_cuda_setup()
if 'BITSANDBYTES_NOWELCOME' not in os.environ or str(os.environ['BITSANDBYTES... |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from . import cuda_setup, utils
from .autograd._functions import (
MatmulLtState,
bmm_cublas,
matmul,
matmul_cublas,
mm_cu... |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import ctypes as ct
import itertools
import operator
import random
import torch
import itertools
import math
from functools import reduce # R... |
import shlex
import subprocess
from typing import Tuple
def execute_and_return(command_string: str) -> Tuple[str, str]:
def _decode(subprocess_err_out_tuple):
return tuple(
to_decode.decode("UTF-8").strip()
for to_decode in subprocess_err_out_tuple
)
def execute_and_re... |
import os
import sys
from warnings import warn
import torch
HEADER_WIDTH = 60
def print_header(
txt: str, width: int = HEADER_WIDTH, filler: str = "+"
) -> None:
txt = f" {txt} " if txt else ""
print(txt.center(width, filler))
def print_debug_info() -> None:
print(
"\nAbove we output some ... |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from .modules import Int8Params, Linear8bitLt, StableEmbedding
|
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from typing import Optional, TypeVar, Union, overload
import torch
import torch.nn.functional as F
from torch import Tensor, device, dtype, nn... |
import operator
import warnings
from dataclasses import dataclass
from functools import reduce # Required in Python 3
from typing import Tuple, Optional
import torch
import bitsandbytes.functional as F
# math.prod not compatible with python < 3.8
def prod(iterable):
return reduce(operator.mul, iterable, 1)
te... |
from ._functions import undo_layout, get_inverse_transform_indices
|
import os
from typing import Dict
def to_be_ignored(env_var: str, value: str) -> bool:
ignorable = {
"PWD", # PWD: this is how the shell keeps track of the current working dir
"OLDPWD",
"SSH_AUTH_SOCK", # SSH stuff, therefore unrelated
"SSH_TTY",
"HOME", # Linux shell de... |
"""
extract factors the build is dependent on:
[X] compute capability
[ ] TODO: Q - What if we have multiple GPUs of different makes?
- CUDA version
- Software:
- CPU-only: only CPU quantization functions (no optimizer, no matrix multipl)
- CuBLAS-LT: full-build 8-bit optimizer
- no CuBLAS-LT: no 8-bit ... |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from bitsandbytes.optim.optimizer import Optimizer1State
class RMSprop(Optimizer1State):
def __init__(
self,
params,
... |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from bitsandbytes.optim.optimizer import Optimizer1State
class Lion(Optimizer1State):
def __init__(
self,
params,
... |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from bitsandbytes.optim.optimizer import Optimizer2State
class LAMB(Optimizer2State):
def __init__(
self,
params,
... |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from bitsandbytes.optim.optimizer import Optimizer1State
class SGD(Optimizer1State):
def __init__(
self,
params,
... |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
from torch.optim import Optimizer
from bitsandbytes.optim.optimizer import Optimizer1State
class LARS(Optimizer1State):
def... |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from bitsandbytes.cextension import COMPILED_WITH_CUDA
from .adagrad import Adagrad, Adagrad8bit, Adagrad32bit
from .adam import Adam, Adam8b... |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from bitsandbytes.optim.optimizer import Optimizer1State
class Adagrad(Optimizer1State):
def __init__(
self,
params,
... |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from bitsandbytes.optim.optimizer import Optimizer2State
class AdamW(Optimizer2State):
def __init__(
self,
params,
... |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import math
import os
import torch
import torch.distributed as dist
import bitsandbytes.functional as F
from bitsandbytes.optim.optimizer im... |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from collections import abc as container_abcs
from collections import defaultdict
from copy import deepcopy
from itertools import chain
import... |
from anymal_belief_state_encoder_decoder_pytorch.networks import Student, Teacher, MLP, Anymal
from anymal_belief_state_encoder_decoder_pytorch.ppo import PPO, MockEnv
|
import torch
from torch import nn
import torch.nn.functional as F
from torch.nn import GRUCell
from torch.distributions import Categorical
from torch.optim import Adam
from einops import rearrange
from einops_exts import check_shape
from einops.layers.torch import Rearrange
from anymal_belief_state_encoder_decoder_py... |
import torch
from torch import nn
from torch.utils.data import Dataset, DataLoader
from torch.optim import Adam
from collections import deque
from einops import rearrange
from anymal_belief_state_encoder_decoder_pytorch import Anymal
class ExperienceDataset(Dataset):
def __init__(self, data):
super().__i... |
from collections import namedtuple, deque
import torch
from torch import nn
from torch.utils.data import Dataset, DataLoader
from torch.optim import Adam
from anymal_belief_state_encoder_decoder_pytorch import Anymal
from anymal_belief_state_encoder_decoder_pytorch.networks import unfreeze_all_layers_
from einops im... |
import torch
from torch import nn
class RunningStats(nn.Module):
def __init__(self, shape, eps = 1e-5):
super().__init__()
shape = shape if isinstance(shape, tuple) else (shape,)
self.shape = shape
self.eps = eps
self.n = 0
self.register_buffer('old_mean', torch.ze... |
from bottleneck_transformer_pytorch.bottleneck_transformer_pytorch import BottleStack, BottleBlock
|
import math
import torch
from torch import nn, einsum
from einops import rearrange
# translated from tensorflow code
# https://gist.github.com/aravindsrinivas/56359b79f0ce4449bcb04ab4b56a57a2
# positional embedding helpers
def pair(x):
return (x, x) if not isinstance(x, tuple) else x
def expand_dim(t, dim, k):... |
import gzip
import random
import tqdm
import numpy as np
import torch
from torch.optim import Adam
from torch.nn import functional as F
from torch.utils.data import DataLoader, Dataset
from accelerate import Accelerator
from block_recurrent_transformer_pytorch import BlockRecurrentTransformer, RecurrentTrainerWrapper... |
import torch
from packaging import version
if version.parse(torch.__version__) >= version.parse('2.0.0'):
from einops._torch_specific import allow_ops_in_compiled_graph
allow_ops_in_compiled_graph()
from block_recurrent_transformer_pytorch.block_recurrent_transformer_pytorch import BlockRecurrentTransformer, ... |
import math
from random import random
from functools import wraps, partial
from itertools import zip_longest
from collections import namedtuple, defaultdict
from packaging import version
import torch
import torch.nn.functional as F
from torch import nn, einsum
from einops import rearrange, repeat, pack, unpack
from ... |
import math
import torch
from torch.optim import Optimizer
def exists(val):
return val is not None
class Adan(Optimizer):
def __init__(
self,
params,
lr = 1e-3,
betas = (0.02, 0.08, 0.01),
eps = 1e-8,
weight_decay = 0,
restart_cond: callable = None
)... |
from adan_pytorch.adan import Adan
|
import torch
from torch import nn
from einops import rearrange
from torch import einsum
def exists(val):
return val is not None
def default(val, d):
return val if exists(val) else d
def stable_softmax(t, dim = -1):
t = t - t.amax(dim = dim, keepdim = True)
return t.softmax(dim = dim)
# bidirectional... |
from bidirectional_cross_attention.bidirectional_cross_attention import BidirectionalCrossAttention
|
from byol_pytorch.byol_pytorch import BYOL
|
import copy
import random
from functools import wraps
import torch
from torch import nn
import torch.nn.functional as F
from torchvision import transforms as T
# helper functions
def default(val, def_val):
return def_val if val is None else val
def flatten(t):
return t.reshape(t.shape[0], -1)
def singleto... |
import os
import argparse
import multiprocessing
from pathlib import Path
from PIL import Image
import torch
from torchvision import models, transforms
from torch.utils.data import DataLoader, Dataset
from byol_pytorch import BYOL
import pytorch_lightning as pl
# test model, a resnet 50
resnet = models.resnet50(pre... |
from all_normalization_transformer import TransformerLM
from all_normalization_transformer.autoregressive_wrapper import AutoregressiveWrapper
import random
import tqdm
import gzip
import numpy as np
import torch
import torch.optim as optim
from torch.nn import functional as F
from torch.utils.data import DataLoader, ... |
from functools import partial
import torch
import random
from torch import nn
import torch.nn.functional as F
from torch.nn.utils.rnn import pad_sequence
def default(value, default):
return value if value is not None else default
def log(t, eps=1e-9):
return torch.log(t + eps)
def top_p(logits, thres = 0.9):... |
import torch
from torch import nn
import torch.nn.functional as F
from einops import rearrange
# helpers
def cum_mean(t):
device = t.device
running_num = torch.arange(t.shape[-1], device=t.device) + 1
return t.cumsum(dim=-1) / running_num
def normalize(t, eps=1e-8):
t -= t.mean(dim=-1, keepdim=True)
... |
from all_normalization_transformer.all_normalization_transformer import TransformerLM
from all_normalization_transformer.autoregressive_wrapper import AutoregressiveWrapper
|
__version__ = '1.4.1'
|
import torch
import transformers
from transformers import T5Tokenizer, T5EncoderModel, T5Config
from beartype import beartype
from beartype.typing import Union, List
# less warning messages since only using encoder
transformers.logging.set_verbosity_error()
# helper functions
def exists(val):
return val is not... |
from pathlib import Path
import torch
from torch import nn, einsum
from torchaudio.functional import resample
from einops import rearrange, repeat, pack, unpack
from audiolm_pytorch.utils import curtail_to_multiple
# suppress a few warnings
def noop(*args, **kwargs):
pass
import warnings
import logging
logg... |
import torch
from packaging import version
if version.parse(torch.__version__) >= version.parse('2.0.0'):
from einops._torch_specific import allow_ops_in_compiled_graph
allow_ops_in_compiled_graph()
from audiolm_pytorch.audiolm_pytorch import AudioLM
from audiolm_pytorch.soundstream import SoundStream, AudioL... |
import functools
from itertools import cycle
from pathlib import Path
from functools import partial, wraps
from itertools import zip_longest
from typing import Optional
import torch
from torch import nn, einsum
from torch.autograd import grad as torch_grad
import torch.nn.functional as F
from torch.linalg import vect... |
import torch
from torch import nn, einsum
import torch.nn.functional as F
from collections import namedtuple
from functools import wraps
from packaging import version
from einops import rearrange
# constants
Config = namedtuple('Config', ['enable_flash', 'enable_math', 'enable_mem_efficient'])
# helpers
def exist... |
from torch import nn
# functions
def round_down_nearest_multiple(num, divisor):
return num // divisor * divisor
def curtail_to_multiple(t, mult, from_left = False):
data_len = t.shape[-1]
rounded_seq_len = round_down_nearest_multiple(data_len, mult)
seq_slice = slice(None, rounded_seq_len) if not fro... |
from pathlib import Path
import torch
from torch import nn
from einops import rearrange
import fairseq
from torchaudio.functional import resample
from audiolm_pytorch.utils import curtail_to_multiple
import logging
logging.root.setLevel(logging.ERROR)
def exists(val):
return val is not None
class FairseqVQWa... |
from lion_pytorch import Lion
from torch.optim import AdamW, Adam
def separate_weight_decayable_params(params):
wd_params, no_wd_params = [], []
for param in params:
param_list = no_wd_params if param.ndim < 2 else wd_params
param_list.append(param)
return wd_params, no_wd_params
def get_o... |
import math
from functools import partial, wraps
from beartype.typing import Optional, Union, List
from beartype import beartype
import torch
from torch import nn, einsum, Tensor
from torch.autograd import grad as torch_grad
import torch.nn.functional as F
from torch.nn.utils.rnn import pad_sequence
import torchaudi... |
import re
from math import sqrt
import copy
from random import choice
from pathlib import Path
from shutil import rmtree
from collections import Counter
from beartype.typing import Union, List, Optional, Tuple
from typing_extensions import Annotated
from beartype import beartype
from beartype.door import is_bearable
... |
from functools import reduce
from einops import rearrange, pack, unpack
import torch
from torch import nn
from torchaudio.functional import resample
from vector_quantize_pytorch import ResidualVQ
from encodec import EncodecModel
from encodec.utils import _linear_overlap_add
# helper functions
def exists(val):
... |
from pathlib import Path
from functools import partial, wraps
from beartype import beartype
from beartype.typing import Tuple, Union, Optional
from beartype.door import is_bearable
import torchaudio
from torchaudio.functional import resample
import torch
import torch.nn.functional as F
from torch.nn.utils.rnn import... |
# standard imports
import os
import sys
import pickle
# non-standard imports
import numpy as np
from sklearn import svm
from sqlite3 import dbapi2 as sqlite3
# local imports
from utils import safe_pickle_dump, strip_version, Config
num_recommendations = 500 # papers to recommend per user
# ----------------------------... |
"""
Very simple script that simply iterates over all files data/pdf/f.pdf
and create a file data/txt/f.pdf.txt that contains the raw text, extracted
using the "pdftotext" command. If a pdf cannot be converted, this
script will not produce the output file.
"""
import os
import sys
import time
import shutil
import pickl... |
import os
import json
import time
import pickle
import dateutil.parser
import argparse
from random import shuffle
import numpy as np
from sqlite3 import dbapi2 as sqlite3
from hashlib import md5
from flask import Flask, request, session, url_for, redirect, \
render_template, abort, g, flash, _app_ctx_stack
from f... |
"""
Queries arxiv API and downloads papers (the query is a parameter).
The script is intended to enrich an existing database pickle (by default db.p),
so this file will be loaded first, and then new results will be added to it.
"""
import os
import time
import pickle
import random
import argparse
import urllib.request... |
"""
Use imagemagick to convert all pfds to a sequence of thumbnail images
requires: sudo apt-get install imagemagick
"""
import os
import time
import shutil
from subprocess import Popen
from utils import Config
# make sure imagemagick is installed
if not shutil.which('convert'): # shutil.which needs Python 3.3+
pr... |
from contextlib import contextmanager
import os
import re
import pickle
import tempfile
# global settings
# -----------------------------------------------------------------------------
class Config(object):
# main paper information repo file
db_path = 'db.p'
# intermediate processing folders
pdf_dir ... |
import re
import pytz
import time
import pickle
import datetime
from dateutil import parser
import twitter # pip install python-twitter
from utils import Config, safe_pickle_dump
sleep_time = 60*10 # in seconds
max_days_keep = 5 # max number of days to keep a tweet in memory
def get_db_pids():
print('loading the ... |
import os
import time
import pickle
import shutil
import random
from urllib.request import urlopen
from utils import Config
timeout_secs = 10 # after this many seconds we give up on a paper
if not os.path.exists(Config.pdf_dir): os.makedirs(Config.pdf_dir)
have = set(os.listdir(Config.pdf_dir)) # get list of all pdf... |
"""
Reads txt files of all papers and computes tfidf vectors for all papers.
Dumps results to file tfidf.p
"""
import os
import pickle
from random import shuffle, seed
import numpy as np
from sklearn.feature_extraction.text import TfidfVectorizer
from utils import Config, safe_pickle_dump
seed(1337)
max_train = 1000... |
# Version: 0.19
"""The Versioneer - like a rocketeer, but for versions.
The Versioneer
==============
* like a rocketeer, but for versions!
* https://github.com/python-versioneer/python-versioneer
* Brian Warner
* License: Public Domain
* Compatible with: Python 3.6, 3.7, 3.8, 3.9 and pypy3
* [![Latest Version][pypi... |
import urllib
import pandas as pd
import numpy as np
import re
import sys
import os
from loguru import logger
import ananse
logger.remove()
logger.add(
sys.stderr, format="<green>{time:YYYY-MM-DD HH:mm:ss}</green> | {level} | {message}"
)
TFP_URL = "https://maayanlab.cloud/Enrichr/geneSetLibrary?mode=text&librar... |
# This file helps to compute a version number in source trees obtained from
# git-archive tarball (such as those provided by githubs download-from-tag
# feature). Distribution tarballs (built by setup.py sdist) and build
# directories (produced by setup.py build) will contain a much shorter file
# that just contains th... |
from glob import glob
import inspect
import os
import re
import sys
from tempfile import NamedTemporaryFile
from fluff.fluffio import load_heatmap_data
from genomepy import Genome
from gimmemotifs.motif import read_motifs
from gimmemotifs.scanner import scan_regionfile_to_table
from gimmemotifs.moap import moap
import... |
from ._version import get_versions
import os
import sys
from loguru import logger
# Remove default logger
logger.remove()
# Add logger
logger.add(sys.stderr, format="{time} | {level} | {message}", level="INFO")
# This is here to prevent very high memory usage on numpy import.
# On a machine with many cores, just impo... |
#!/usr/bin/env python
# Copyright (c) 2009-2019 Quan Xu <qxuchn@gmail.com>
#
# This module is free software. You can redistribute it and/or modify it under
# the terms of the MIT License, see the file COPYING included with this
# distribution.
"""Predict TF influence score"""
# Python imports
from __future__ import ... |
import os.path
import numpy as np
import pandas as pd
from scipy import stats
from ananse.utils import cleanpath
class Distributions:
def __init__(self):
# dist_functions = [f for f in dir(ananse.distributions) if f.endswith("_dist")]
dist_functions = [
scale_dist,
log_sc... |
import atexit
import getpass
import os
import pwd
import shutil
import subprocess as sp
import tempfile
import warnings
import genomepy.utils
from pybedtools import BedTool
import pysam
import pandas as pd
def check_path(arg, error_missing=True):
"""Expand all paths. Can check for existence."""
if arg is Non... |
#!/usr/bin/env python
# Copyright (c) 2009-2019 Quan Xu <qxuchn@gmail.com>
#
# This module is free software. You can redistribute it and/or modify it under
# the terms of the MIT License, see the file COPYING included with this
# distribution.
"""Build gene regulatory network"""
# Python imports
import os
import mat... |
import multiprocessing as mp
import os
import tempfile
import shutil
import dask.dataframe as dd
import dask.diagnostics
import genomepy
from gimmemotifs.scanner import scan_regionfile_to_table
from gimmemotifs.utils import pfmfile_location
from loguru import logger
import numpy as np
import pandas as pd
import pickle... |
from ananse.commands.binding import binding # noqa
from ananse.commands.influence import influence # noqa
from ananse.commands.network import network # noqa
from ananse.commands.view import view # noqa
|
#!/usr/bin/env python
# Copyright (c) 2009-2019 Quan Xu <qxuchn@gmail.com>
#
# This module is free software. You can redistribute it and/or modify it under
# the terms of the MIT License, see the file COPYING included with this
# distribution.
from __future__ import print_function
import ananse.influence
from ananse.... |
#!/usr/bin/env python
# Copyright (c) 2021 Simon van Heeringen
#
# This module is free software. You can redistribute it and/or modify it under
# the terms of the MIT License, see the file COPYING included with this
# distribution.
from ananse.utils import view_h5
import sys
def view(args):
df = view_h5(args.infil... |
#!/usr/bin/env python
# Copyright (c) 2009-2019 Quan Xu <qxuchn@gmail.com>
#
# This module is free software. You can redistribute it and/or modify it under
# the terms of the MIT License, see the file COPYING included with this
# distribution.
from __future__ import print_function
import os
import ananse.network
from... |
#!/usr/bin/env python
# Copyright (c) 2009-2019 Quan Xu <qxuchn@gmail.com>
#
# This module is free software. You can redistribute it and/or modify it under
# the terms of the MIT License, see the file COPYING included with this
# distribution.
from ananse.peakpredictor import predict_peaks
from ananse.utils import chec... |
import os
import genomepy.utils
from loguru import logger
from ananse.enhancer_binding import (
CombineBedFiles,
ScorePeaks,
ScoreMotifs,
Binding,
)
from ananse.utils import clean_tmp
@logger.catch
def run_binding(
genome,
peakfiles,
bams,
outdir,
peak_width=200,
dist_func="p... |
import numpy as np
import pytest
import ananse.distributions
def test_distributions():
d = ananse.distributions.Distributions()
func_list = d.get()
assert isinstance(func_list, list)
for func in func_list:
d.set(func)
scores = np.array([0, 1, 2])
def test_scale_dist():
s = ananse.dis... |
from collections import namedtuple
from tempfile import NamedTemporaryFile
import numpy as np
import pytest
import pandas as pd
from ananse.network import Network
from ananse.commands import network
@pytest.fixture
def binding_fname():
return "tests/example_data/binding2.tsv"
@pytest.fixture
def network_obj()... |
from ananse.influence import read_expression
def test_read_expression():
res = read_expression("tests/data/dge.tsv")
assert set(res.keys()) == {"ANPEP", "CD24", "COL6A3", "DAB2", "DMKN"}
assert res["ANPEP"].score - 7.44242618323665 < 0.001
assert res["ANPEP"].realfc - 7.44242618323665 < 0.001
asse... |
import subprocess as sp
# run tests locally with:
# pytest -vv --disable-pytest-warnings
# pytest -vv --disable-pytest-warnings tests/continuous_integration/test_01*
# pytest -vv --disable-pytest-warnings -k [substring]
# TODO: apply to all code --> targets = ["ananse/", "tests/"]
targets = [
"ananse/commands/__i... |
import os
import genomepy.utils
import pytest
import ananse.enhancer_binding
from ananse.commands.enhancer_binding import run_binding
import ananse.utils
from .test_02_utils import write_file, write_bam, h0, h1, line1, line2, line3
# prep
test_dir = os.path.dirname(os.path.dirname(__file__))
outdir = os.path.join(t... |
import os
import tempfile
import time
import genomepy.utils
import pysam
import ananse.utils
# prep
test_dir = os.path.dirname(os.path.dirname(__file__))
outdir = os.path.join(test_dir, "output")
genomepy.utils.mkdir_p(outdir)
def write_file(filename, lines):
with open(filename, "w") as f:
for line in... |
# source:
# https://stackoverflow.com/questions/6620471/fitting-empirical-distribution-to-theoretical-ones-with-scipy-python
import warnings
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
import scipy.stats as st
from tqdm import tqdm
mpl.rcParams["figure.figsize"] = ... |
import os
# import numpy as np
import pandas as pd
import seaborn as sns
def distplot(infile, score_col=4, show=False):
"""
generate simple distplot from bedfile
"""
# https://stackoverflow.com/questions/18534562/scipy-lognormal-fitting
# https://stackoverflow.com/questions/41940726/scipy-lognorm... |
import os
import genomepy.utils
from ananse.enhancer_binding import (
CombineBedFiles,
ScorePeaks,
ScoreMotifs,
Binding,
)
from tests.benchmark.utils import distplot
# prep
run_gimme = False # takes ages
test_dir = os.path.dirname(os.path.dirname(__file__))
data_dir = os.path.join(test_dir, "data"... |
#!/usr/bin/env python
# TODO maybe have sklearn transforms for dot prod and Lp dists
# TODO add L1 distance
from . import bolt # inner bolt because of SWIG
import kmc2 # state-of-the-art kmeans initialization (as of NIPS 2016)
import numpy as np
from sklearn import cluster, exceptions
# =========================... |
#!/usr/bin/env python
# note that we import module generate py file, not the generated
# wrapper so (which is _bolt)
from .bolt_api import * # noqa
|
#!/usr/bin/env python
# from future import absolute_import, division, print_function
import os
import numpy as np
# import pathlib as pl
from sklearn import linear_model
from scipy import signal
from python.datasets import caltech, sharee, incart, ucr
from python import misc_algorithms as algo
from python import win... |
#!/bin/env python
import numpy as np
import matplotlib.pyplot as plt
def main():
UNDEFINED = 7
M = 40000
# M = 500
# M = 2
# K = 16
# C = 64
try_Cs = np.array([2, 4, 8, 16, 32, 64, 128])
try_Us = np.array([2, 4, 8, 16, 32, 64, 128])
biases = np.zeros((try_Cs.size, try_Us.size))... |
#!/bin/env/python
import os
import shutil
def ls(dir='.'):
return os.listdir(dir)
def is_hidden(path):
return os.path.basename(path).startswith('.')
def is_visible(path):
return not is_hidden(path)
def join_paths(dir, contents):
return [os.path.join(dir, f) for f in contents]
def files_matchi... |
import os
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sb
import results
from files import ensure_dir_exists
# CAMERA_READY_FONT = 'Calibri'
CAMERA_READY_FONT = 'DejaVu Sans'
SAVE_DIR = os.path.expanduser('~/Desktop/bolt/figs/')
ensure_dir_exists(SAVE_DI... |
#!/bin/env/python
from __future__ import division
import numpy as np
import numba
from .utils import top_k_idxs
# ================================================================ eigenvecs
# @numba.jit(nopython=True) # don't jit since take like 2.5s
# def top_principal_component(X, niters=50, return_eigenval=Fal... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.