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 |
|---|---|---|---|---|---|---|
finmag | finmag-master/doc/tailored_tutorials/basics.py | conf = {'nameshort': 'basics',
'names': ('Finmag Users',),
'tutorials' : ['tutorial-using-ipython-notebook',
'tutorial-example2',
'tutorial-saving-averages-demo',
'tutorial-scheduling-events',
'tutorial-relaxatio... | 724 | 47.333333 | 70 | py |
finmag | finmag-master/doc/tailored_tutorials/2015-Hagen-Fuchs.py | conf = {'nameshort': 'HagenFuchs',
'names': ('Hagen Fuchs', 'Ulrich Roessler', 'Denys Makarov'),
'tutorials' : ['tutorial-using-ipython-notebook',
'tutorial-example2',
'tutorial-saving-averages-demo',
'tutorial-use-of-logging',
... | 628 | 47.384615 | 69 | py |
finmag | finmag-master/doc/tailored_tutorials/hesjedahl.py | conf = {'nameshort': 'Hesjedahl',
'names': ('Thorsten Hesjedahl', 'Shilei Zhang'),
'tutorials' : ['tutorial-using-ipython-notebook',
'tutorial-example2',
'tutorial-saving-averages-demo',
'tutorial-use-of-logging',
... | 510 | 45.454545 | 68 | py |
CVD-Physiological-Measurement | CVD-Physiological-Measurement-master/test.py | ########################################################
# This is an example of the training and test procedure
# You need to adjust the training and test dataloader based on your data
# CopyRight @ Xuesong Niu
########################################################
import torch
import torch.nn as nn
import torch.nn... | 6,206 | 39.835526 | 159 | py |
CVD-Physiological-Measurement | CVD-Physiological-Measurement-master/utils/__init__.py | 1 | 0 | 0 | py | |
CVD-Physiological-Measurement | CVD-Physiological-Measurement-master/utils/database/__init__.py | 1 | 0 | 0 | py | |
CVD-Physiological-Measurement | CVD-Physiological-Measurement-master/utils/database/Pixelmap.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.autograd import Variable
import os
import shutil
import numpy as np
from torch.utils.data import Dataset, DataLoader
import scipy.io as sio
from PIL import Image
import torchvision.transforms.functional as transF
... | 2,154 | 30.231884 | 106 | py |
CVD-Physiological-Measurement | CVD-Physiological-Measurement-master/utils/loss/loss_cross.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.autograd import Variable, Function
import os
import shutil
import numpy as np
import scipy.io as sio
from scipy.stats import norm
class Cross_loss(nn.Module):
def __init__(self, lambda_cross_fhr = 0.000005, la... | 1,533 | 36.414634 | 151 | py |
CVD-Physiological-Measurement | CVD-Physiological-Measurement-master/utils/loss/__init__.py | 1 | 0 | 0 | py | |
CVD-Physiological-Measurement | CVD-Physiological-Measurement-master/utils/loss/loss_SNR.py | import math
import torch
from torch.autograd import Variable
import numpy as np
import torch.nn.functional as F
import torch.nn as nn
class SNR_loss(nn.Module):
def __init__(self, clip_length = 300, delta = 3, loss_type = 1, use_wave = False):
super(SNR_loss, self).__init__()
self.clip_length = cl... | 3,482 | 31.858491 | 130 | py |
CVD-Physiological-Measurement | CVD-Physiological-Measurement-master/utils/loss/loss_r.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.autograd import Variable, Function
import os
import shutil
import numpy as np
import scipy.io as sio
from scipy.stats import norm
class Neg_Pearson(nn.Module): # Pearson range [-1, 1] so if < 0, abs|loss| ; if >0... | 1,249 | 29.487805 | 110 | py |
CVD-Physiological-Measurement | CVD-Physiological-Measurement-master/utils/model/resnet.py | import torch.nn as nn
import math
import torch.utils.model_zoo as model_zoo
from torch.autograd import Variable
import torch
__all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101',
'resnet152']
model_urls = {
'resnet18': 'https://download.pytorch.org/models/resnet18-5c106cde.pth',
're... | 16,942 | 33.577551 | 87 | py |
CVD-Physiological-Measurement | CVD-Physiological-Measurement-master/utils/model/model.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.autograd import Variable
import os, sys
import shutil
import numpy as np
import scipy.io as sio
sys.path.append('..');
from utils.model.resnet import resnet18, resnet_small;
from utils.model.resnet_stconv import ... | 353 | 16.7 | 54 | py |
CVD-Physiological-Measurement | CVD-Physiological-Measurement-master/utils/model/__init__.py | 1 | 0 | 0 | py | |
CVD-Physiological-Measurement | CVD-Physiological-Measurement-master/utils/model/model_disentangle.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import os, sys
import shutil
import numpy as np
import scipy.io as sio
sys.path.append('..');
from utils.model.resnet import resnet18, resnet18_part;
import time
class ResidualBlock(nn.Module):
"""Residual Block."""
def __init__(self, dim_in,... | 5,936 | 34.76506 | 136 | py |
CREPE | CREPE-master/crepe_prod_eval_cyclip.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import ast
import argparse
import logging
import os
from PIL import Image, ImageFile
from dataclasses import da... | 5,815 | 32.045455 | 135 | py |
CREPE | CREPE-master/crepe_prod_eval_albef.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import logging
import os
from PIL import Image
from time import time
import torch
from torch import nn
from to... | 7,966 | 34.887387 | 135 | py |
CREPE | CREPE-master/crepe_prod_eval_flava.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import ast
import logging
import os
from PIL import Image
from dataclasses import dataclass
from time import t... | 6,056 | 31.918478 | 135 | py |
CREPE | CREPE-master/crepe_prod_eval_clip.py | import logging
import os
from time import time
import json
import torch
import torchvision.transforms.functional as TF
import clip
from torch.utils.data import DataLoader
import numpy as np
import pandas as pd
from crepe_eval_utils import BaseCsvDataset, get_one2many_rank, get_one2many_metrics, DataInfo
from crepe_p... | 5,220 | 30.642424 | 135 | py |
CREPE | CREPE-master/crepe_compo_eval_open_clip.py | import os
import json
import logging
import torch
import numpy as np
import torch.nn.functional as F
import torchvision.transforms.functional as TF
from torch.utils.data import DataLoader
from torch.utils.data.distributed import DistributedSampler
from dataclasses import dataclass
from open_clip import tokenize, create... | 7,732 | 34.15 | 160 | py |
CREPE | CREPE-master/crepe_params.py | import argparse
def setup_args():
parser = argparse.ArgumentParser(description="Run image2text retrieval eval.")
parser.add_argument("--compo-type", required=True, type=str, default="systematicity", help="Either systematicity or productivity")
parser.add_argument("--input-dir", required=True, type=str, def... | 1,608 | 72.136364 | 150 | py |
CREPE | CREPE-master/crepe_eval_utils.py | import ast
import logging
import os
from PIL import Image
from dataclasses import dataclass
import torch
from torch.utils.data import DataLoader, Dataset
import numpy as np
import pandas as pd
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger()
### DATASET CONSTRUCTION
class BaseCsvDataset(Dataset... | 3,542 | 35.525773 | 146 | py |
CREPE | CREPE-master/open_clip/openai.py | """ OpenAI pretrained model functions
Adapted from https://github.com/openai/CLIP. Originally MIT License, Copyright (c) 2021 OpenAI.
"""
import os
import warnings
from typing import Union, List
import torch
from .model import build_model_from_openai_state_dict
from .pretrained import get_pretrained_url, list_pretr... | 4,503 | 34.464567 | 117 | py |
CREPE | CREPE-master/open_clip/transform.py | from torchvision.transforms import Normalize, Compose, RandomResizedCrop, ToTensor, Resize, \
CenterCrop
from PIL import Image
def _convert_to_rgb(image):
return image.convert('RGB')
def image_transform(
image_size: int,
is_train: bool,
mean=(0.48145466, 0.4578275, 0.40821073),
... | 850 | 26.451613 | 93 | py |
CREPE | CREPE-master/open_clip/loss.py | import torch
import torch.distributed.nn
from torch import distributed as dist, nn as nn
from torch.nn import functional as F
try:
import horovod.torch as hvd
except ImportError:
hvd = None
def gather_features(
image_features,
text_features,
local_loss=False,
gather_with_grad=... | 4,658 | 39.513043 | 101 | py |
CREPE | CREPE-master/open_clip/utils.py | from torch import nn as nn
from torchvision.ops.misc import FrozenBatchNorm2d
def freeze_batch_norm_2d(module, module_match={}, name=''):
"""
Converts all `BatchNorm2d` and `SyncBatchNorm` layers of provided module into `FrozenBatchNorm2d`. If `module` is
itself an instance of either `BatchNorm2d` or `Syn... | 1,850 | 44.146341 | 131 | py |
CREPE | CREPE-master/open_clip/model.py | """ CLIP Model
Adapted from https://github.com/openai/CLIP. Originally MIT License, Copyright (c) 2021 OpenAI.
"""
from collections import OrderedDict
from dataclasses import dataclass
from typing import Tuple, Union, Callable, Optional
import numpy as np
import torch
import torch.nn.functional as F
from torch impor... | 21,811 | 37.95 | 120 | py |
CREPE | CREPE-master/open_clip/version.py | __version__ = '1.3.0'
| 22 | 10.5 | 21 | py |
CREPE | CREPE-master/open_clip/factory.py | import json
import logging
import os
import pathlib
import re
from copy import deepcopy
from pathlib import Path
import torch
from .model import CLIP, convert_weights_to_fp16
from .openai import load_openai_model
from .pretrained import get_pretrained_url, download_pretrained
from .transform import image_transform
... | 5,455 | 34.660131 | 106 | py |
CREPE | CREPE-master/open_clip/tokenizer.py | """ CLIP tokenizer
Copied from https://github.com/openai/CLIP. Originally MIT License, Copyright (c) 2021 OpenAI.
"""
import gzip
import html
import os
from functools import lru_cache
from typing import Union, List
import ftfy
import regex as re
import torch
@lru_cache()
def default_bpe():
return os.path.join(o... | 6,637 | 33.936842 | 121 | py |
CREPE | CREPE-master/open_clip/pretrained.py | import hashlib
import os
import urllib
import warnings
from tqdm import tqdm
_RN50 = dict(
openai="https://openaipublic.azureedge.net/clip/models/afeb0e10f9e5a86da6080e35cf09123aca3b358a0c3e3b6c78a7b63bc04b6762/RN50.pt",
yfcc15m="https://github.com/mlfoundations/open_clip/releases/download/v0.2-weights/rn50-q... | 7,174 | 42.75 | 142 | py |
CREPE | CREPE-master/open_clip/__init__.py | from .factory import list_models, create_model, create_model_and_transforms, add_model_config
from .loss import ClipLoss
from .model import CLIP, CLIPTextCfg, CLIPVisionCfg, convert_weights_to_fp16, trace_model
from .openai import load_openai_model, list_openai_models
from .pretrained import list_pretrained, list_pretr... | 499 | 54.555556 | 97 | py |
CREPE | CREPE-master/open_clip/timm_model.py | """ timm model adapter
Wraps timm (https://github.com/rwightman/pytorch-image-models) models for use as a vision tower in CLIP model.
"""
from collections import OrderedDict
import torch.nn as nn
try:
import timm
from timm.models.layers import Mlp, to_2tuple
from timm.models.layers.attention_pool2d impor... | 4,300 | 39.196262 | 119 | py |
DNN_Rover | DNN_Rover-master/ModelTrain.py | # author = michael teti
from __future__ import division, print_function, absolute_import
import numpy as np
import tflearn
from tflearn.layers.core import input_data, dropout, fully_connected
from tflearn.layers.conv import conv_2d, max_pool_2d
from tflearn.layers.normalization import local_response_normalization
from... | 6,753 | 27.618644 | 88 | py |
DNN_Rover | DNN_Rover-master/main.py | from RoverAPI import *
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument(
'--model_name',
type=str,
help='path to the model file if autonomous.')
parser.add_argument(
'--autonomous',
type=bool,
default=False,
help='Tr... | 2,908 | 26.971154 | 96 | py |
DNN_Rover | DNN_Rover-master/NetworkSwitch.py | import os, sys
import tflearn
import tensorflow as tf
import h5py
import numpy as np
from sklearn.preprocessing import scale
from tflearn.layers.core import input_data, dropout, fully_connected, flatten
from tflearn.layers.conv import conv_2d, max_pool_2d, highway_conv_2d, avg_pool_2d
from tflearn.layers.normalization ... | 25,531 | 46.369202 | 161 | py |
DNN_Rover | DNN_Rover-master/RoverAPI.py | from __future__ import print_function
from rover.Data import *
import os, sys
from rover.Pygame_UI import *
from rover import Rover
import time
import numpy as np
#from scipy.misc import imresize
class RoverRun(Rover):
def __init__(self, fileName, network_name, autonomous, driver, rover, FPS,
vie... | 2,802 | 31.593023 | 78 | py |
DNN_Rover | DNN_Rover-master/tobii_interface.py.py | import tobii_research as tr
import time
import cv2
import numpy as np
from numpy.random import randint
import csv
class Tobii:
def __init__(self):
self.cal_points = 5
self.ht, self.wd = 1024, 1280 # height and width of the display
self.point_size = 10 // 2 # number of pixels in a display ... | 2,462 | 33.690141 | 104 | py |
DNN_Rover | DNN_Rover-master/rover/adpcm.py | _indexAdjust = [-1, -1, -1, -1, 2, 4, 6, 8]
_stepTable = [
7,
8,
9,
10,
11,
12,
13,
14,
16,
17,
19,
21,
23,
25,
28,
31,
34,
37,
41,
45,
50,
55,
60,
66,
73,
80,
88,
97,
107,
118,
130,
143,
... | 1,671 | 11.571429 | 85 | py |
DNN_Rover | DNN_Rover-master/rover/blowfish.py | import ctypes
class Blowfish:
def __init__(self, key):
'''Uses the specified key to create a Blowfish object that you can then
to encrypt and decrypt pairs of numbers. P-array is initialized
with values derived from the hexadecimal digits of Pi.
'''
# from https:/... | 19,150 | 53.561254 | 80 | py |
DNN_Rover | DNN_Rover-master/rover/Data.py | import time
import numpy as np
import h5py
import progressbar
import datetime
import tflearn
from tflearn.layers.core import input_data
import torchvision.models as models
from NetworkSwitch import *
import torch
import torch.nn as nn
from scipy.misc import imresize
from skimage.transform import resize
class Data():
... | 3,962 | 35.027273 | 80 | py |
DNN_Rover | DNN_Rover-master/rover/byteutils.py |
import struct
import sys
def dump_bytes(bytes):
for c in bytes:
sys.stdout.write('%02x ' % ord(c))
sys.stdout.write('\n')
def bytes_to_int(bytes, offset):
return struct.unpack('i', bytes[offset:offset + 4])[0]
def bytes_to_uint(bytes, offset):
return struct.unpack('I', bytes[offset:offset... | 426 | 18.409091 | 58 | py |
DNN_Rover | DNN_Rover-master/rover/__init__.py | import threading
import socket
import time
import numpy as np
import cv2
from rover.blowfish import Blowfish
from rover.adpcm import decodeADPCMToPCM
from rover.byteutils import *
# Base class for handling sockets, encryption, and movement
class Rover:
def __init__(self):
""" Creates a Rover object that y... | 11,218 | 31.518841 | 103 | py |
DNN_Rover | DNN_Rover-master/rover/Pygame_UI.py | import pygame
import numpy as np
import cv2
from scipy.misc import bytescale
import os
import time
class Pygame_UI:
def __init__(self, fps, speed):
pygame.init()
pygame.display.set_caption('Rover Dashboard')
self.screen_size = [700, 480]
self.screen = pygame.display.set_mode(self.sc... | 1,930 | 29.650794 | 65 | py |
StodAp | StodAp-master/main.py | #!/usr/bin/python
# -*- coding: utf-8 -*-
import functions
import model
import config
import cPickle as pickle
import time
#functions.LoadODPs()
#functions.LoadODPData()
#functions.WriteWikiPages()
#functions.CalculateStats()
#functions.TagsOverN(1)
#functions.TagsDistribution()
#functions.TagsPerDataset()
#functions... | 3,688 | 23.430464 | 129 | py |
StodAp | StodAp-master/functions.py | ##########################################################
#This scripts walks through several CKAN instances given by the CKAN instances project (https://github.com/ckan/ckan-instances/blob/gh-pages/config/instances.json) and collects information about the portals, the datasets, and tags. Data are stored as objects of... | 16,020 | 26.154237 | 289 | py |
StodAp | StodAp-master/model.py | ##########################################################
#This scripts walks through several CKAN instances given by the CKAN instances project (https://github.com/ckan/ckan-instances/blob/gh-pages/config/instances.json) and collects information about the portals, the datasets, and tags. Data are stored as objects of... | 9,593 | 25.576177 | 289 | py |
StodAp | StodAp-master/lib.py | import time
from functools import wraps
def retry(ExceptionToCheck, tries=2, delay=2, backoff=1, logger=None):
"""Retry calling the decorated function using an exponential backoff.
http://www.saltycrane.com/blog/2009/11/trying-out-retry-decorator-python/
original from: http://wiki.python.org/moin/PythonD... | 1,825 | 28.934426 | 77 | py |
StodAp | StodAp-master/config.py | ##########################################################
#This scripts walks through several CKAN instances given by the CKAN instances project (https://github.com/ckan/ckan-instances/blob/gh-pages/config/instances.json) and collects information about the portals, the datasets, and tags. Data are stored as objects of... | 881 | 32.923077 | 289 | py |
StodAp | StodAp-master/main_data_collection.py | #!/usr/bin/python
# -*- coding: utf-8 -*-
import functions
functions.LoadODPs()
functions.LoadODPData()
functions.ListCooccurences()
| 135 | 14.111111 | 28 | py |
StodAp | StodAp-master/main_data_analysis.py | #!/usr/bin/python
# -*- coding: utf-8 -*-
import functions
import config
import cPickle as pickle
functions.CalculateStats()
#functions.TagsOverN(1)
#functions.TagsDistribution()
#functions.TagsPerDataset()
#functions.Similarity2('naive')
#functions.WriteTagsCSV()
#functions.GetLanguage()
#functions.MostUsedTags()
#f... | 418 | 19.95 | 42 | py |
Rep-Learning | Rep-Learning-main/nips_supp/Meta_learning.py | from scipy.io import loadmat
import numpy as np
import scipy
from scipy.optimize import minimize
from sklearn.linear_model import LinearRegression
import matplotlib.pyplot as plt
import numpy.linalg as npl
class optimal_representation_matrix:
def __init__(self, beta, p, n, sigma_square, epsilon, beta_star):
... | 22,568 | 50.645309 | 261 | py |
Rep-Learning | Rep-Learning-main/nips_supp/mom_iota.py | from scipy.io import loadmat
import numpy as np
# import torch
# import torch.nn as nn
# import torch.optim as optim
# from torchvision import models
# import torch.utils.data
# from torch.utils import data
# from torch.utils.data import DataLoader, TensorDataset
import scipy
from scipy.optimize import minimize
from sk... | 1,116 | 23.822222 | 66 | py |
Rep-Learning | Rep-Learning-main/nips_supp/SVM_MNIST.py | import numpy as np
import numpy.linalg as npl
import matplotlib.pyplot as plt
from keras.datasets import mnist
import cvxpy as cp
(train_X, train_y), (test_X, test_y) = mnist.load_data()
train_X=train_X.astype(float)
test_X=test_X.astype(float)
for i in range(len(train_X)):
train_X[i]-=np.mean(train_X[i])
trai... | 3,339 | 28.298246 | 115 | py |
Rep-Learning | Rep-Learning-main/nips_supp/Optimal_weighting.py | from scipy.io import loadmat
import numpy as np
import scipy
from scipy.optimize import minimize
from sklearn.linear_model import LinearRegression
import matplotlib.pyplot as plt
def computeLeftError(bSi, B, sigma_square, p, n, R):
# bsi and B are vectors
gamma = p/n
theta = R/p
idx_trun = int(p * thet... | 12,764 | 47.721374 | 225 | py |
FORK | FORK-master/TD3-FORK/TD3_FORK.py | import copy
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
class Actor(nn.Module):
def __init__(self, state_dim, action_dim, max_action):
super(Actor, self).__init__()
self.l1 = nn.Linear(state_dim, 25... | 10,157 | 31.14557 | 108 | py |
FORK | FORK-master/TD3-FORK/utils.py | import numpy as np
import torch
import math
class ReplayBuffer(object):
def __init__(self, state_dim, action_dim, max_size=int(1e6)):
self.max_size = max_size
self.ptr = 0
self.size = 0
self.state = np.zeros((max_size, state_dim))
self.action = np.zeros((max_size, action_dim))
self.next_state = np.zeros... | 3,165 | 32.680851 | 113 | py |
FORK | FORK-master/TD3-FORK/TD3.py | import copy
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
# Implementation of Twin Delayed Deep Deterministic Policy Gradients (TD3)
# Paper: https://arxiv.org/abs/1802.09477
class Actor(nn.Module):
def _... | 4,752 | 26.473988 | 93 | py |
FORK | FORK-master/TD3-FORK/main_td3_fork.py | import numpy as np
import torch
import gym
import argparse
import os
import copy
import utils
import TD3
import pandas as pd
import json,os
import TD3_FORK
def eval_policy(policy, env_name,eval_episodes=10):
eval_env = gym.make(env_name)
avg_reward = 0.
for _ in range(eval_episodes):
state, done = eval_env.reset(... | 9,548 | 44.255924 | 258 | py |
FORK | FORK-master/SAC-FORK/replay_memory.py | import random
import numpy as np
class ReplayMemory:
def __init__(self, capacity, seed):
random.seed(seed)
self.capacity = capacity
self.buffer = []
self.position = 0
def push(self, state, action, reward, next_state, done):
if len(self.buffer) < self.capacity:
... | 765 | 30.916667 | 78 | py |
FORK | FORK-master/SAC-FORK/SAC.py | import os
import torch
import torch.nn.functional as F
from torch.optim import Adam
from utils import soft_update, hard_update
from model import GaussianPolicy, QNetwork, DeterministicPolicy
class SAC(object):
def __init__(self, num_inputs, action_space, args):
self.gamma = args.gamma
self.tau = ... | 5,765 | 45.128 | 133 | py |
FORK | FORK-master/SAC-FORK/utils.py | import numpy as np
import torch
import math
class ReplayBuffer(object):
def __init__(self, state_dim, action_dim, max_size=int(1e6)):
self.max_size = max_size
self.ptr = 0
self.size = 0
self.state = np.zeros((max_size, state_dim))
self.action = np.zeros((max_size, action_dim))
self.next_state = np.zeros... | 3,165 | 32.680851 | 113 | py |
FORK | FORK-master/SAC-FORK/model.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.distributions import Normal
LOG_SIG_MAX = 2
LOG_SIG_MIN = -20
epsilon = 1e-6
# Initialize Policy weights
def weights_init_(m):
if isinstance(m, nn.Linear):
torch.nn.init.xavier_uniform_(m.weight, gain=1)
torch.nn.init.co... | 6,142 | 31.162304 | 84 | py |
FORK | FORK-master/SAC-FORK/main_sac_fork.py | import argparse
import datetime
import gym
import numpy as np
import itertools
import os
import json
import pandas as pd
import torch
import SAC
import SAC_FORK
from replay_memory import ReplayMemory
def eval_policy(policy, env_name, eval_episodes=10):
eval_env = gym.make(env_name)
avg_reward = 0.
for _ ... | 9,260 | 44.62069 | 265 | py |
FORK | FORK-master/SAC-FORK/SAC_FORK.py | import os
import torch
import torch.nn.functional as F
from torch.optim import Adam
from utils import soft_update, hard_update
from model import GaussianPolicy, QNetwork, DeterministicPolicy, Sys_R, SysModel
class SAC_FORK(object):
def __init__(self, num_inputs, action_space, args):
self.gamma = args.gam... | 8,966 | 47.733696 | 172 | py |
SIVAND | SIVAND-master/MyDD.py | import DD
import helper as hp
###############################################################
g_model = None
g_original_method_name = None
g_predicted_method_name = None
g_all_data = []
g_cnt_dict = {}
g_cnt_pass = [0, 0, 0]
###############################################################
class MyDD(DD.DD):
def... | 3,896 | 37.584158 | 110 | py |
SIVAND | SIVAND-master/DD.py | #! /usr/bin/env python
# $Id: DD.py,v 1.2 2001/11/05 19:53:33 zeller Exp $
# Enhanced Delta Debugging class
# Copyright (c) 1999, 2000, 2001 Andreas Zeller.
# This module (written in Python) implements the base delta debugging
# algorithms and is at the core of all our experiments. This should
# easily run on any pla... | 28,834 | 30.342391 | 116 | py |
SIVAND | SIVAND-master/helper.py | import pandas as pd
import subprocess
import javalang
from datetime import datetime
import json
###############################################################
g_deltas_types = ["token", "char"]
g_simp_file = "data/tmp/sm_test.java"
JAR_LOAD_JAVA_METHOD = "others/LoadJavaMethod/target/jar/LoadJavaMethod.jar"
# TODO ... | 3,405 | 26.031746 | 85 | py |
SIVAND | SIVAND-master/others/load_java_method.py | import subprocess
from pathlib import Path
JAR_LOAD_JAVA_METHOD = "LoadJavaMethod/target/jar/LoadJavaMethod.jar"
def load_method(file_path):
cmd = ['java', '-jar', JAR_LOAD_JAVA_METHOD, file_path]
contents = subprocess.check_output(cmd, encoding="utf-8", close_fds=True)
contents = contents.split()
na... | 695 | 30.636364 | 77 | py |
SIVAND | SIVAND-master/others/get_ast_nodes.py | import subprocess
from pathlib import Path
JAR_JAVA_AST_DATA = "GetAstNodes/target/jar/GetAstNodes.jar"
INNER_DELIMITER = " ___INNER___ "
OUTER_DELIMITER = " ___OUTER___ "
def get_ast_data(str_code):
cmd = ['java', '-jar', JAR_JAVA_AST_DATA, str_code]
content = subprocess.check_output(cmd, encoding="utf-8", ... | 941 | 35.230769 | 76 | py |
SIVAND | SIVAND-master/others/get_tokens_java.py | import javalang
from pathlib import Path
def get_tokens(str_code):
tokens = list(javalang.tokenizer.tokenize(str_code))
tokens = [token.value for token in tokens]
return tokens
if __name__ == '__main__':
program = Path('sample_input.java').read_text()
print("program:\n{}".format(program))
pr... | 367 | 23.533333 | 56 | py |
SIVAND | SIVAND-master/models/dd-great/sm_helper.py | import os
import json
from datetime import datetime
#######################################
root_path = "/scratch/rabin/deployment/root-simplify/sm-great/"
vocabulary_path = root_path + "vocab.txt"
config_path = root_path + "config.yml"
vm_json_root_path = "/scratch/rabin/deployment/root-simplify/data_selection/vm_r... | 6,095 | 30.42268 | 102 | py |
SIVAND | SIVAND-master/models/dd-great/attn_model.py | import sys
sys.path.append('.')
sys.path.insert(0, "..")
import yaml
import tensorflow as tf
from checkpoint_tracker import Tracker
from data import data_loader, vocabulary
from meta_model import VarMisuseModel
import sm_helper as hp
###############################################################
g_model = None
g_d... | 4,510 | 38.570175 | 112 | py |
SIVAND | SIVAND-master/models/dd-great/dd_model.py | import sys
sys.path.append('.')
sys.path.insert(0, "..")
import yaml
import tensorflow as tf
from checkpoint_tracker import Tracker
from data import data_loader, vocabulary
from meta_model import VarMisuseModel
import DD
import sm_helper as hp
###############################################################
g_model... | 6,118 | 36.310976 | 112 | py |
SIVAND | SIVAND-master/models/dd-code2seq/dd_code2seq.py | from argparse import ArgumentParser
import numpy as np
import tensorflow as tf
from config import Config
from dd_model import Model
import DD
import sm_helper as hp
###############################################################
g_model = None
g_original_method_name = None
g_predicted_method_name = None
g_cnt_pass = ... | 5,296 | 37.384058 | 106 | py |
SIVAND | SIVAND-master/models/dd-code2seq/sm_helper.py | import json
import re
import statistics
import subprocess
from datetime import datetime
import javalang
import pandas as pd
###############################################################
# TODO: all (if)
g_root_path = "/scratch/rabin/deployment/root-simplify/sm-code2seq"
g_c2s_model = "/scratch/rabin/models/code2s... | 10,010 | 38.72619 | 119 | py |
SIVAND | SIVAND-master/models/dd-code2seq/attn_code2seq.py | from argparse import ArgumentParser
import numpy as np
import tensorflow as tf
from config import Config
from dd_model import Model
import sm_helper as hp
###############################################################
g_model = None
g_all_data = []
g_cnt_dict = {}
###################################################... | 3,832 | 42.556818 | 120 | py |
SIVAND | SIVAND-master/models/dd-code2seq/dd_model.py | import _pickle as pickle
import tensorflow as tf
import reader
from common import Common
class Model:
topk = 10
num_batches_to_log = 100
def __init__(self, config):
self.config = config
self.sess = tf.Session()
self.eval_queue = None
self.predict_queue = None
s... | 21,800 | 56.827586 | 142 | py |
SIVAND | SIVAND-master/models/dd-code2vec/dd_code2vec.py | from config import Config
from dd_tensorflow_model import Code2VecModel
import DD
import sm_helper as hp
###############################################################
g_model = None
g_original_method_name = None
g_predicted_method_name = None
g_all_data = []
g_cnt_dict = {}
g_cnt_pass = [0, 0, 0]
#################... | 4,192 | 36.774775 | 106 | py |
SIVAND | SIVAND-master/models/dd-code2vec/sm_helper.py | import json
import re
import subprocess
from datetime import datetime
import javalang
import pandas as pd
###############################################################
# TODO: all (if)
g_root_path = "/scratch/rabin/deployment/root-simplify/sm-code2vec"
g_c2v_model = "/scratch/rabin/models/code2vec/main/java-large... | 6,378 | 28.396313 | 105 | py |
SIVAND | SIVAND-master/models/dd-code2vec/attn_code2vec.py | from config import Config
from dd_tensorflow_model import Code2VecModel
import sm_helper as hp
###############################################################
g_model = None
g_all_data = []
g_cnt_dict = {}
###############################################################
if __name__ == '__main__':
config = Config... | 2,398 | 40.362069 | 98 | py |
SIVAND | SIVAND-master/models/dd-code2vec/dd_tensorflow_model.py | import tensorflow as tf
from typing import Dict, Optional
from path_context_reader import PathContextReader, ModelInputTensorsFormer, ReaderInputTensors, EstimatorAction
from common import common
from vocabularies import VocabType
from config import Config
from dd_model_base import Code2VecModelBase
tf.compat.v1.disa... | 11,224 | 50.255708 | 120 | py |
SIVAND | SIVAND-master/models/dd-code2vec/dd_model_base.py | import numpy as np
import abc
import os
from typing import Optional, Dict, Tuple, Iterable
from common import common
from vocabularies import Code2VecVocabs, VocabType
from config import Config
class Code2VecModelBase(abc.ABC):
def __init__(self, config: Config):
self.config = config
self.config.... | 5,679 | 41.706767 | 119 | py |
Higgs-ML | Higgs-ML-master/cnn.py | from __future__ import print_function
import os, sys
import math
import pandas as pd
import numpy as np
import keras
from keras.models import load_model
from keras import backend as K
from keras.callbacks import ModelCheckpoint, EarlyStopping
from sklearn.model_selection import train_test_split
from sklearn import ... | 3,700 | 27.689922 | 155 | py |
Higgs-ML | Higgs-ML-master/func/file.py | from __future__ import print_function
import os, sys
import shutil
def removedir(folder):
filelist=[]
rootdir=folder
filelist=os.listdir(rootdir)
for f in filelist:
filepath = os.path.join(rootdir,f)
if os.path.isfile(filepath):
os.remove(f... | 596 | 28.85 | 49 | py |
Higgs-ML | Higgs-ML-master/func/figure.py | from __future__ import print_function
import keras
import numpy as np
import matplotlib.pyplot as plt
import math
class LossHistory(keras.callbacks.Callback):
def on_train_begin(self,log={}):
self.losses = {'batch':[], 'epoch':[]}
self.accuracy = {'batch':[], 'epoch':[]}
self.val_loss = {'batch':[], 'epoch':[]... | 3,107 | 32.782609 | 158 | py |
Higgs-ML | Higgs-ML-master/func/models.py | import keras
from keras.models import Sequential
from keras.layers import Conv2D, MaxPooling2D, Dense, Dropout, Activation, Flatten
from keras.callbacks import ModelCheckpoint, EarlyStopping
from keras.optimizers import SGD, Adam, Nadam
def our_model(img_rows,img_cols):
model=Sequential()
model.add(Conv2D(64,(3,3),... | 1,906 | 36.392157 | 107 | py |
Higgs-ML | Higgs-ML-master/func/__init__.py | 0 | 0 | 0 | py | |
hyperas | hyperas-master/setup.py | from setuptools import setup
from setuptools import find_packages
setup(name='hyperas',
version='0.4.1',
description='Simple wrapper for hyperopt to do convenient hyperparameter optimization for Keras models',
url='http://github.com/maxpumperla/hyperas',
download_url='https://github.com/maxpump... | 600 | 39.066667 | 110 | py |
hyperas | hyperas-master/hyperas/distributions.py | from hyperopt.hp import choice
from hyperopt.hp import randint
from hyperopt.hp import pchoice
from hyperopt.hp import uniform
from hyperopt.hp import quniform
from hyperopt.hp import loguniform
from hyperopt.hp import qloguniform
from hyperopt.hp import normal
from hyperopt.hp import qnormal
from hyperopt.hp import lo... | 397 | 32.166667 | 35 | py |
hyperas | hyperas-master/hyperas/optim.py | import inspect
import os
import re
import sys
import nbformat
import numpy as np
from hyperopt import fmin
from nbconvert import PythonExporter
from .ensemble import VotingModel
from .utils import (
remove_imports, remove_all_comments, extract_imports, temp_string,
write_temp_files, determine_indent, with_lin... | 11,352 | 36.468647 | 136 | py |
hyperas | hyperas-master/hyperas/utils.py | import ast
import re
import warnings
from operator import attrgetter
from hyperopt import space_eval
class ImportParser(ast.NodeVisitor):
def __init__(self):
self.lines = []
self.line_numbers = []
def visit_Import(self, node):
line = 'import {}'.format(self._import_names(node.names))... | 7,226 | 30.285714 | 117 | py |
hyperas | hyperas-master/hyperas/__init__.py | 0 | 0 | 0 | py | |
hyperas | hyperas-master/hyperas/ensemble.py | import numpy as np
from keras.models import model_from_yaml
class VotingModel(object):
def __init__(self, model_list, voting='hard',
weights=None, nb_classes=None):
"""(Weighted) majority vote model for a given list of Keras models.
Parameters
----------
model_li... | 2,567 | 39.125 | 101 | py |
hyperas | hyperas-master/examples/mnist_readme.py | from __future__ import print_function
from hyperopt import Trials, STATUS_OK, tpe
from keras.datasets import mnist
from keras.layers.core import Dense, Dropout, Activation
from keras.models import Sequential
from keras.utils import np_utils
from hyperas import optim
from hyperas.distributions import choice, uniform
... | 3,140 | 34.693182 | 83 | py |
hyperas | hyperas-master/examples/lstm.py | from __future__ import print_function
from hyperopt import Trials, STATUS_OK, tpe
from hyperas import optim
from hyperas.distributions import choice, uniform
from keras.preprocessing import sequence
from keras.datasets import imdb
from keras.models import Sequential
from keras.layers.core import Dense, Dropout, Activat... | 2,374 | 34.447761 | 80 | py |
hyperas | hyperas-master/examples/mnist_distributed.py | from hyperas import optim
from hyperas.distributions import quniform, uniform
from hyperopt import STATUS_OK, tpe, mongoexp
import keras
from keras.layers import Dense, Dropout
from keras.models import Sequential
from keras.optimizers import RMSprop
from keras.datasets import mnist
import tempfile
def data():
(x_... | 2,561 | 35.084507 | 109 | py |
hyperas | hyperas-master/examples/simple.py | from __future__ import print_function
from hyperopt import Trials, STATUS_OK, tpe
from hyperas import optim
from hyperas.distributions import choice, uniform
from keras.models import Sequential
from keras.layers.core import Dense, Dropout, Activation
from keras.optimizers import RMSprop
from keras.datasets import mni... | 2,737 | 33.225 | 87 | py |
hyperas | hyperas-master/examples/complex.py | from __future__ import print_function
from hyperopt import Trials, STATUS_OK, tpe
from hyperas import optim
from hyperas.distributions import choice, uniform
from keras.models import Sequential
from keras.layers.core import Dense, Dropout, Activation
from keras.datasets import mnist
from keras.utils import np_utils
d... | 3,080 | 35.678571 | 83 | py |
hyperas | hyperas-master/examples/mnist_ensemble.py | from __future__ import print_function
from hyperopt import Trials, STATUS_OK, rand
from hyperas import optim
from hyperas.distributions import choice, uniform
from sklearn.metrics import accuracy_score
from keras.utils import np_utils
from keras.datasets import mnist
from keras.models import Sequential
from keras.layer... | 2,430 | 33.239437 | 87 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.