repo
stringlengths
1
99
file
stringlengths
13
215
code
stringlengths
12
59.2M
file_length
int64
12
59.2M
avg_line_length
float64
3.82
1.48M
max_line_length
int64
12
2.51M
extension_type
stringclasses
1 value
mmda
mmda-main/src/mmda/predictors/hf_predictors/bibentry_predictor/predictor.py
import os import re from typing import Dict, List, Optional, Tuple from optimum.onnxruntime import ORTModelForTokenClassification import torch from transformers import AutoConfig, AutoTokenizer, AutoModelForTokenClassification from unidecode import unidecode from mmda.predictors.hf_predictors.base_hf_predictor import...
9,946
43.806306
193
py
mmda
mmda-main/src/ai2_internal/vila/interface.py
""" This file contains the classes required by Semantic Scholar's TIMO tooling. You must provide a wrapper around your model, as well as a definition of the objects it expects, and those it returns. """ import logging from typing import List import torch from pydantic import BaseModel, BaseSettings, Field from ai2_...
3,302
27.721739
92
py
mmda
mmda-main/src/ai2_internal/layout_parser/interface.py
""" This file contains the classes required by Semantic Scholar's TIMO tooling. You must provide a wrapper around your model, as well as a definition of the objects it expects, and those it returns. """ import logging from typing import List import torch from pydantic import BaseModel, BaseSettings, Field from ai2_...
3,946
32.449153
85
py
mmda
mmda-main/tests/test_recipes/core_recipe_fixtures.py
FIRST_1000_SYMBOLS = """Field\nTask\nDataset\nSOTA\nB ERT -Base\nS CI B ERT\nFrozen\nFinetune\nFrozen\nFinetune\nBio\nNER\nBC5CDR (Li et al., 2016)\n88.85 7\n85.08\n86.72\n88.73\n90.01\nJNLPBA (Collier and Kim, 2004)\n78.58\n74.05\n76.09\n75.77\n77.28\nNCBI-disease (Dogan et al., 2014)\n89.36\n84.06\n86.88\n86.39\n88.5...
249,118
509.489754
234,906
py
PRISim
PRISim-master/prisim/interferometry.py
from __future__ import division import numpy as NP import scipy.constants as FCNST from scipy import interpolate, ndimage import datetime as DT import progressbar as PGB import os, ast import copy import astropy from astropy.io import fits, ascii from astropy.coordinates import Galactic, SkyCoord, ICRS, FK5, AltAz, Ear...
579,057
57.526177
587
py
PRISim
PRISim-master/scripts/altsim_interface.py
#!python import yaml, argparse, ast, warnings import numpy as NP from astropy.io import ascii from astropy.time import Time import prisim prisim_path = prisim.__path__[0]+'/' def simparms_from_pyuvsim_to_prisim(pyuvsim_parms, prisim_parms): if not isinstance(pyuvsim_parms, dict): raise TypeError('Input p...
8,667
49.988235
376
py
PRISim
PRISim-master/scripts/run_prisim.py
#!python import os, shutil, subprocess, pwd, errno, warnings from mpi4py import MPI import yaml import h5py import argparse import copy import numpy as NP from astropy.io import fits, ascii from astropy.coordinates import Galactic, FK5, ICRS, SkyCoord, AltAz, EarthLocation from astropy import units as U from astropy.t...
122,758
51.461111
537
py
dstqa
dstqa-master/multiwoz_format.py
// Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: LicenseRef-.amazon.com.-AmznSL-1.0 // Licensed under the Amazon Software License http://aws.amazon.com/asl/ import sys import os import json import pdb import copy import random assert(len(sys.argv) == 4) ontology_...
15,023
35.914005
171
py
dstqa
dstqa-master/multiwoz_2.1_format.py
// Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: LicenseRef-.amazon.com.-AmznSL-1.0 // Licensed under the Amazon Software License http://aws.amazon.com/asl/ import sys import os import json import pdb import copy import random assert(len(sys.argv) == 4) ontology_...
18,246
35.567134
171
py
dstqa
dstqa-master/dstqa/dstqa.py
// Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: LicenseRef-.amazon.com.-AmznSL-1.0 // Licensed under the Amazon Software License http://aws.amazon.com/asl/ import pdb import math import logging import os.path import pickle import random from typing import Any, Di...
26,073
48.103578
193
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/Lorenz/generate.py
from turtle import color import numpy as np import math import torch import timeit import numpy as np import matplotlib.pyplot as plt # import matplotlib # matplotlib.rcParams['font.sans-serif'] = 'NSimSun,Times New Roman' # matplotlib.rcParams['text.usetex'] = True colors = [ [233/256, 110/256, 236/256], # #e96e...
12,969
35.432584
103
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/Lorenz/ES_ICNN.py
import torch.nn.functional as F import timeit from hessian import hessian from hessian import jacobian # from gradient import hessian # from gradient import jacobian import torch import random import numpy as np def setup_seed(seed): torch.manual_seed(seed) # torch.cuda.manual_seed_all(seed) # torch.cuda....
4,181
31.169231
169
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/Lorenz/ES_Quadratic.py
import torch.nn.functional as F import timeit from hessian import hessian from hessian import jacobian # from gradient import hessian # from gradient import jacobian import torch import random import math import numpy as np def setup_seed(seed): torch.manual_seed(seed) # torch.cuda.manual_seed_all(seed) # ...
5,582
30.016667
142
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/Lorenz/Control_Nonlinear_Icnn.py
import torch import torch.nn as nn import torch.nn.functional as F class ICNN(nn.Module): def __init__(self, input_shape, layer_sizes, activation_fn): super(ICNN, self).__init__() self._input_shape = input_shape self._layer_sizes = layer_sizes self._activation_fn = activation_fn ...
3,750
34.386792
122
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/Energy/AS.py
import torch import torch.nn.functional as F import timeit import math class Net(torch.nn.Module): def __init__(self,n_input,n_hidden,n_output): super(Net, self).__init__() torch.manual_seed(2) self.layer1 = torch.nn.Linear(n_input, n_hidden) self.layer2 = torch.nn.Linear(n_h...
1,720
21.064103
70
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/Energy/functions.py
import numpy as np import math import torch import timeit from scipy import integrate start = timeit.default_timer() np.random.seed(1) class Net(torch.nn.Module): def __init__(self,n_input,n_hidden,n_output): super(Net, self).__init__() torch.manual_seed(2) self.layer1 = torch.nn.L...
3,792
26.092857
129
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/Energy/plot.py
import numpy as np import matplotlib.pyplot as plt import torch import matplotlib matplotlib.rcParams['font.sans-serif'] = 'NSimSun,Times New Roman' matplotlib.rcParams['text.usetex'] = True def plot_grid(): plt.grid(b=True, which='major', color='gray', alpha=0.6, linestyle='dashdot', lw=1.5) # minor grid lin...
3,641
34.359223
127
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/stuart/AS.py
import torch import torch.nn.functional as F import numpy as np import timeit class Net(torch.nn.Module): def __init__(self,n_input,n_hidden,n_output): super(Net, self).__init__() torch.manual_seed(2) self.layer1 = torch.nn.Linear(n_input, n_hidden) self.layer2 = torch.nn.Lin...
1,843
22.341772
82
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/stuart/generate.py
import numpy as np from scipy import integrate import torch import matplotlib.pyplot as plt import math import timeit from scipy.integrate import odeint import sys sys.path.append('./neural_sde/stuart') from AS import * from functions import * start = timeit.default_timer() stuart_model = Net(D_in,H1,D_out) # stuar...
1,915
24.210526
96
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/stuart/functions.py
import torch import numpy as np import timeit import matplotlib.pyplot as plt ''' x = rho_1,rho_2,rho_n, w1,w2,wn-1 ''' #Transform \Tilde{\theta} to \theta def theta(W): W = torch.cat([W,torch.tensor([1.0])],0) T = torch.eye(len(W)) for i in range(len(T)): for k in range(len(T)): ...
3,921
30.376
181
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/stuart/plot.py
from functions import * import numpy as np import torch import matplotlib.pyplot as plt import os os.environ["KMP_DUPLICATE_LIB_OK"]="TRUE" # import matplotlib # matplotlib.rcParams['font.sans-serif'] = 'NSimSun,Times New Roman' # matplotlib.rcParams['text.usetex'] = True font_size = 35 def plot_grid(): plt.grid(b...
4,294
34.204918
184
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/inverted_pendulum/invert_pendulum_control_1227.py
import numpy as np import math import torch import matplotlib.pyplot as plt from matplotlib import cm import matplotlib.gridspec as gridspec from functions import * from base_function import colors alpha = 1.0 fontsize=35 fontsize_legend = 20 MarkerSize = 60 linewidth = 5 color_w = 0.15 #0.5 framealpha = 0.7 N_seg = ...
6,416
33.315508
129
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/inverted_pendulum/algo2.py
import torch import torch.nn.functional as F import numpy as np import timeit import math class Net(torch.nn.Module): def __init__(self,n_input,n_hidden,n_output): super(Net, self).__init__() torch.manual_seed(2) self.layer1 = torch.nn.Linear(n_input, n_hidden) self.layer2 = ...
2,276
24.021978
141
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/inverted_pendulum/functions.py
import numpy as np import math import torch import timeit import matplotlib.pyplot as plt from matplotlib import cm import matplotlib.gridspec as gridspec from scipy.integrate import odeint import numpy as np np.random.seed(10) class Net(torch.nn.Module): def __init__(self,n_input,n_hidden,n_output): ...
4,192
29.830882
127
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/hyper_a/plot_trajectory.py
from statistics import mean import sys sys.path.append('./neural_sde') import numpy as np import math import matplotlib.pyplot as plt import torch from mpl_toolkits.mplot3d import axes3d from matplotlib import cm import timeit # import pylustrator # pylustrator.start() start = timeit.default_timer() A = torch.load('....
816
26.233333
105
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/hyper_a/plot_loss.py
import numpy as np import matplotlib.pyplot as plt import torch import pylustrator pylustrator.start() import seaborn as sns sns.set_theme(style="white") def plot_a(a): L = np.load('./neural_sde/hyper_a/a_{}.npy'.format(a)) r_L = np.zeros(1000-len(L)) L = np.concatenate((L,r_L),axis=0) # np.concaten...
1,949
30.967213
110
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/hyper_a/AS.py
import torch import torch.nn.functional as F import numpy as np import timeit class Net(torch.nn.Module): def __init__(self,n_input,n_hidden,n_output): super(Net, self).__init__() torch.manual_seed(2) self.layer1 = torch.nn.Linear(n_input, n_hidden) self.layer2 = torch.nn.Lin...
2,236
25.011628
141
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/hyper_a/test.py
import sys sys.path.append('./neural_sde') import numpy as np import math import matplotlib.pyplot as plt import torch from mpl_toolkits.mplot3d import axes3d from matplotlib import cm import timeit A = torch.ones(2,100) # B = torch.diagonal(A) print(A[:,0:100:10].shape)
273
20.076923
39
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/hyper_a/generate.py
import numpy as np import math import torch import timeit import numpy as np import matplotlib.pyplot as plt np.random.seed(10) class Net(torch.nn.Module): def __init__(self,n_input,n_hidden,n_output): super(Net, self).__init__() torch.manual_seed(2) self.layer1 = torch.nn.Linear(n_in...
2,698
28.021505
92
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/hyper_a/u_plot.py
import matplotlib.pyplot as plt import torch import numpy as np from matplotlib import cm import matplotlib as mpl class ControlNet(torch.nn.Module): def __init__(self,n_input,n_hidden,n_output): super(ControlNet, self).__init__() torch.manual_seed(2) self.layer1 = torch.nn.Linear(n_i...
1,330
26.729167
80
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/hyper_a/functions.py
from os import stat import numpy as np import math import torch import timeit import random import matplotlib.pyplot as plt from matplotlib import cm from scipy.integrate import odeint import numpy as np np.random.seed(10) class ControlNet(torch.nn.Module): def __init__(self,n_input,n_hidden,n_output): ...
4,265
30.6
127
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/hyper_a/calculate.py
import matplotlib.pyplot as plt import torch import numpy as np def plot_grid(): plt.grid(b=True, which='major', color='gray', alpha=0.5, linestyle='dashdot', lw=1.5) # minor grid lines plt.minorticks_on() plt.grid(b=True, which='minor', color='beige', alpha=0.5, ls='-', lw=1) ''' Calculate and plot t...
1,901
40.347826
207
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/hyper_a/plot.py
import numpy as np import matplotlib.pyplot as plt from u_plot import * from plot_trajectory import * # import matplotlib # matplotlib.rcParams['font.sans-serif'] = 'NSimSun,Times New Roman' # matplotlib.rcParams['text.usetex'] = True font_size = 15 ''' Pick trajectories data for corresponding $\alpha$ ''' A = torch....
2,666
27.98913
89
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/hopf/AS.py
import torch import torch.nn.functional as F import numpy as np import timeit class Net(torch.nn.Module): def __init__(self,n_input,n_hidden,n_output): super(Net, self).__init__() torch.manual_seed(2) self.layer1 = torch.nn.Linear(n_input, n_hidden) self.layer2 = torch.nn.Lin...
2,120
24.554217
143
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/hopf/generate.py
import numpy as np import math import matplotlib.pyplot as plt import torch import timeit class Net(torch.nn.Module): def __init__(self,n_input,n_hidden,n_output): super(Net, self).__init__() torch.manual_seed(2) self.layer1 = torch.nn.Linear(n_input, n_hidden) self.layer2 = t...
3,077
27.766355
80
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/hopf/functions.py
import numpy as np import torch import matplotlib.pyplot as plt from matplotlib import cm import matplotlib.gridspec as gridspec #向量场 def f(y,t) : #parameters x1,x2 = y dydt = [-25.0*x1-x2+x1*(x1**2+x2**2),x1-25*x2+x2*(x1**2+x2**2)] return dydt #绘制向量场 def Plotflow(Xd, Yd, t): # Plot phase ...
4,576
33.674242
92
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/Echo/AS.py
import torch import torch.nn.functional as F import numpy as np import timeit import argparse parser = argparse.ArgumentParser('ODE demo') parser.add_argument('--N', type=float, default=5000) parser.add_argument('--lr', type=float, default=0.03) args = parser.parse_args() class Net(torch.nn.Module): def __i...
2,257
24.954023
141
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/Echo/generate.py
import numpy as np import torch import math class Net(torch.nn.Module): def __init__(self,n_input,n_hidden,n_output): super(Net, self).__init__() torch.manual_seed(2) self.layer1 = torch.nn.Linear(n_input, n_hidden) self.layer2 = torch.nn.Linear(n_hidden,n_hidden) self....
2,073
26.653333
77
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/hyper_b/plot_trajectory.py
import numpy as np import math import matplotlib.pyplot as plt import torch from mpl_toolkits.mplot3d import axes3d from matplotlib import cm import timeit start = timeit.default_timer() def plot_trajec(L,b): mean_data = torch.mean(L,0).detach().numpy() std_data =torch.std(L,0).detach().numpy() plt.fi...
639
28.090909
105
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/hyper_b/V_plot.py
import matplotlib.pyplot as plt import torch import numpy as np from matplotlib import cm import matplotlib as mpl # import matplotlib # matplotlib.rcParams['font.sans-serif'] = 'NSimSun,Times New Roman' # matplotlib.rcParams['text.usetex'] = True colors = [ [233/256, 110/256, 236/256], # #e96eec # [0.6, 0.6,...
2,205
28.413333
83
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/hyper_b/generate.py
import numpy as np import math import torch import timeit import numpy as np import matplotlib.pyplot as plt np.random.seed(10) class ControlNet(torch.nn.Module): def __init__(self,n_input,n_hidden,n_output): super(ControlNet, self).__init__() torch.manual_seed(2) self.layer1 = torch....
2,768
30.827586
96
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/hyper_b/u_plot.py
import matplotlib.pyplot as plt import torch import numpy as np from matplotlib import cm import matplotlib as mpl class ControlNet(torch.nn.Module): def __init__(self,n_input,n_hidden,n_output): super(ControlNet, self).__init__() torch.manual_seed(2) self.layer1 = torch.nn.Linear(n_in...
1,389
27.367347
81
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/hyper_b/calculate.py
import matplotlib.pyplot as plt import torch import numpy as np # import pylustrator # pylustrator.start() def plot_grid(): plt.grid(b=True, which='major', color='gray', alpha=0.5, linestyle='dashdot', lw=1.5) # minor grid lines plt.minorticks_on() plt.grid(b=True, which='minor', color='beige', alpha=0...
1,872
43.595238
243
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/hyper_b/ES_Quadratic.py
import sys sys.path.append('./neural_sde') import torch import torch.nn.functional as F import numpy as np import timeit from hessian import hessian from hessian import jacobian # from gradient import hessian # from gradient import jacobian class ControlNet(torch.nn.Module): def __init__(self,n_input,n_hidd...
4,311
28.737931
142
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/hyper_b/plot.py
import numpy as np import matplotlib.pyplot as plt from V_plot import * from u_plot import * from plot_trajectory import * # import matplotlib # matplotlib.rcParams['font.sans-serif'] = 'NSimSun,Times New Roman' # matplotlib.rcParams['text.usetex'] = True font_size = 15 A = torch.load('./data/hyper_b/data.pt')[:,9:14,...
2,394
26.848837
106
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/harmonic/plot_loss.py
import numpy as np import matplotlib.pyplot as plt import torch import pylustrator pylustrator.start() import seaborn as sns sns.set_theme(style="whitegrid") L1 = torch.load('./data/harmonic/loss_icnn.pt')[2:] # delete large first tow numbers L2 = torch.load('./data/harmonic/loss_quad.pt') L3 = torch.load('./data/har...
3,889
45.86747
181
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/harmonic/AS.py
import torch import torch.nn.functional as F import timeit class Net(torch.nn.Module): def __init__(self,n_input,n_hidden,n_output): super(Net, self).__init__() torch.manual_seed(2) self.layer1 = torch.nn.Linear(n_input, n_hidden) self.layer2 = torch.nn.Linear(n_hidden,n_hidd...
2,766
26.39604
143
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/harmonic/generate.py
import numpy as np import math import torch import numpy as np import timeit from AS import * from Control_Nonlinear_Icnn import * start = timeit.default_timer() # Harmonic linear oscillator model = Net(D_in,H1,D_out) # Generate trajectory with nonlinaer AS control def algo2(z,X,N,dt): model = Net(D_in,H1,D_out...
2,835
33.585366
113
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/harmonic/ES_ICNN.py
import torch import torch.nn.functional as F import timeit from hessian import hessian from hessian import jacobian from Control_Nonlinear_Icnn import * # Drift function def harmonic(x): y = [] beta = 0.5 for i in range(0,len(x)): f = [x[i,1],-x[i,0]-2*beta*x[i,1]] y.append(f) y = to...
2,972
26.527778
142
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/harmonic/ES_Quadratic.py
import torch import torch.nn.functional as F import timeit from hessian import hessian from hessian import jacobian class Net(torch.nn.Module): def __init__(self,n_input,n_hidden,n_output): super(Net, self).__init__() torch.manual_seed(2) self.layer1 = torch.nn.Linear(n_input, n_hid...
3,376
26.016
142
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/harmonic/plot.py
import numpy as np import matplotlib.pyplot as plt import torch import matplotlib matplotlib.rcParams['font.sans-serif'] = 'NSimSun,Times New Roman' matplotlib.rcParams['text.usetex'] = True import sys sys.path.append('./data/harmonic') ''' Data is dictionary {'X','Y','Z','W'},corresponds to 20 sample trajectories unde...
11,933
39.317568
114
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/harmonic/table1.py
import numpy as np import torch data = torch.load('./data/harmonic/data_long.pt') # Calculate the data in table1 def L2_norm(st,a): Y = data[st][torch.tensor([0,1,3,4,5,6,7,8,9,10,11,13,14,15,16,17,18,19]),:,:] Y = Y.detach().numpy() X = np.linalg.norm(Y,axis=2) Z = np.mean(X,0) index = np.where(Z...
513
24.7
83
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/harmonic/Control_Nonlinear_Icnn.py
import torch import torch.nn as nn import torch.nn.functional as F class ICNN(nn.Module): def __init__(self, input_shape, layer_sizes, activation_fn): super(ICNN, self).__init__() self._input_shape = input_shape self._layer_sizes = layer_sizes self._activation_fn = activation_fn ...
3,754
34.424528
122
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/code_rebuttal/model_free/functions.py
import torch import torch.nn.functional as F import numpy as np import timeit import argparse import matplotlib.pyplot as plt colors = [ [233/256, 110/256, 236/256], # #e96eec # [0.6, 0.6, 0.2], # olive # [0.5333333333333333, 0.13333333333333333, 0.3333333333333333], # wine [255/255, 165/255, 0], ...
2,097
32.301587
89
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/code_rebuttal/model_free/run.py
import numpy as np from scipy import integrate import torch import matplotlib.pyplot as plt import math import timeit from scipy.integrate import odeint from functions import * def f(x,u=0): a, b, c = 1, 1, 1 U2 = np.array([0.5, 0.74645887, 1.05370735, 0.38154169, 1.68833014, 0.83746371]) x1, x2, x3, x4, ...
4,155
29.335766
127
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/code_rebuttal/model_free/NODE.py
# import sys # sys.path.append('./neural_sde/NODE') import argparse import time import numpy as np import torch import torch.nn as nn import torch.optim as optim parser = argparse.ArgumentParser('ODE demo') parser.add_argument('--method', type=str, choices=['dopri5', 'adams'], default='dopri5') parser.add_argument('...
4,670
31.213793
118
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/code_rebuttal/model_free/NSC_train.py
import torch import torch.nn.functional as F import numpy as np import timeit import argparse parser = argparse.ArgumentParser('ODE demo') parser.add_argument('--N', type=float, default=1000) parser.add_argument('--num', type=float, default=6) parser.add_argument('--lr', type=float, default=0.05) args = parser.parse_a...
4,004
31.04
153
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/code_rebuttal/multiple_k/AS.py
import torch import torch.nn.functional as F import timeit import math class Net(torch.nn.Module): def __init__(self,n_input,n_hidden,n_output): super(Net, self).__init__() torch.manual_seed(2) self.layer1 = torch.nn.Linear(n_input, n_hidden) self.layer2 = torch.nn.Linear(n_h...
1,716
21.012821
72
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/code_rebuttal/multiple_k/functions.py
import numpy as np import math import torch import timeit from scipy import integrate import matplotlib.pyplot as plt start = timeit.default_timer() np.random.seed(1) class Net(torch.nn.Module): def __init__(self, n_input, n_hidden, n_output): super(Net, self).__init__() torch.manual_seed(2) ...
6,281
26.432314
129
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/code_rebuttal/multiple_k/plot_appendix.py
import numpy as np import matplotlib.pyplot as plt import torch # import matplotlib # matplotlib.rcParams['font.sans-serif'] = 'NSimSun,Times New Roman' # matplotlib.rcParams['text.usetex'] = True def plot_grid(): plt.grid(b=True, which='major', color='gray', alpha=0.6, linestyle='dashdot', lw=1.5) # minor gr...
2,306
30.60274
102
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/code_rebuttal/mixed_control/functions.py
import numpy as np from scipy import integrate import torch import torch.nn as nn import matplotlib.pyplot as plt import math import timeit from scipy.integrate import odeint colors = [ [233/256, 110/256, 236/256], # #e96eec # [0.6, 0.6, 0.2], # olive # [0.5333333333333333, 0.13333333333333333, 0.3333333...
2,307
31.507042
89
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/code_rebuttal/mixed_control/run.py
import numpy as np from scipy import integrate import torch import matplotlib.pyplot as plt import math import timeit from scipy.integrate import odeint from functions import * from cvxopt import solvers,matrix def f(x,u=0): u,v = x G = 9.81 # gravity L = 0.5 # length of the pole m = 0.15 # ball m...
4,956
29.598765
127
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/code_rebuttal/mixed_control/NSC_train.py
import torch import torch.nn.functional as F import numpy as np import timeit import argparse parser = argparse.ArgumentParser('ODE demo') parser.add_argument('--N', type=float, default=1000) parser.add_argument('--num', type=float, default=2) parser.add_argument('--lr', type=float, default=0.05) args = parser.parse_a...
3,379
28.137931
153
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/code_rebuttal/comparison/lqr.py
import numpy as np from cvxopt import solvers,matrix import matplotlib.pyplot as plt import torch def harmonic(n,dt): x0 = np.array([2.0,2.0]) X = np.zeros([n,2]) X[0,:]=x0 z = np.random.normal(0, 1, n) for i in range(n-1): x1,x2 = X[i,:] X[i+1,0] = x1 + (x2-4.45*x1-0.09*x2)*dt ...
662
21.1
83
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/code_rebuttal/comparison/run.py
import numpy as np from cvxopt import solvers,matrix import matplotlib.pyplot as plt import torch import seaborn as sns class ControlNet(torch.nn.Module): def __init__(self,n_input,n_hidden,n_output): super(ControlNet,self).__init__() torch.manual_seed(2) self.layer1=torch.nn.Linear(n_inp...
10,101
40.572016
116
py
MixLacune
MixLacune-main/process-lacunes.py
# -*- coding: utf-8 -*- import os import torch import torchvision import numpy as np from torch.utils.data import Dataset, DataLoader from torchvision import transforms, utils import SimpleITK as sitk import glob import torch.nn as nn import nibabel as nib import shutil device = torch.device('cuda' if torch.cud...
21,262
36.173077
155
py
SimCSE
SimCSE-main/setup.py
import io from setuptools import setup, find_packages with io.open('./README.md', encoding='utf-8') as f: readme = f.read() setup( name='simcse', packages=['simcse'], version='0.4', license='MIT', description='A sentence embedding tool based on SimCSE', author='Tianyu Gao, Xingcheng Yao, D...
767
26.428571
88
py
SimCSE
SimCSE-main/evaluation.py
import sys import io, os import numpy as np import logging import argparse from prettytable import PrettyTable import torch import transformers from transformers import AutoModel, AutoTokenizer # Set up logger logging.basicConfig(format='%(asctime)s : %(message)s', level=logging.DEBUG) # Set PATHs PATH_TO_SENTEVAL = ...
8,127
38.456311
165
py
SimCSE
SimCSE-main/simcse_to_huggingface.py
""" Convert SimCSE's checkpoints to Huggingface style. """ import argparse import torch import os import json def main(): parser = argparse.ArgumentParser() parser.add_argument("--path", type=str, help="Path of SimCSE checkpoint folder") args = parser.parse_args() print("SimCSE checkpoint -> Hugging...
1,327
29.181818
107
py
SimCSE
SimCSE-main/train.py
import logging import math import os import sys from dataclasses import dataclass, field from typing import Optional, Union, List, Dict, Tuple import torch import collections import random from datasets import load_dataset import transformers from transformers import ( CONFIG_MAPPING, MODEL_FOR_MASKED_LM_MAPP...
24,040
39.955707
144
py
SimCSE
SimCSE-main/simcse/tool.py
import logging from tqdm import tqdm import numpy as np from numpy import ndarray import torch from torch import Tensor, device import transformers from transformers import AutoModel, AutoTokenizer from sklearn.metrics.pairwise import cosine_similarity from sklearn.preprocessing import normalize from typing import List...
12,092
41.135889
160
py
SimCSE
SimCSE-main/simcse/trainers.py
import collections import inspect import math import sys import os import re import json import shutil import time import warnings from pathlib import Path import importlib.util from packaging import version from transformers import Trainer from transformers.modeling_utils import PreTrainedModel from transformers.train...
25,360
44.368515
149
py
SimCSE
SimCSE-main/simcse/models.py
import torch import torch.nn as nn import torch.nn.functional as F import torch.distributed as dist import transformers from transformers import RobertaTokenizer from transformers.models.roberta.modeling_roberta import RobertaPreTrainedModel, RobertaModel, RobertaLMHead from transformers.models.bert.modeling_bert impo...
13,807
34.405128
161
py
SimCSE
SimCSE-main/demo/gradiodemo.py
import torch from scipy.spatial.distance import cosine from transformers import AutoModel, AutoTokenizer import gradio as gr # Import our models. The package will take care of downloading the models automatically tokenizer = AutoTokenizer.from_pretrained("princeton-nlp/sup-simcse-bert-base-uncased") model = AutoModel....
2,105
40.294118
219
py
SimCSE
SimCSE-main/demo/flaskdemo.py
import json import argparse import torch import os import random import numpy as np import requests import logging import math import copy import string from tqdm import tqdm from time import time from flask import Flask, request, jsonify from flask_cors import CORS from tornado.wsgi import WSGIContainer from tornado....
2,839
32.809524
113
py
SimCSE
SimCSE-main/SentEval/examples/infersent.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # """ InferSent models. See https://github.com/facebookresearch/InferSent. """ from __future__ import absolute_import, division,...
2,463
31
92
py
SimCSE
SimCSE-main/SentEval/examples/bow.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # from __future__ import absolute_import, division, unicode_literals import sys import io import numpy as np import logging # ...
3,423
29.300885
82
py
SimCSE
SimCSE-main/SentEval/examples/googleuse.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # from __future__ import absolute_import, division import os import sys import logging import tensorflow as tf import tensorflow...
2,205
31.441176
86
py
SimCSE
SimCSE-main/SentEval/examples/models.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # """ This file contains the definition of encoders used in https://arxiv.org/pdf/1705.02364.pdf """ import numpy as np import t...
9,875
36.12782
94
py
SimCSE
SimCSE-main/SentEval/examples/gensen.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # """ Clone GenSen repo here: https://github.com/Maluuba/gensen.git And follow instructions for loading the model used in batcher...
2,429
31.4
82
py
SimCSE
SimCSE-main/SentEval/examples/skipthought.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # from __future__ import absolute_import, division, unicode_literals """ Example of file for SkipThought in SentEval """ import ...
2,048
32.048387
97
py
SimCSE
SimCSE-main/SentEval/senteval/engine.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # ''' Generic sentence evaluation scripts wrapper ''' from __future__ import absolute_import, division, unicode_literals from ...
6,525
49.2
139
py
SimCSE
SimCSE-main/SentEval/senteval/rank.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # ''' Image-Caption Retrieval with COCO dataset ''' from __future__ import absolute_import, division, unicode_literals import os...
4,643
41.605505
129
py
SimCSE
SimCSE-main/SentEval/senteval/snli.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # ''' SNLI - Entailment ''' from __future__ import absolute_import, division, unicode_literals import codecs import os import io...
4,577
39.157895
75
py
SimCSE
SimCSE-main/SentEval/senteval/utils.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # from __future__ import absolute_import, division, unicode_literals import numpy as np import re import inspect from torch impo...
2,713
27.270833
79
py
SimCSE
SimCSE-main/SentEval/senteval/binary.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # ''' Binary classifier and corresponding datasets : MR, CR, SUBJ, MPQA ''' from __future__ import absolute_import, division, uni...
3,712
38.924731
79
py
SimCSE
SimCSE-main/SentEval/senteval/mrpc.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # ''' MRPC : Microsoft Research Paraphrase (detection) Corpus ''' from __future__ import absolute_import, division, unicode_liter...
4,202
39.028571
80
py
SimCSE
SimCSE-main/SentEval/senteval/probing.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # ''' probing tasks ''' from __future__ import absolute_import, division, unicode_literals import os import io import copy impo...
6,786
38.459302
120
py
SimCSE
SimCSE-main/SentEval/senteval/sick.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # ''' SICK Relatedness and Entailment ''' from __future__ import absolute_import, division, unicode_literals import os import io...
9,243
41.599078
80
py
SimCSE
SimCSE-main/SentEval/senteval/trec.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # ''' TREC question-type classification ''' from __future__ import absolute_import, division, unicode_literals import os import...
3,565
38.622222
79
py
SimCSE
SimCSE-main/SentEval/senteval/sst.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # ''' SST - binary classification ''' from __future__ import absolute_import, division, unicode_literals import os import io im...
3,946
39.690722
94
py
SimCSE
SimCSE-main/SentEval/senteval/tools/relatedness.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # """ Semantic Relatedness (supervised) with Pytorch """ from __future__ import absolute_import, division, unicode_literals impo...
4,552
32.725926
100
py
SimCSE
SimCSE-main/SentEval/senteval/tools/validation.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # """ Validation and classification (train) : inner-kfold classifier (train, test) : kfold classifier (train, d...
10,358
40.939271
93
py
SimCSE
SimCSE-main/SentEval/senteval/tools/classifier.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # """ Pytorch Classifier class in the style of scikit-learn Classifiers include Logistic Regression and MLP """ from __future__ ...
7,737
37.118227
94
py
SimCSE
SimCSE-main/SentEval/senteval/tools/ranking.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # """ Image Annotation/Search for COCO with Pytorch """ from __future__ import absolute_import, division, unicode_literals impor...
15,275
41.433333
109
py
pytorch_conv4D
pytorch_conv4D-master/conv4d.py
import numpy as np import math import torch import torch.nn as nn import torch.nn.functional as F class Conv4d_broadcast(nn.Module): def __init__(self, in_channels, out_channels, kernel_size, padding, stride=1, padding_mode='circ...
9,176
40.337838
116
py
pytorch_conv4D
pytorch_conv4D-master/test_conv4d.py
import pytest import timeit import numpy as np import scipy.stats as sns from functools import partial import torch import torch.nn as nn from .conv4d import Conv4d_broadcast, Conv4d_groups try: import intel_extension_for_pytorch as ipex device = torch.device("xpu" if torch.xpu.is_available() else "cpu") ...
7,179
35.262626
106
py
phocnet
phocnet-master/install.py
import os import shutil import logging import argparse from subprocess import call import sys def main(cudnn_dir, no_caffe, opencv_dir, install_dir, install_caffe_dir): # init logger logging.basicConfig(level=logging.INFO) logger = logging.getLogger('install.py') # init submodules call(['git',...
2,659
41.222222
174
py
phocnet
phocnet-master/tools/predict_phocs.py
#!/usr/bin/env python ''' Script for predicting PHOCs for a number of images residing in a folder on disk. ''' import argparse import logging import os import caffe import numpy as np import cv2 from phocnet.evaluation.cnn import net_output_for_word_image_list def main(img_dir, output_dir, pretrained_phocnet, deploy...
2,673
42.836066
133
py
phocnet
phocnet-master/tools/save_deploy_proto.py
#!/usr/bin/env python import argparse import os from phocnet.caffe.model_proto_generator import ModelProtoGenerator if __name__ == '__main__': parser = argparse.ArgumentParser(description='Save a PHOCNet deploy proto file to disk.') parser.add_argument('--output_dir', '-od', action='store', type=str, default='...
1,028
59.529412
118
py