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
CoordFill
CoordFill-master/models/ffc.py
# Fast Fourier Convolution NeurIPS 2020 # original implementation https://github.com/pkumivision/FFC/blob/main/model_zoo/ffc.py # paper https://proceedings.neurips.cc/paper/2020/file/2fd5d41ec6cfab47e32164d5624269b1-Paper.pdf import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import ...
22,247
39.014388
125
py
CoordFill
CoordFill-master/models/models.py
import copy models = {} def register(name): def decorator(cls): models[name] = cls return cls return decorator def make(model_spec, args=None, load_sd=False): if args is not None: model_args = copy.deepcopy(model_spec['args']) model_args.update(args) else: m...
485
19.25
54
py
CoordFill
CoordFill-master/models/__init__.py
from .models import register, make from . import gan, modules, coordfill, ffc_baseline from . import misc
106
25.75
51
py
CoordFill
CoordFill-master/models/sync_batchnorm.py
# -*- coding: utf-8 -*- # File : batchnorm.py # Author : Jiayuan Mao # Email : maojiayuan@gmail.com # Date : 27/01/2018 # # This file is part of Synchronized-BatchNorm-PyTorch. # https://github.com/vacancy/Synchronized-BatchNorm-PyTorch # Distributed under MIT License. import collections import contextlib import...
16,476
43.05615
135
py
CoordFill
CoordFill-master/models/adv_loss.py
import os import numpy as np import torch import torch.nn as nn import torch.optim as optim from torch import autograd import torchvision.models as models device = torch.device("cuda" if torch.cuda.is_available() else "cpu") class AdversarialLoss(nn.Module): """ Adversarial loss https://arxiv.org/abs/1711...
1,484
28.7
89
py
CoordFill
CoordFill-master/models/coordfill.py
import torch.nn as nn import torch.nn.functional as F import torch from scipy import ndimage import numpy as np from .ffc import FFCResNetGenerator from .modules import CoordFillGenerator from .ffc import FFCResNetGenerator, FFCResnetBlock, ConcatTupleLayer, FFC_BN_ACT class AttFFC(nn.Module): """Convolutional LR...
7,669
36.598039
135
py
CoordFill
CoordFill-master/models/bn_helper.py
import torch import functools if torch.__version__.startswith('0'): from .sync_bn.inplace_abn.bn import InPlaceABNSync BatchNorm2d = functools.partial(InPlaceABNSync, activation='none') BatchNorm2d_class = InPlaceABNSync relu_inplace = False else: BatchNorm2d_class = BatchNorm2d = torch.nn.SyncBatc...
451
27.25
70
py
CoordFill
CoordFill-master/models/ffc_baseline.py
import torch.nn as nn import torch.nn.functional as F import torch from scipy import ndimage import numpy as np class ResnetBlock_remove_IN(nn.Module): def __init__(self, dim, dilation=1, use_spectral_norm=True): super(ResnetBlock_remove_IN, self).__init__() self.conv_block = nn.Sequential( ...
4,182
32.464
164
py
CoordFill
CoordFill-master/models/LPIPS/models/base_model.py
import os import torch import sys sys.path.insert(1, './LPIPS/') # import util.util as util from torch.autograd import Variable from pdb import set_trace as st from IPython import embed class BaseModel(): def __init__(self): pass; def name(self): return 'BaseModel' def initializ...
1,794
26.19697
78
py
CoordFill
CoordFill-master/models/LPIPS/models/pretrained_networks.py
from collections import namedtuple import torch from torchvision import models from IPython import embed class squeezenet(torch.nn.Module): def __init__(self, requires_grad=False, pretrained=True): super(squeezenet, self).__init__() pretrained_features = models.squeezenet1_1(pretrained=pretrained)....
6,788
35.5
121
py
CoordFill
CoordFill-master/models/LPIPS/models/networks_basic.py
from __future__ import absolute_import import sys sys.path.append('..') sys.path.append('.') import torch import torch.nn as nn import torch.nn.init as init from torch.autograd import Variable import numpy as np from pdb import set_trace as st from skimage import color from IPython import embed from . import pretrain...
10,730
37.188612
136
py
CoordFill
CoordFill-master/models/LPIPS/models/models.py
from __future__ import absolute_import def create_model(opt): model = None print(opt.model) from .siam_model import * model = DistModel() model.initialize(opt, opt.batchSize, ) print("model [%s] was created" % (model.name())) return model
269
21.5
52
py
CoordFill
CoordFill-master/models/LPIPS/models/__init__.py
0
0
0
py
CoordFill
CoordFill-master/models/LPIPS/models/dist_model.py
from __future__ import absolute_import import sys sys.path.append('..') sys.path.append('.') import numpy as np import torch from torch import nn import os from collections import OrderedDict from torch.autograd import Variable import itertools from .base_model import BaseModel from scipy.ndimage import zoom import f...
13,452
39.521084
278
py
CoordFill
CoordFill-master/models/LPIPS/util/html.py
import dominate from dominate.tags import * import os class HTML: def __init__(self, web_dir, title, image_subdir='', reflesh=0): self.title = title self.web_dir = web_dir # self.img_dir = os.path.join(self.web_dir, ) self.img_subdir = image_subdir self.img_dir = os.path.jo...
2,023
29.208955
91
py
CoordFill
CoordFill-master/models/LPIPS/util/visualizer.py
import numpy as np import os import time from . import util from . import html # from pdb import set_trace as st import matplotlib.pyplot as plt import math # from IPython import embed def zoom_to_res(img,res=256,order=0,axis=0): # img 3xXxX from scipy.ndimage import zoom zoom_factor = res/img.shape[1] ...
8,602
38.645161
116
py
CoordFill
CoordFill-master/models/LPIPS/util/util.py
from __future__ import print_function import numpy as np from PIL import Image import inspect import re import numpy as np import os import collections import matplotlib.pyplot as plt from scipy.ndimage.interpolation import zoom from skimage.measure import compare_ssim # from skimage.metrics import from skimage import...
14,095
29.912281
153
py
CoordFill
CoordFill-master/models/LPIPS/util/__init__.py
0
0
0
py
CoordFill
CoordFill-master/datasets/wrappers.py
import functools import random import math from PIL import Image import numpy as np import torch from torch.utils.data import Dataset from torchvision import transforms from datasets import register def to_mask(mask): return transforms.ToTensor()( transforms.Grayscale(num_output_channels=1)( ...
2,575
22.851852
77
py
CoordFill
CoordFill-master/datasets/datasets.py
import copy datasets = {} def register(name): def decorator(cls): datasets[name] = cls return cls return decorator def make(dataset_spec, args=None): if args is not None: dataset_args = copy.deepcopy(dataset_spec['args']) dataset_args.update(args) else: data...
432
18.681818
60
py
CoordFill
CoordFill-master/datasets/image_folder.py
import os import json from PIL import Image import pickle import imageio import numpy as np import torch from torch.utils.data import Dataset from torchvision import transforms from datasets import register @register('image-folder') class ImageFolder(Dataset): def __init__(self, path, split_file=None, split_key...
1,885
27.575758
107
py
CoordFill
CoordFill-master/datasets/__init__.py
from .datasets import register, make from . import image_folder from . import wrappers
87
21
36
py
cycle-transformer
cycle-transformer-main/test.py
# This code is released under the CC BY-SA 4.0 license. import glob import os import numpy as np import pandas as pd import pydicom import torch from skimage.metrics import structural_similarity as ssim from models import create_model from options.train_options import TrainOptions @torch.no_grad() def compute_eval_...
2,738
29.775281
86
py
cycle-transformer
cycle-transformer-main/train.py
# This code is released under the CC BY-SA 4.0 license. import time from options.train_options import TrainOptions from data import create_dataset from models import create_model from util.visualizer import Visualizer if __name__ == '__main__': opt = TrainOptions().parse() # get training options dataset = ...
3,739
57.4375
136
py
cycle-transformer
cycle-transformer-main/options/train_options.py
from .base_options import BaseOptions class TrainOptions(BaseOptions): """This class includes training options. It also includes shared options defined in BaseOptions. """ def initialize(self, parser): parser = BaseOptions.initialize(self, parser) # visdom and HTML visualization para...
3,916
80.604167
210
py
cycle-transformer
cycle-transformer-main/options/base_options.py
import argparse import os from util import util import torch import models as models class BaseOptions: """This class defines options used during both training and test time. It also implements several helper functions such as parsing, printing, and saving the options. It also gathers additional options ...
8,414
58.680851
235
py
cycle-transformer
cycle-transformer-main/options/__init__.py
"""This package options includes option modules: training options, test options, and basic options (used in both training and test)."""
136
67.5
135
py
cycle-transformer
cycle-transformer-main/options/test_options.py
from .base_options import BaseOptions class TestOptions(BaseOptions): """This class includes test options. It also includes shared options defined in BaseOptions. """ def initialize(self, parser): parser = BaseOptions.initialize(self, parser) # define shared options # parser.add_arg...
1,168
47.708333
110
py
cycle-transformer
cycle-transformer-main/models/base_model.py
import os import torch from collections import OrderedDict from abc import ABC, abstractmethod from . import networks class BaseModel(ABC): """This class is an abstract base class (ABC) for models. To create a subclass, you need to implement the following five functions: -- <__init__>: ...
10,583
44.038298
260
py
cycle-transformer
cycle-transformer-main/models/cytran_model.py
# This code is released under the CC BY-SA 4.0 license. import torch import itertools from util import ImagePool from models.conv_transformer import ConvTransformer from .base_model import BaseModel from . import networks class CyTranModel(BaseModel): @staticmethod def modify_commandline_options(parser, is_t...
10,350
54.352941
362
py
cycle-transformer
cycle-transformer-main/models/conv_transformer.py
# This code is released under the CC BY-SA 4.0 license. from einops import rearrange from torch import nn, einsum import functools class Encoder(nn.Module): def __init__(self, input_nc, ngf=16, norm_layer=nn.BatchNorm2d, n_downsampling=3): super(Encoder, self).__init__() if type(norm_layer) == fu...
6,016
34.187135
116
py
cycle-transformer
cycle-transformer-main/models/networks.py
# This code is released under the CC BY-SA 4.0 license. import torch import torch.nn as nn from torch.nn import init import functools from torch.optim import lr_scheduler ############################################################################### # Helper Functions ###############################################...
28,452
45.115073
167
py
cycle-transformer
cycle-transformer-main/models/__init__.py
"""This package contains modules related to objective functions, optimizations, and network architectures. To add a custom model class called 'dummy', you need to add a file called 'dummy_model.py' and define a subclass DummyModel inherited from BaseModel. You need to implement the following five functions: -- <__...
3,080
44.308824
250
py
cycle-transformer
cycle-transformer-main/models/cycle_gan_model.py
# This code is released under the CC BY-SA 4.0 license. import torch import itertools from util import ImagePool from .base_model import BaseModel from . import networks class CycleGANModel(BaseModel): """ This class implements the CycleGAN model, for learning image-to-image translation without paired data. ...
10,621
52.918782
362
py
cycle-transformer
cycle-transformer-main/util/image_pool.py
import random import torch class ImagePool: """This class implements an image buffer that stores previously generated images. This buffer enables us to update discriminators using a history of generated images rather than the ones produced by the latest generators. """ def __init__(self, pool_si...
2,224
39.454545
140
py
cycle-transformer
cycle-transformer-main/util/html.py
import dominate from dominate.tags import meta, h3, table, tr, td, p, a, img, br import os class HTML: """This HTML class allows us to save images and write texts into a single HTML file. It consists of functions such as <add_header> (add a text header to the HTML file), <add_images> (add a row of imag...
3,223
36.057471
157
py
cycle-transformer
cycle-transformer-main/util/visualizer.py
import numpy as np import os import sys import ntpath import time from . import util, html from subprocess import Popen, PIPE if sys.version_info[0] == 2: VisdomExceptionBase = Exception else: VisdomExceptionBase = ConnectionError def save_images(webpage, visuals, image_path, aspect_ratio=1.0, width=256): ...
10,460
46.121622
139
py
cycle-transformer
cycle-transformer-main/util/util.py
"""This module contains simple helper functions """ from __future__ import print_function import torch import numpy as np from PIL import Image import os def tensor2im(input_image, imtype=np.uint8): """"Converts a Tensor array into a numpy image array. Parameters: input_image (tensor) -- the input i...
3,175
29.538462
119
py
cycle-transformer
cycle-transformer-main/util/__init__.py
"""This package includes a miscellaneous collection of useful helper functions."""
83
41
82
py
cycle-transformer
cycle-transformer-main/util/get_data.py
from __future__ import print_function import os import tarfile import requests from warnings import warn from zipfile import ZipFile from bs4 import BeautifulSoup from os.path import abspath, isdir, join, basename class GetData(object): def __init__(self, technique='cyclegan', verbose=True): url_dict = { ...
3,093
31.229167
90
py
cycle-transformer
cycle-transformer-main/datasets/combine_A_and_B.py
import os import numpy as np import cv2 import argparse from multiprocessing import Pool def image_write(path_A, path_B, path_AB): im_A = cv2.imread(path_A, 1) # python2: cv2.CV_LOAD_IMAGE_COLOR; python3: cv2.IMREAD_COLOR im_B = cv2.imread(path_B, 1) # python2: cv2.CV_LOAD_IMAGE_COLOR; python3: cv2.IMREAD_COL...
3,002
43.161765
181
py
cycle-transformer
cycle-transformer-main/datasets/prepare_cityscapes_dataset.py
import os import glob from PIL import Image help_msg = """ The dataset can be downloaded from https://cityscapes-dataset.com. Please download the datasets [gtFine_trainvaltest.zip] and [leftImg8bit_trainvaltest.zip] and unzip them. gtFine contains the semantics segmentations. Use --gtFine_dir to specify the path to th...
4,127
40.28
142
py
cycle-transformer
cycle-transformer-main/datasets/make_dataset_aligned.py
import os from PIL import Image def get_file_paths(folder): image_file_paths = [] for root, dirs, filenames in os.walk(folder): filenames = sorted(filenames) for filename in filenames: input_path = os.path.abspath(root) file_path = os.path.join(input_path, filename) ...
2,257
34.28125
97
py
cycle-transformer
cycle-transformer-main/data/colorization_dataset.py
import os from data.base_dataset import BaseDataset, get_transform from data import make_dataset from skimage import color # require skimage from PIL import Image import numpy as np import torchvision.transforms as transforms class ColorizationDataset(BaseDataset): """This dataset class can load a set of natural...
2,704
38.202899
141
py
cycle-transformer
cycle-transformer-main/data/base_dataset.py
"""This module implements an abstract base class (ABC) 'BaseDataset' for datasets. It also includes common transformation functions (e.g., get_transform, __scale_width), which can be later used in subclasses. """ import random import numpy as np import torch.utils.data as data from PIL import Image import torchvision....
5,400
33.183544
141
py
cycle-transformer
cycle-transformer-main/data/unaligned_dataset.py
import os from data.base_dataset import BaseDataset, get_transform from data import make_dataset from PIL import Image import random class UnalignedDataset(BaseDataset): """ This dataset class can load unaligned/unpaired datasets. It requires two directories to host training images from domain A '/path/t...
3,286
44.652778
122
py
cycle-transformer
cycle-transformer-main/data/ct_dataset.py
# This code is released under the CC BY-SA 4.0 license. import pickle import numpy as np import pydicom from data.base_dataset import BaseDataset class CTDataset(BaseDataset): def __init__(self, opt): BaseDataset.__init__(self, opt) self.raw_data = pickle.load(open(opt.dataroot, "rb")) ...
1,330
26.163265
69
py
cycle-transformer
cycle-transformer-main/data/image_folder.py
"""A modified image folder class We modify the official PyTorch image folder (https://github.com/pytorch/vision/blob/master/torchvision/datasets/folder.py) so that this class can load images from both current directory and its subdirectories. """ import torch.utils.data as data from PIL import Image import os IMG_E...
1,885
27.575758
122
py
cycle-transformer
cycle-transformer-main/data/aligned_dataset.py
import os from data.base_dataset import BaseDataset, get_params, get_transform from data import make_dataset from PIL import Image class AlignedDataset(BaseDataset): """A dataset class for paired image dataset. It assumes that the directory '/path/to/data/train' contains image pairs in the form of {A,B}. ...
2,444
39.081967
118
py
cycle-transformer
cycle-transformer-main/data/__init__.py
"""This package includes all the modules related to data loading and preprocessing To add a custom dataset class called 'dummy', you need to add a file called 'dummy_dataset.py' and define a subclass 'DummyDataset' inherited from BaseDataset. You need to implement four functions: -- <__init__>: ...
3,270
37.034884
176
py
cycle-transformer
cycle-transformer-main/data/template_dataset.py
from data.base_dataset import BaseDataset, get_transform # from data.image_folder import make_dataset # from PIL import Image class TemplateDataset(BaseDataset): """A template dataset class for you to implement custom datasets.""" @staticmethod def modify_commandline_options(parser, is_train): """...
2,822
43.809524
156
py
cycle-transformer
cycle-transformer-main/data/single_dataset.py
from data.base_dataset import BaseDataset, get_transform from data import make_dataset from PIL import Image class SingleDataset(BaseDataset): """This dataset class can load a set of images specified by the path --dataroot /path/to/data. It can be used for generating CycleGAN results only for one side with t...
1,482
35.170732
105
py
GreedyAC
GreedyAC-master/main.py
# Import modules import numpy as np import environment import experiment import pickle from utils import experiment_utils as exp_utils import click import json from copy import deepcopy import os import utils.hypers as hypers import socket @click.command(help="Run an experiment outlined by an algorithm and " + ...
9,203
36.721311
79
py
GreedyAC
GreedyAC-master/environment.py
# Import modules import gym from copy import deepcopy from env.PendulumEnv import PendulumEnv from env.Acrobot import AcrobotEnv import env.MinAtar as MinAtar import numpy as np class Environment: """ Class Environment is a wrapper around OpenAI Gym environments, to ensure logging can be done as well as t...
7,743
28.444867
79
py
GreedyAC
GreedyAC-master/experiment.py
#!/usr/bin/env python3 # Import modules import time from datetime import datetime from copy import deepcopy import numpy as np class Experiment: """ Class Experiment will run a single experiment, which consists of a single run of agent-environment interaction. """ def __init__(self, agent, env, e...
9,747
32.613793
79
py
GreedyAC
GreedyAC-master/combine.py
#!/usr/bin/env python3 import click import utils.experiment_utils as exp import utils.hypers as hypers import json import os import pickle import signal import shutil import sys from tqdm import tqdm signal.signal(signal.SIGINT, lambda: exit(0)) @click.command(help="Combine multiple data dictionaries into one") @c...
2,542
28.229885
79
py
GreedyAC
GreedyAC-master/env/PendulumEnv.py
#!/usr/bin/env python3 # Adapted from OpenAI Gym Pendulum-v0 # Import modules import gym from gym import spaces from gym.utils import seeding import numpy as np from os import path class PendulumEnv(gym.Env): """ PendulumEnv is a modified version of the Pendulum-v0 OpenAI Gym environment. In this versio...
8,838
31.377289
79
py
GreedyAC
GreedyAC-master/env/MinAtar.py
from copy import deepcopy import gym from gym import spaces from gym.envs import register import numpy as np from minatar import Environment class GymEnv(gym.Env): """ GymEnv wraps MinAtar environments to change their interface to the OpenAI Gym interface """ metadata = {"render.modes": ["human",...
3,720
23.320261
79
py
GreedyAC
GreedyAC-master/env/Acrobot.py
"""classic Acrobot task""" import numpy as np from numpy import sin, cos, pi from gym import spaces import gym # TODO: Redo documentation string for class class AcrobotEnv(gym.Env): """ Acrobot is a 2-link pendulum with only the second joint actuated. Initially, both links point downwards. The goal is ...
10,907
32.155015
93
py
GreedyAC
GreedyAC-master/env/__init__.py
0
0
0
py
GreedyAC
GreedyAC-master/utils/plot_utils.py
# Import modules import matplotlib.pyplot as plt from matplotlib.lines import Line2D from matplotlib import ticker, gridspec import experiment_utils as exp import numpy as np from scipy import ndimage from scipy import stats as st import seaborn as sns from collections.abc import Iterable import pickle import matplotli...
23,905
37.682848
79
py
GreedyAC
GreedyAC-master/utils/runs.py
import numpy as np from copy import deepcopy TRAIN = "train" EVAL = "eval" def episodes_to(in_data, i, type_=TRAIN): """ Restricts the number of `type_` episodes to be from episode 0 to the episode right before episode i. The input data dictionary is not changed. If `type_` is 'train', then the t...
7,984
31.72541
79
py
GreedyAC
GreedyAC-master/utils/plot_mse.py
# Script to plot mean learning curves with standard error from pprint import pprint import pickle import runs import seaborn as sns from tqdm import tqdm import os from pprint import pprint import matplotlib.pyplot as plt import numpy as np import hypers import json import sys import plot_utils as plot import matplotli...
2,814
24.36036
79
py
GreedyAC
GreedyAC-master/utils/experience_replay.py
# Import modules import numpy as np import torch from abc import ABC, abstractmethod # Class definitions class ExperienceReplay(ABC): """ Abstract base class ExperienceReplay implements an experience replay buffer. The specific kind of buffer is determined by classes which implement this base class. F...
9,362
33.422794
79
py
GreedyAC
GreedyAC-master/utils/hypers.py
from functools import reduce from collections.abc import Iterable from copy import deepcopy import numpy as np import pickle from tqdm import tqdm try: from utils.runs import expand_episodes except ModuleNotFoundError: from runs import expand_episodes TRAIN = "train" EVAL = "eval" def sweeps(parameters, ind...
28,864
33.945521
79
py
GreedyAC
GreedyAC-master/utils/experiment_utils.py
# Import modules import numpy as np import bootstrapped.bootstrap as bs import bootstrapped.stats_functions as bs_stats try: import runs except ModuleNotFoundError: import utils.runs def create_agent(agent, config): """ Creates an agent given the agent name and configuration dictionary Parameters...
25,362
34.37378
79
py
GreedyAC
GreedyAC-master/agent/Random.py
#!/usr/bin/env python3 # Adapted from https://github.com/pranz24/pytorch-soft-actor-critic # Import modules import torch import numpy as np from agent.baseAgent import BaseAgent class Random(BaseAgent): """ Random implement a random agent, which is one which samples uniformly from all available actions....
2,248
24.556818
78
py
GreedyAC
GreedyAC-master/agent/baseAgent.py
#!/usr/bin/env python3 # Import modules from abc import ABC, abstractmethod # TODO: Given a data dictionary generated by main, create a static # function to initialize any agent based on this dict. Note that since the # dict has the agent name, only one function is needed to create ANY agent # we could also use the e...
3,716
28.975806
77
py
GreedyAC
GreedyAC-master/agent/nonlinear/VACDiscrete.py
# Import modules import torch import inspect import time from gym.spaces import Box, Discrete import numpy as np import torch.nn.functional as F from torch.optim import Adam from agent.baseAgent import BaseAgent import agent.nonlinear.nn_utils as nn_utils from agent.nonlinear.policy.MLP import Softmax from agent.nonlin...
9,344
37.29918
78
py
GreedyAC
GreedyAC-master/agent/nonlinear/GreedyAC.py
# Import modules from gym.spaces import Box, Discrete import torch import torch.nn.functional as F from torch.optim import Adam import numpy as np from agent.baseAgent import BaseAgent from utils.experience_replay import TorchBuffer as ExperienceReplay from agent.nonlinear.value_function.MLP import Q as QMLP from agent...
11,905
40.340278
79
py
GreedyAC
GreedyAC-master/agent/nonlinear/GreedyACDiscrete.py
# Import modules from gym.spaces import Box, Discrete import inspect import torch import torch.nn.functional as F from torch.optim import Adam import numpy as np from agent.baseAgent import BaseAgent from utils.experience_replay import TorchBuffer as ExperienceReplay from agent.nonlinear.value_function.MLP import Q as ...
8,572
36.436681
78
py
GreedyAC
GreedyAC-master/agent/nonlinear/SAC.py
# Import modules import torch import numpy as np import torch.nn.functional as F from torch.optim import Adam from agent.baseAgent import BaseAgent import agent.nonlinear.nn_utils as nn_utils from agent.nonlinear.policy.MLP import SquashedGaussian, Gaussian from agent.nonlinear.value_function.MLP import DoubleQ, Q from...
20,671
35.587611
79
py
GreedyAC
GreedyAC-master/agent/nonlinear/SACDiscrete.py
#!/usr/bin/env python3 # Import modules import os from gym.spaces import Box import torch import numpy as np import torch.nn.functional as F from torch.optim import Adam from agent.baseAgent import BaseAgent import agent.nonlinear.nn_utils as nn_utils from agent.nonlinear.policy.MLP import Softmax from agent.nonlinear...
13,490
36.475
79
py
GreedyAC
GreedyAC-master/agent/nonlinear/VAC.py
# Import modules import torch import inspect from gym.spaces import Box, Discrete import numpy as np import torch.nn.functional as F from torch.optim import Adam from agent.baseAgent import BaseAgent import agent.nonlinear.nn_utils as nn_utils from agent.nonlinear.policy.MLP import Gaussian from agent.nonlinear.value_f...
10,808
38.021661
78
py
GreedyAC
GreedyAC-master/agent/nonlinear/nn_utils.py
# Import modules import torch import torch.nn as nn import numpy as np def weights_init_(layer, init="kaiming", activation="relu"): """ Initializes the weights for a fully connected layer of a neural network. Parameters ---------- layer : torch.nn.Module The layer to initialize init : ...
6,135
31.638298
79
py
GreedyAC
GreedyAC-master/agent/nonlinear/policy/MLP.py
# Import modules import torch import time import numpy as np import torch.nn as nn import torch.nn.functional as F from torch.distributions import Normal, Independent from agent.nonlinear.nn_utils import weights_init_ # Global variables EPSILON = 1e-6 class SquashedGaussian(nn.Module): """ Class SquashedGau...
16,553
31.206226
79
py
GreedyAC
GreedyAC-master/agent/nonlinear/value_function/MLP.py
#!/usr/bin/env python3 # Import modules import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import agent.nonlinear.nn_utils as nn_utils # Class definitions class V(nn.Module): """ Class V is an MLP for estimating the state value function `v`. """ def __init__(self, n...
8,998
30.798587
78
py
ecdata
ecdata-master/scripts/make_tables.py
import sys import os from files import HOME sys.path.append(os.path.join(HOME, 'lmfdb')) from lmfdb import db db.create_table(name='ec_curvedata', search_columns={ 'text': ['Clabel', 'lmfdb_label', 'Ciso', 'lmfdb_iso'], 'numeric': ['regulator', 'absD', 'faltings...
7,542
43.89881
179
py
ecdata
ecdata-master/scripts/ecdb.py
import os import sys sys.path.insert(0, '/home/jec/ecdata/scripts/') from sage.all import (EllipticCurve, Integer, ZZ, Set, factorial, mwrank_get_precision, mwrank_set_precision, srange, prod, copy, gcd) from magma import get_magma from red_gens import reduce_tgens, reduce_gens from trace_hash i...
41,373
41.046748
189
py
ecdata
ecdata-master/scripts/labels.py
# Function to create alllabels file mapping Cremona labels to LMFDB labels # # Input: curves file, e.g. curves.230000-239999 # # Output: alllabels file, e.g. alllabels.230000-239999 # # Format: conductor iso number conductor lmfdb_iso lmfdb_number # # NB we do this by computing the isogeny class and (re)sorting it in #...
1,410
36.131579
74
py
ecdata
ecdata-master/scripts/galrep.py
# Sage interface to Sutherland's Magma script for Galois images GALREP_SCRIPT_DIR = "/home/jec/galrep" def init_galrep(mag, script_dir=GALREP_SCRIPT_DIR): """ Load the 2adic magma script into this magma process """ mag.eval('cwd:=GetCurrentDirectory();') mag.eval('ChangeDirectory("{}");'.format(sc...
766
25.448276
70
py
ecdata
ecdata-master/scripts/magma.py
# Manage child Magma processes: # # User gets a Magma instance using get_magma(), which restarts after # magma_count uses (default 100). This avoid the possible problems # with using Magma on hundreds of thousands of curves, without the # overhead of starting a new one every time. # # Also, the scripts for 2adic and m...
1,106
26.675
68
py
ecdata
ecdata-master/scripts/codec.py
###################################################################### # # Utility and coding/decoding functions # ###################################################################### import re from sage.all import ZZ, QQ, RR, sage_eval, EllipticCurve, EllipticCurve_from_c4c6 whitespace = re.compile(r'\s+') def ...
8,688
31.912879
118
py
ecdata
ecdata-master/scripts/eqn.py
# Custom function to make a latex 'equation' string from a-invariants # # assume that [a1,a2,a3] are one of the 12 reduced triples. # This is the same as latex(EllipticCurve(ainvs)).replace(" # ","").replace("{3}","3").replace("{2}","2"), i.e. the only # difference is that we have x^3 instead of x^{3} (and x^2 instead...
893
39.636364
105
py
ecdata
ecdata-master/scripts/twoadic.py
# Sage interface to 2adic Magma script import os from codec import parse_twoadic_string TWOADIC_SCRIPT_DIR = "/home/jec/ecdata/scripts" def init_2adic(mag, script_dir=TWOADIC_SCRIPT_DIR): """ Load the 2adic magma script into this magma process """ script = os.path.join(script_dir, "2adic.m") mag....
731
21.875
68
py
ecdata
ecdata-master/scripts/update.py
import os import sys from lmfdb import db HOME = os.getenv("HOME") UPLOAD_DIR = os.path.join(HOME, "ecq-upload") sys.path.append(os.path.join(HOME, 'lmfdb')) all_tables = (db.ec_curvedata, db.ec_localdata, db.ec_mwbsd, db.ec_classdata, db.ec_galrep, db.ec_torsion_growth, db.ec_iwasawa) ma...
2,737
33.225
117
py
ecdata
ecdata-master/scripts/misc.py
import os from sage.all import ZZ, QQ, Integer, EllipticCurve, class_to_int try: from sage.databases.cremona import cmp_code except: pass from files import read_data, MATSCHKE_DIR, write_curvedata from moddeg import get_modular_degree from codec import (parse_int_list, point_to_weighted_proj, ...
11,920
34.373887
92
py
ecdata
ecdata-master/scripts/summarytable.py
# script used to create table.html from allbsd.* files: #countrank.awk: # cat curves.*0000-*9999 | # gawk -v FIRST=$1 -v LAST=$2 'BEGIN{printf("Curve numbers by rank in the range %d...%d:\nrank:\t0\t1\t2\t3\t4\n",FIRST,LAST);}\ # ($1>=FIRST)&&($1<=LAST){r[$5]+=1;rt+=1;}\ # END {printf("number:\t%d\t%d\t%d\t%d\t%d\nT...
6,247
33.905028
207
py
ecdata
ecdata-master/scripts/red_gens.py
###################################################################### # # Functions for Minkowski-reduction of generators, and naive reduction # of torsion generators and of generators mod torsion. # ###################################################################### pt_wt = lambda P: len(str(P)) def reduce_tgens...
6,804
31.099057
108
py
ecdata
ecdata-master/scripts/ec_utils.py
# elliptic curve utility functions for finding generators, saturating and mapping around an isogeny class from sage.all import (pari, QQ, mwrank_get_precision, mwrank_set_precision) from magma import get_magma, MagmaEffort mwrank_saturation_precision = 1000 # 500 not enough for 594594bf2 mwrank...
5,776
33.801205
148
py
ecdata
ecdata-master/scripts/sharanktable.py
# script used to create shas.html from allbsd.* files: from sage.all import isqrt # we do not call the output file "shas.html" so we can compare the new # version with the old HTML_FILENAME = "newshas.html" MAX_RANK = 4 SHA_LIST = range(2, 35) + [37, 41, 43, 47, 50, 75] def make_rankshatable(nmax=30, verbose=False...
6,552
34.61413
106
py
ecdata
ecdata-master/scripts/aplist.py
# Sage's E.aplist(100) returns a list of the Fourier coefficients for # p<100. For the aplist files, we want to replace the coefficient for # p|N with the W-eigenvalue (the root number) and append the # W-eigenvalues for p|N, p>100. Not relevant for making LMFDBupload # files. from sage.all import prime_range def w...
1,200
25.688889
70
py
ecdata
ecdata-master/scripts/moddeg.py
def get_modular_degree(E, label): degphi_magma = 0 degphi_sympow = 0 #return E.modular_degree(algorithm='sympow') try: degphi_magma = E.modular_degree(algorithm='magma') except RuntimeError: print("{}: degphi via magma failed".format(label)) try: degphi_sympow = E...
1,008
33.793103
89
py
ecdata
ecdata-master/scripts/min_quad_twist.py
# May 2023 new function for cmputing minimal quadratic twist for any curve /Q # # - for j not 0 or 1728 this only depends on the j-invariant # - for curves with CM (and j not 0, 1728) we use a lookup table for speed # - for non-CM curves it's enough to # (1) find minimal conductor; # (2) sort into isogeny classes (...
4,524
37.347458
103
py
ecdata
ecdata-master/scripts/check_gens.py
###################################################################### # # Functions to check Minkowksi-reduction of generators, and compare # ###################################################################### import os from sage.all import EllipticCurve from codec import split, parse_int_list, proj_to_point, poin...
4,640
41.972222
117
py
ecdata
ecdata-master/scripts/intpts.py
# Find integral points in a fail-safe way uing both Sage and Magma, # comparing, returning the union in all cases and outputting a warning # message if they disagree. from sage.all import Set from magma import get_magma def get_integral_points_with_sage(E, gens): return [P[0] for P in E.integral_points(mw_base=ge...
1,025
34.37931
97
py
ecdata
ecdata-master/scripts/files.py
# Functions to read data from the files: # # alllabels.*, allgens.*, alldegphi.*, allisog.*, # intpts.*, opt_man.*, 2adic.*, galrep.* # # and also torsion growth and Iwasawa data files. The latter used to # be arranged differently; now they are not, but only exist in the # ranges up to 50000. import os from sage.all i...
67,026
38.684429
217
py
ecdata
ecdata-master/scripts/trace_hash.py
# file copied from lmfdb codebase (lmfdb/lmfdb/utils/trace_hash.py) # Sage translation of the Magma function TraceHash(), just for elliptic curves /Q and /NF from sage.all import GF, ZZ, QQ, pari, prime_range TH_C = [326490430436040986,559705121321738418,1027143540648291608,1614463795034667624,455689193399227776, 8...
10,937
72.409396
105
py
Vecchia_GPR_var_select
Vecchia_GPR_var_select-master/code/func/reg_tree.py
import numpy as np from sklearn.tree import DecisionTreeRegressor def reg_tree_wrap(XTrn, yTrn, XTst, yTst, pIn): # dataTrn = np.genfromtxt(dataFn + "_train.csv", delimiter=",") # dataTst = np.genfromtxt(dataFn + "_test.csv", delimiter=",") # fkMatch = re.search(r'f([0-9]+)', dataFn) # if fkMatch: ...
1,508
30.4375
108
py
Vecchia_GPR_var_select
Vecchia_GPR_var_select-master/code/func/SVGP.py
#!/usr/bin/env python import numpy as np import gpflow import tensorflow as tf from gpflow.ci_utils import ci_niter class Matern25_aniso(gpflow.kernels.AnisotropicStationary): def K_d(self, d): sqrt5 = np.sqrt(5.0) d = tf.square(d) d = tf.reduce_sum(d, -1) d = tf.sqrt(d) t...
1,958
30.095238
76
py