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 |
|---|---|---|---|---|---|---|
GANFingerprints | GANFingerprints-master/CramerGAN/gan/core/resnet/ops/conv2d.py | """
Based on https://github.com/igul222/improved_wgan_training/blob/master/
"""
from ... import resnet as lib
import numpy as np
import tensorflow as tf
_default_weightnorm = False
def enable_default_weightnorm():
global _default_weightnorm
_default_weightnorm = True
_weights_stdev = None
def set_weights_std... | 3,910 | 30.039683 | 140 | py |
GANFingerprints | GANFingerprints-master/CramerGAN/gan/core/resnet/ops/cond_batchnorm.py | import resnet as lib
import numpy as np
import tensorflow as tf
def Batchnorm(name, axes, inputs, is_training=None, stats_iter=None, update_moving_stats=True, fused=True, labels=None, n_labels=None):
"""conditional batchnorm (dumoulin et al 2016) for BCHW conv filtermaps"""
if axes != [0,2,3]:
raise E... | 871 | 50.294118 | 135 | py |
GANFingerprints | GANFingerprints-master/CramerGAN/gan/core/resnet/ops/batchnorm.py | """
Based on https://github.com/igul222/improved_wgan_training/blob/master/
"""
from ... import resnet as lib
import numpy as np
import tensorflow as tf
def Batchnorm(name, axes, inputs, is_training=None, stats_iter=None, update_moving_stats=True, fused=True):
if ((axes == [0,2,3]) or (axes == [0,2])) and fused==T... | 4,463 | 48.6 | 169 | py |
GANFingerprints | GANFingerprints-master/CramerGAN/gan/core/resnet/ops/deconv2d.py | import resnet as lib
import numpy as np
import tensorflow as tf
_default_weightnorm = False
def enable_default_weightnorm():
global _default_weightnorm
_default_weightnorm = True
_weights_stdev = None
def set_weights_stdev(weights_stdev):
global _weights_stdev
_weights_stdev = weights_stdev
def unse... | 3,277 | 27.258621 | 101 | py |
GANFingerprints | GANFingerprints-master/CramerGAN/gan/core/resnet/ops/layernorm.py | """
Based on https://github.com/igul222/improved_wgan_training/blob/master/
"""
from ... import resnet as lib
import numpy as np
import tensorflow as tf
def Layernorm(name, norm_axes, inputs):
mean, var = tf.nn.moments(inputs, norm_axes, keep_dims=True)
# Assume the 'neurons' axis is the first of norm_axes. T... | 911 | 37 | 117 | py |
GANFingerprints | GANFingerprints-master/CramerGAN/gan/core/resnet/ops/conv1d.py | import tflib as lib
import numpy as np
import tensorflow as tf
_default_weightnorm = False
def enable_default_weightnorm():
global _default_weightnorm
_default_weightnorm = True
def Conv1D(name, input_dim, output_dim, filter_size, inputs, he_init=True, mask_type=None, stride=1, weightnorm=None, biases=True, ... | 3,401 | 30.211009 | 140 | py |
GANFingerprints | GANFingerprints-master/CramerGAN/gan/core/resnet/ops/linear.py | import resnet as lib
import numpy as np
import tensorflow as tf
_default_weightnorm = False
def enable_default_weightnorm():
global _default_weightnorm
_default_weightnorm = True
def disable_default_weightnorm():
global _default_weightnorm
_default_weightnorm = False
_weights_stdev = None
def set_we... | 4,325 | 29.041667 | 98 | py |
GANFingerprints | GANFingerprints-master/CramerGAN/gan/core/resnet/ops/__init__.py | 0 | 0 | 0 | py | |
GANFingerprints | GANFingerprints-master/CramerGAN/gan/utils/timer.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 19 13:42:24 2018
@author: mikolajbinkowski
"""
import time
class Timer(object):
def __init__(self, start_time=time.time(), limit=100):
self.start_time = start_time
self.limit = limit
def __call__(self, step, mess... | 843 | 23.823529 | 69 | py |
GANFingerprints | GANFingerprints-master/CramerGAN/gan/utils/get_test_images.py | import tensorflow as tf
import numpy as np
import os
os.chdir(os.path.join(os.getcwd(), '..', '..'))
import core.pipeline
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--dataset', default='lsun', help='dataset to sample from')
parser.add_argument('--data... | 1,553 | 41 | 115 | py |
GANFingerprints | GANFingerprints-master/CramerGAN/gan/utils/scorer.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 10 17:23:38 2018
@author: mikolajbinkowski
"""
import time, os, scipy, sys
import numpy as np
from core import mmd
import compute_scores as cs
class Scorer(object):
def __init__(self, dataset, lr_scheduler=True, stdout=sys.stdout):
self... | 6,569 | 44.625 | 141 | py |
GANFingerprints | GANFingerprints-master/CramerGAN/gan/utils/misc.py | """
Some codes from https://github.com/Newmu/dcgan_code
Released under the MIT license.
"""
from __future__ import division
import random
import pprint
import scipy.misc
import numpy as np
from time import gmtime, strftime
import tensorflow as tf
from six.moves import xrange
pp = pprint.PrettyPrinter()
def inverse_t... | 9,739 | 33.661922 | 112 | py |
GANFingerprints | GANFingerprints-master/CramerGAN/gan/utils/utils.py | """
Some codes from https://github.com/Newmu/dcgan_code
Released under the MIT license.
"""
from __future__ import division
import random
import pprint
import scipy.misc
import numpy as np
from time import gmtime, strftime
import tensorflow as tf
from six.moves import xrange
pp = pprint.PrettyPrinter()
def inverse_t... | 9,736 | 33.775 | 112 | py |
GANFingerprints | GANFingerprints-master/CramerGAN/gan/utils/__init__.py | __all__ = ['scorer', 'timer', 'misc']
| 38 | 18.5 | 37 | py |
GANFingerprints | GANFingerprints-master/ProGAN/tfutil.py | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... | 37,013 | 48.352 | 154 | py |
GANFingerprints | GANFingerprints-master/ProGAN/legacy.py | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... | 5,249 | 43.491525 | 122 | py |
GANFingerprints | GANFingerprints-master/ProGAN/loss.py | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... | 4,447 | 52.590361 | 115 | py |
GANFingerprints | GANFingerprints-master/ProGAN/misc.py | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... | 15,001 | 35.950739 | 177 | py |
GANFingerprints | GANFingerprints-master/ProGAN/dataset.py | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... | 12,111 | 49.049587 | 134 | py |
GANFingerprints | GANFingerprints-master/ProGAN/networks.py | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... | 17,216 | 53.484177 | 167 | py |
GANFingerprints | GANFingerprints-master/ProGAN/run.py | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... | 18,100 | 54.185976 | 190 | py |
GANFingerprints | GANFingerprints-master/ProGAN/config.py | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... | 4,119 | 64.396825 | 346 | py |
GANFingerprints | GANFingerprints-master/ProGAN/dataset_tool.py | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... | 36,317 | 46.976222 | 163 | py |
GANFingerprints | GANFingerprints-master/ProGAN/util_scripts.py | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... | 1,590 | 47.212121 | 173 | py |
GANFingerprints | GANFingerprints-master/ProGAN/metrics/sliced_wasserstein.py | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... | 5,788 | 41.566176 | 135 | py |
GANFingerprints | GANFingerprints-master/ProGAN/metrics/frechet_inception_distance.py | #!/usr/bin/env python3
#
# Copyright 2017 Martin Heusel
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable la... | 11,441 | 39.574468 | 110 | py |
GANFingerprints | GANFingerprints-master/ProGAN/metrics/ms_ssim.py | #!/usr/bin/python
#
# Copyright 2016 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... | 8,160 | 39.60199 | 128 | py |
GANFingerprints | GANFingerprints-master/ProGAN/metrics/inception_score.py | # Copyright 2016 Wojciech Zaremba
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | 5,305 | 34.851351 | 110 | py |
GANFingerprints | GANFingerprints-master/ProGAN/metrics/__init__.py | # empty
| 8 | 3.5 | 7 | py |
flock | flock-master/hierarchical/plan.py | import numpy as np
import math
class Plan:
'''
Set field 1 of condition: Must be a Test
Set field 2 of condition: Must be an Action
Set field 3 of condition: Must be an Action
Add action (to top level): Must be an Action or Condition
'''
legal = {}
def __init__(self):
... | 5,927 | 20.794118 | 136 | py |
flock | flock-master/hierarchical/run.py | import random
import numpy as np
filename = "../simulator/test.txt"
num_wolves = 6
num_sheep = 20
T = 500
fieldc = [100, 0, 0, 0, 0, 100, 100, 100]
penc = [25, 0, 0, 0, 0, 25, 25, 25]
field = "100 0 0 0 0 100 100 100"
pen = "25 0 0 0 0 0 25 25 25"
wall_force = 10
wall_dist = 10
sheep_attract = 1
sheep_repulse = 20... | 4,275 | 25.893082 | 89 | py |
flock | flock-master/hierarchical/evolve.py | '''
Isaac Julien
Evolution for decision tree model of shepherding problem
Basic setup:
Plan = Conditionals + Expressions + Actions + Observations
Conditionals = Expression + Actions (based on evaluation of expression)
- classified into DirectionConditionals only for now
Expressions = evaluate to some Type of v... | 9,713 | 28.797546 | 101 | py |
flock | flock-master/hierarchical/TestPlan.py | import plan
from plan import *
'''
Custom-made plan for wolves:
'''
def myPlan():
p = Plan()
NNN = DirectionAction("N")
NNE = DirectionAction("N")
NNS = DirectionAction("N")
NNW = DirectionAction("N")
NEN = DirectionAction("W")
NEE = DirectionAction("W")
NEW = DirectionAction("W")
... | 3,741 | 31.53913 | 77 | py |
YAIB-cohorts | YAIB-cohorts-main/Python/sepsis.py | import os
import argparse
import pyarrow as pa
import pyarrow.parquet as pq
from src.cohort import Cohort, SelectionCriterion
from src.steps import (
InputStep, LoadStep,
AggStep, FilterStep, TransformStep, CustomStep, RenameStep,
Pipeline, CombineStep
)
from src.ricu import stay_windows
from src.ricu_uti... | 5,841 | 34.840491 | 105 | py |
YAIB-cohorts | YAIB-cohorts-main/Python/aki.py | import os
import argparse
import pyarrow as pa
import pyarrow.parquet as pq
from src.cohort import Cohort, SelectionCriterion
from src.steps import (
InputStep, LoadStep,
AggStep, FilterStep, TransformStep, CustomStep, RenameStep,
Pipeline, CombineStep
)
from src.ricu import stay_windows
from src.ricu_uti... | 6,292 | 34.156425 | 106 | py |
YAIB-cohorts | YAIB-cohorts-main/Python/los.py | import os
import argparse
import pyarrow as pa
import pyarrow.parquet as pq
import numpy as np
from src.cohort import Cohort, SelectionCriterion
from src.steps import (
InputStep, LoadStep,
AggStep, FilterStep, TransformStep, CustomStep, DropStep, RenameStep,
Pipeline
)
from src.ricu import stay_windows, ... | 4,897 | 34.23741 | 102 | py |
YAIB-cohorts | YAIB-cohorts-main/Python/setup_env.py | from rpy2.robjects.packages import importr
# Install renv for reproducible R package management
utils = importr('utils')
utils.chooseCRANmirror(ind=1)
utils.install_packages('renv')
# Use renv to install all necessary packages
renv = importr('renv')
renv.activate()
renv.restore()
utils.install_packages('units')
# Ad... | 522 | 29.764706 | 86 | py |
YAIB-cohorts | YAIB-cohorts-main/Python/kidney_function.py | import os
import argparse
import pyarrow as pa
import pyarrow.parquet as pq
from src.cohort import Cohort, SelectionCriterion
from src.steps import (
InputStep, LoadStep,
AggStep, FilterStep, TransformStep, CustomStep, DropStep, RenameStep,
Pipeline
)
from src.ricu import stay_windows, hours
from src.ricu... | 5,167 | 34.156463 | 114 | py |
YAIB-cohorts | YAIB-cohorts-main/Python/mortality.py | import os
import argparse
import pyarrow as pa
import pyarrow.parquet as pq
from src.cohort import Cohort, SelectionCriterion
from src.steps import (
InputStep, LoadStep,
AggStep, FilterStep, TransformStep, CustomStep, DropStep, RenameStep,
Pipeline
)
from src.ricu import stay_windows, hours
from src.ricu... | 5,256 | 35.255172 | 108 | py |
YAIB-cohorts | YAIB-cohorts-main/Python/src/ricu.py | import os
from typing import List
import pandas as pd
import rpy2.robjects as ro
from rpy2.robjects.packages import importr
from .Rutils import as_data_frame, r_to_pandas
# Load ricu
ricu = importr('ricu')
# ------------------------------------------------------------------------------
# Port existing and often use... | 2,031 | 30.261538 | 93 | py |
YAIB-cohorts | YAIB-cohorts-main/Python/src/steps.py | from abc import abstractmethod
from typing import Any, List, Callable, Type
import pandas as pd
from .ricu import *
from .Rutils import as_null, r_to_pandas
class Step():
"""Base class for a transformation step
"""
def __init__(self, cache=False) -> None:
self.cache = cache
self._perform... | 7,939 | 32.221757 | 118 | py |
YAIB-cohorts | YAIB-cohorts-main/Python/src/cohort.py | from typing import List, Tuple
from collections import namedtuple
import pandas as pd
from .steps import Pipeline
fields = ['desc', 'n_input', 'n_criterion', 'n_excluded', 'n_left']
AttritionItem = namedtuple('AttritionItem', fields)
class SelectionCriterion(Pipeline):
"""Single cohort selection criterion, ei... | 4,300 | 32.084615 | 125 | py |
YAIB-cohorts | YAIB-cohorts-main/Python/src/__init__.py | 0 | 0 | 0 | py | |
YAIB-cohorts | YAIB-cohorts-main/Python/src/Rutils.py | import pandas as pd
import rpy2
import rpy2.robjects as ro
from rpy2.robjects import pandas2ri
source = ro.r['source']
as_data_frame = ro.r['as.data.frame']
as_null = ro.r['as.null']
def r_to_pandas(df: ro.RObject) -> pd.DataFrame:
"""Convert an R data.frame to pandas.DataFrame
Args:
df: R data.frame... | 944 | 27.636364 | 120 | py |
YAIB-cohorts | YAIB-cohorts-main/Python/src/ricu_utils.py | from typing import Callable, List
import numpy as np
import pandas as pd
def stop_window_at(x: pd.DataFrame, end: int | pd.DataFrame) -> pd.DataFrame:
"""Stop observation time at a given end date
Args:
x: observation times for each patient
end: time at which to end observation, can either be ... | 4,894 | 34.729927 | 129 | py |
gym-minecraft | gym-minecraft-master/setup.py | from setuptools import setup, find_packages
setup(name='gym_minecraft',
version='0.0.2',
description='OpenAI Gym environment for Minecraft based on Malmo',
url='https://github.com/tambetm/gym-minecraft',
author='Tambet Matiisen',
author_email='tambet.matiisen@gmail.com',
license='MI... | 705 | 40.529412 | 103 | py |
gym-minecraft | gym-minecraft-master/examples/test.py | import gym
import gym_minecraft
import time
env = gym.make('MinecraftBasic-v0')
#env.configure(allowContinuousMovement=["move", "turn"])
env.configure(allowDiscreteMovement=["move", "turn"], log_level="INFO")
#env.configure(videoResolution=[160, 120])
#env.monitor.start("gym_random")
for _ in xrange(10):
t = time... | 806 | 25.9 | 87 | py |
gym-minecraft | gym-minecraft-master/examples/test_multi.py | import gym
import gym_minecraft
env = gym.make('MinecraftBasic-v0')
env.configure(client_pool=[("localhost", 10000), ("localhost", 10001), ("localhost", 10002)])
env.reset()
done = False
while not done:
env.render()
action = env.action_space.sample()
obs, reward, done, info = env.step(action)
| 308 | 22.769231 | 93 | py |
gym-minecraft | gym-minecraft-master/gym_minecraft/__init__.py | from gym.envs.registration import register
# Env registration
# ==========================
register(
id='MinecraftDefaultWorld1-v0',
entry_point='gym_minecraft.envs:MinecraftEnv',
kwargs={'mission_file': 'default_world_1.xml'},
#tags={'wrapper_config.TimeLimit.max_episode_steps': 6060},
#timestep... | 3,949 | 26.622378 | 63 | py |
gym-minecraft | gym-minecraft-master/gym_minecraft/envs/minecraft_env.py | import logging
import time
import os
import numpy as np
import json
import xml.etree.ElementTree as ET
import gym
from gym import spaces, error
try:
import minecraft_py
import MalmoPython
except ImportError as e:
raise error.DependencyNotInstalled("{}. (HINT: install minecraft_py from https://github.com/t... | 17,110 | 43.21447 | 131 | py |
gym-minecraft | gym-minecraft-master/gym_minecraft/envs/__init__.py | from gym_minecraft.envs.minecraft_env import *
| 47 | 23 | 46 | py |
SpectralANN | SpectralANN-main/MonteCarloTest.py | # -*- coding: utf-8 -*-
"""
Created on Mon Sep 20 11:22:43 2021
@author: Thibault
"""
import torch
from ACANN import ACANN
from torch.utils.data import DataLoader
import numpy as np
import matplotlib.pyplot as plt
import inputParameters as config
import pandas as pd
from matplotlib.legend_handler import HandlerTuple
f... | 11,372 | 29.328 | 120 | py |
SpectralANN | SpectralANN-main/generatePropagators.py | # -*- coding: utf-8 -*-
"""
Created on Mon Jul 5 12:18:08 2021
@author: Thibault
"""
import numpy as np
from scipy import integrate
import itertools
import pandas as pd
import os
from functools import lru_cache
import time
import random
np.seterr('raise')
cacheSize = 2048
random.seed(64)
@lru_cache(maxsize=cacheS... | 17,733 | 33.840864 | 134 | py |
SpectralANN | SpectralANN-main/train_ACANN.py | from ACANN import ACANN
from Database import Database
from torch.nn.modules.loss import KLDivLoss,L1Loss,MSELoss
from torch.optim import Adam,Rprop,Adamax, RMSprop,SGD,LBFGS,AdamW
from torch.utils.data import DataLoader
import torch
import inputParameters as config
import matplotlib.pyplot as plt
import os
os.environ[... | 4,320 | 35.008333 | 146 | py |
SpectralANN | SpectralANN-main/inputParameters.py | nbrOfPoles = 3
trainingPoints = 10200
validationPoints = 1700
pstart = 0
pend = 8.25
nbrPoints = 100
nbrWs = 200
| 113 | 13.25 | 23 | py |
SpectralANN | SpectralANN-main/robustnessCheck.py | # -*- coding: utf-8 -*-
"""
Created on Thu Sep 2 17:54:33 2021
@author: Thibault
"""
#1: add noise 20 times to same propagator
#2: Convert to correct input
#3: Input to NN
#4: Calc average and stddev of spectral functions
indices = [227, 1552, 112, 1243, 606]
nbrOfSamples = 100
noiseSize = 1e-2
from Database i... | 12,731 | 33.597826 | 144 | py |
SpectralANN | SpectralANN-main/Database.py | from torch.utils.data import TensorDataset
import pandas as pd
import torch
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
print("Using",device)
class Database():
def __init__(self, csv_target, csv_input, transform=None,nb_data=25000):
"""
Build the data set structure
... | 1,130 | 38 | 79 | py |
SpectralANN | SpectralANN-main/test_ACANN.py | # -*- coding: utf-8 -*-
"""
Created on Sun Jun 27 10:53:43 2021
@author: Thibault
"""
import torch
from ACANN import ACANN
from Database import Database
from torch.utils.data import DataLoader
import numpy as np
import matplotlib.pyplot as plt
import inputParameters as config
import pandas as pd
from matplotlib.legend... | 12,953 | 32.734375 | 120 | py |
SpectralANN | SpectralANN-main/propagatorNoise.py | # -*- coding: utf-8 -*-
"""
Created on Tue Nov 30 15:06:14 2021
@author: Thibault
"""
from Database import Database
from torch.utils.data import DataLoader
import inputParameters as config
import numpy as np
import pandas as pd
import os
os.environ["KMP_DUPLICATE_LIB_OK"]="TRUE"
noiseSize = 5e-3
#Load input parame... | 2,951 | 27.660194 | 101 | py |
SpectralANN | SpectralANN-main/ACANN.py | import torch.nn as nn
import torch.nn.functional as F
import torch
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
class ACANN(nn.Module):
def __init__(self,input_size,output_size,hidden_layers,drop_p=0.05):
""" Builds ACANN network with arbitrary number of hidden layers.
... | 1,617 | 29.528302 | 95 | py |
giants | giants-main/prepare_batch.py | import pandas as pd
import numpy as np
import os
def create_batch_file(inlist, outdir, batchfile_path, local=False):
# read in the list of targets
f = pd.read_csv(inlist, delimiter=',')
try:
targets = np.array(f['tic'])
except:
targets = np.array(f['TIC'])
# create the batch file
... | 1,579 | 36.619048 | 107 | py |
giants | giants-main/setup.py | #!/usr/bin/env python
import os
import sys
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
with open('requirements.txt') as f:
install_requires = f.read().splitlines()
setup(name='giants',
version='0.0.1',
description="",
author='Samuel Grunblatt, N... | 519 | 22.636364 | 54 | py |
giants | giants-main/housekeeping.py | import os
import time
dirpath = '/home/nsaunders/.lightkurve-cache/tesscut/'
while True:
time.sleep(60)
for f in os.listdir(dirpath):
try:
fn = os.path.join(dirpath, f)
if os.stat(fn).st_mtime < time.time() - 60:
os.remove(fn)
print(f'Removed {f}... | 381 | 24.466667 | 55 | py |
giants | giants-main/run_giants.py | import sys
import argparse
import pandas as pd
import numpy as np
from giants.plotting import plot_summary
from giants.target import Target
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Run giants on a single target.')
parser.add_argument('ticid', type=str, help='TICID of the targ... | 1,652 | 36.568182 | 131 | py |
giants | giants-main/src/giants/target.py | import os
import re
import numpy as np
import pandas as pd
import scipy
import lightkurve as lk
import warnings
from tess_stars2px import tess_stars2px_function_entry
from astrocut import CutoutFactory
from astroquery.mast import Catalogs
from . import PACKAGEDIR
from .plotting import plot_summary
# suppress verbose ... | 14,120 | 32.863309 | 142 | py |
giants | giants-main/src/giants/plotting.py | import os
import numpy as np
import scipy
import matplotlib.pyplot as plt
import matplotlib
from astropy.stats import BoxLeastSquares
from astropy.coordinates import SkyCoord, Angle
import lightkurve as lk
import astropy.units as u
import pickle
from astroquery.mast import Catalogs
try:
from .utils import build_kt... | 18,574 | 31.192374 | 160 | py |
giants | giants-main/src/giants/lomb.py | #!/usr/bin/env python
""" Fast algorithm for spectral analysis of unevenly sampled data
The Lomb-Scargle method performs spectral analysis on unevenly sampled
data and is known to be a powerful way to find, and test the
significance of, weak periodic signals. The method has previously been
thought to be 'slow', requir... | 6,005 | 28.297561 | 73 | py |
giants | giants-main/src/giants/utils.py | import numpy as np
from astropy.stats import BoxLeastSquares
import lightkurve as lk
import astropy.units as u
from scipy.constants import G
def _calculate_separation(m_star, period):
"""
Calculate the separation of a planet in a circular orbit around a star.
Parameters
----------
m_star : fl... | 3,255 | 27.313043 | 110 | py |
giants | giants-main/src/giants/__init__.py | import os
PACKAGEDIR = os.path.abspath(os.path.dirname(__file__))
from .target import *
from .plotting import *
from .utils import * | 133 | 21.333333 | 55 | py |
NeuralBKI | NeuralBKI-main/generate_results.py | # This file generates results for evaluation by loading semantic predictions from files.
# Not intended for use on-board robot.
import os
import pdb
import time
import json
import rospy
import yaml
os.environ["CUDA_LAUNCH_BLOCKING"] = "1"
import numpy as np
import copy
from tqdm import tqdm
# Torch imports
import to... | 13,528 | 41.410658 | 150 | py |
NeuralBKI | NeuralBKI-main/train.py | import os
import pdb
import time
import json
import yaml
os.environ["CUDA_LAUNCH_BLOCKING"] = "1"
import numpy as np
from tqdm import tqdm
# Torch imports
import torch
from torch import nn
import torch.optim as optim
from torch.utils.data import Dataset, DataLoader
from torch.utils.tensorboard import SummaryWriter
#... | 11,927 | 39.989691 | 141 | py |
NeuralBKI | NeuralBKI-main/Data/KittiOdometry.py | import os
import numpy as np
# from utils import laserscan
import yaml
from torch.utils.data import Dataset
import torch
# import spconv
import math
from scipy.spatial.transform import Rotation as R
config_file = os.path.join('Config/kitti_odometry.yaml')
kitti_config = yaml.safe_load(open(config_file, 'r'))
SPLIT_SEQ... | 14,054 | 40.217009 | 123 | py |
NeuralBKI | NeuralBKI-main/Data/utils.py | import os
import pdb
from matplotlib import markers
import rospy
import numpy as np
import time
import os
import pdb
import torch
from visualization_msgs.msg import *
from geometry_msgs.msg import Point32
from std_msgs.msg import ColorRGBA
# Intersection, union for one frame
def iou_one_frame(pred, target, n_classes=2... | 4,931 | 31.662252 | 109 | py |
NeuralBKI | NeuralBKI-main/Data/SemanticKitti.py | import os
import numpy as np
# from utils import laserscan
import yaml
from torch.utils.data import Dataset
import torch
# import spconv
import math
from scipy.spatial.transform import Rotation as R
config_file = os.path.join('Config/semantic_kitti.yaml')
kitti_config = yaml.safe_load(open(config_file, 'r'))
remapdict... | 15,165 | 39.878706 | 134 | py |
NeuralBKI | NeuralBKI-main/Data/Rellis3D.py | ## Maintainer: Arthur Zhang #####
## Contact: arthurzh@umich.edu #####
import os
import pdb
import math
import numpy as np
import random
import json
import yaml
from sklearn.metrics import homogeneity_completeness_v_measure
import torch
from torch import gt
import torch.nn.functional as F
from torch.utils.data import... | 11,319 | 38.719298 | 154 | py |
NeuralBKI | NeuralBKI-main/Models/model_utils.py | import pdb
import torch
import random
import numpy as np
from torch import empty
from torch import long
from Models.ConvBKI import ConvBKI
def setup_seed(seed=42):
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
np.random.seed(seed)
random.seed(seed)
def measure_inf_time(model, inputs, rep... | 1,843 | 30.254237 | 111 | py |
NeuralBKI | NeuralBKI-main/Models/ConvBKI.py | import pdb
import os
import torch
torch.backends.cudnn.deterministic = True
import torch.nn.functional as F
class ConvBKI(torch.nn.Module):
def __init__(self, grid_size, min_bound, max_bound, filter_size=3,
num_classes=21, prior=0.001, device="cpu", datatype=torch.float32,
max_di... | 9,899 | 47.292683 | 123 | py |
NeuralBKI | NeuralBKI-main/Models/mapping_utils.py | # This file contains classes for local and global offline mapping (not running semantic prediction)
import torch
import torch.nn.functional as F
import numpy as np
import time
from Models.ConvBKI import ConvBKI
# TODO: Trilinear interpolation
# Save grid in CPU memory, load to GPU when needed for update step
# Voxels... | 7,482 | 46.66242 | 142 | py |
NeuralBKI | NeuralBKI-main/Models/BKINet.py | import torch
# BKINet consists of two components:
# 1) A pre-trained semantic segmentation model
# 2) A pre-trained ConvBKI layer
# This module is intended for ROS integration
class BKINet(torch.nn.Module):
def __init__(self, grid_size, min_bound, max_bound, weights, filter_size, segmentation_net,
... | 1,442 | 34.195122 | 106 | py |
pivnet | pivnet-main/pivnet.py | from typing import List
import pickle, itertools
from numba import jit, i4, i8, f4, typeof
from numba.typed import List
from numba.experimental import jitclass
import numpy as np
from sklearn.preprocessing import StandardScaler
from collections import OrderedDict
from scipy.spatial import KDTree
import multiprocessing ... | 10,860 | 30.120344 | 73 | py |
absynthe | absynthe-main/scripts/run_sygus_benchmarks.py | from plumbum import local, FG, TF
from plumbum.cmd import bundle
import json
import numpy as np
from scipy.stats import iqr
import os
import argparse
import sys
import csv
parser = argparse.ArgumentParser(description='Run Absynthe SyGuS benchmarks')
parser.add_argument('--times', '-t', dest='times', action='store',
... | 3,229 | 34.494505 | 159 | py |
absynthe | absynthe-main/scripts/run_autopandas_benchmarks.py | import json
import numpy as np
from scipy.stats import iqr
import os
import argparse
import sys
import csv
sys.path.insert(1, os.path.abspath('../autopandas/'))
from harness import run_benchmarks, benches, smallbenches
parser = argparse.ArgumentParser(description='Run Absynthe AutoPandas benchmarks')
parser.add_argum... | 3,202 | 30.401961 | 117 | py |
absynthe | absynthe-main/autopandas/benchmarks.py | # The following benchmarks are sourced from the AutoPandas benchmarks
# Source: https://github.com/rbavishi/autopandas/blob/master/autopandas_v2/evaluation/benchmarks/stackoverflow.py
from io import StringIO
import pandas as pd
import numpy as np
from runner import Benchmark
# https://stackoverflow.com/questions/1188... | 25,083 | 49.777328 | 124 | py |
absynthe | absynthe-main/autopandas/harness.py | import io
import subprocess
import benchmarks
import unittest
import warnings
import time
import random
import sys
import os
from pygments import highlight
from pygments.lexers import PythonLexer
from pygments.formatters import TerminalFormatter
from protocol import Protocol, handle_action
# List of benchmarks to run ... | 3,650 | 29.940678 | 69 | py |
absynthe | absynthe-main/autopandas/runner.py | import pandas as pd
import numpy as np
import itertools
def flatten(xs):
try:
return list(itertools.chain(*xs))
except:
return xs
# Defines and infers the domains required by AutoPandas in Python
# Note that all the methods required by each domain is still defined in Ruby.
# The code here just... | 5,867 | 34.137725 | 117 | py |
absynthe | absynthe-main/autopandas/protocol.py | # This file defines the IPC protocol used by the AutoPandas Python test harness
# process to communicate with the Absynthe core process in Ruby. This is a JSON
# line protocol with each action decribing steps happening with every message.
import json
class Action:
pass
class Protocol:
def __init__(self, proc, lo... | 1,669 | 29.925926 | 79 | py |
tdqn | tdqn-master/tdqn/tdqn.py | import time
import math, random
import numpy as np
from os.path import join as pjoin
import torch
import torch.nn as nn
import torch.optim as optim
import torch.autograd as autograd
import torch.nn.functional as F
import logger
import copy
from replay import *
from schedule import *
from models import TDQN
from env... | 11,644 | 37.816667 | 119 | py |
tdqn | tdqn-master/tdqn/logger.py | import os
import sys
import shutil
import os.path as osp
import json
import time
import datetime
import tempfile
from collections import defaultdict
DEBUG = 10
INFO = 20
WARN = 30
ERROR = 40
DISABLED = 50
class KVWriter(object):
def writekvs(self, kvs):
raise NotImplementedError
class SeqWriter(object):... | 14,503 | 28.660532 | 122 | py |
tdqn | tdqn-master/tdqn/replay.py | from collections import deque
import numpy as np
import random
class ReplayBuffer(object):
def __init__(self, capacity):
self.buffer = deque(maxlen=capacity)
def push(self, state, action, reward, next_state, done):
self.buffer.append((state, action, reward, next_state, done))
def sample(... | 2,230 | 38.140351 | 121 | py |
tdqn | tdqn-master/tdqn/models.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import numpy as np
import random
class TDQN(nn.Module):
def __init__(self, args, template_size, vocab_size, vocab_size_act):
super(TDQN, self).__init__()
self.embeddings = nn.Embedding(vocab_siz... | 5,149 | 40.532258 | 98 | py |
tdqn | tdqn-master/tdqn/schedule.py | import math
"""
Adapted from https://github.com/berkeleydeeprlcourse/homework
"""
class Schedule(object):
def value(self, t):
"""Value of the schedule at time t"""
raise NotImplementedError()
class ConstantSchedule(object):
def __init__(self, value):
"""Value remains constant over t... | 3,725 | 34.826923 | 94 | py |
tdqn | tdqn-master/tdqn/train.py | import os
import argparse
import jericho
from tdqn import TDQN_Trainer
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('--rom_path', default='zork1.z5')
parser.add_argument('--output_dir', default='logs')
parser.add_argument('--spm_path', default='../spm_models/unigram_8k.model... | 1,538 | 42.971429 | 104 | py |
tdqn | tdqn-master/tdqn/env.py | import subprocess
import time
import redis
from os.path import basename, dirname
from jericho import *
from jericho.template_action_generator import TemplateActionGenerator
from jericho.util import *
from jericho.defines import *
def start_redis():
print('Starting Redis')
subprocess.Popen(['redis-server', '--s... | 3,689 | 35.534653 | 98 | py |
tdqn | tdqn-master/drrn/drrn.py | import pickle
import torch
import torch.nn as nn
import torch.nn.functional as F
from os.path import join as pjoin
from memory import ReplayMemory, Transition, State
from model import DRRN
from util import *
import logger
import sentencepiece as spm
device = torch.device("cuda" if torch.cuda.is_available() else "cpu"... | 3,809 | 36.722772 | 104 | py |
tdqn | tdqn-master/drrn/memory.py | from collections import namedtuple
import random
State = namedtuple('State', ('obs', 'description', 'inventory'))
Transition = namedtuple('Transition', ('state', 'act', 'reward', 'next_state', 'next_acts', 'done'))
class ReplayMemory(object):
def __init__(self, capacity):
self.capacity = capacity
... | 2,479 | 37.153846 | 107 | py |
tdqn | tdqn-master/drrn/model.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import random
import itertools
from util import pad_sequences
from memory import State
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
class DRRN(torch.nn.Module):
"""
Deep Reinforcement Relevance... | 4,282 | 40.990196 | 96 | py |
tdqn | tdqn-master/drrn/logger.py | import os
import sys
import shutil
import os.path as osp
import json
import time
import datetime
import tempfile
from collections import defaultdict
DEBUG = 10
INFO = 20
WARN = 30
ERROR = 40
DISABLED = 50
class KVWriter(object):
def writekvs(self, kvs):
raise NotImplementedError
class SeqWriter(object):... | 14,503 | 28.660532 | 122 | py |
tdqn | tdqn-master/drrn/vec_env.py | import numpy as np
from multiprocessing import Process, Pipe
def worker(remote, parent_remote, env):
parent_remote.close()
env.create()
try:
done = False
while True:
cmd, data = remote.recv()
if cmd == 'step':
if done:
ob, info = e... | 2,514 | 33.452055 | 94 | py |
tdqn | tdqn-master/drrn/util.py | import numpy as np
def pad_sequences(sequences, maxlen=None, dtype='int32', value=0.):
'''
Partially borrowed from Keras
# Arguments
sequences: list of lists where each element is a sequence
maxlen: int, maximum length
dtype: type to cast the resulting sequence.
value: floa... | 1,480 | 36.025 | 114 | py |
tdqn | tdqn-master/drrn/train.py | import subprocess
import time
import os
import torch
import logger
import argparse
import yaml
import jericho
from os.path import basename, dirname
from drrn import DRRN_Agent
from vec_env import VecEnv
from env import JerichoEnv
from jericho.util import clean
def configure_logger(log_dir):
logger.configure(log_d... | 5,988 | 38.926667 | 118 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.