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
YouTokenToMe
YouTokenToMe-master/tests/unit_tests/utils_for_testing.py
import random import shutil from pathlib import Path from subprocess import run BASE_MODEL_FILE = "artifacts/base_model.yttm" RENAME_ID_MODEL_FILE = "artifacts/rename_model.yttm" TRAIN_FILE = "artifacts/random_train_text.txt" TEST_FILE = "artifacts/random_test_text.txt" BOS_ID = 2 EOS_ID = 3 artifacts_generated = Fal...
1,777
24.042254
81
py
YouTokenToMe
YouTokenToMe-master/youtokentome/yttm_cli.py
import _youtokentome_cython as yttmc import click @click.group() def main(): pass @click.command() @click.option( "--data", type=click.Path(exists=True), required=True, help="Training data file path.", ) @click.option( "--model", type=click.Path(), required=True, help="Output model file path...
4,130
23.3
87
py
YouTokenToMe
YouTokenToMe-master/youtokentome/__init__.py
from .youtokentome import BPE from .youtokentome import OutputType
67
21.666667
36
py
YouTokenToMe
YouTokenToMe-master/youtokentome/youtokentome.py
import _youtokentome_cython from enum import Enum from typing import List, Union, Optional, Collection class OutputType(Enum): ID = 1 SUBWORD = 2 class BPE: def __init__(self, model: str, n_threads: int = -1): self.model = model self.n_threads = n_threads self.bpe_cython = _yout...
2,732
26.33
80
py
Learning-Debiased-Disentangled
Learning-Debiased-Disentangled-master/test.py
import numpy as np import torch import random from learner import Learner import argparse if __name__ == '__main__': parser = argparse.ArgumentParser(description='Learning Debiased Representation via Disentangled Feature Augmentation (NeurIPS 21 Oral)') # training parser.add_argument("--batch_size", help=...
3,784
63.152542
170
py
Learning-Debiased-Disentangled
Learning-Debiased-Disentangled-master/learner.py
from tqdm import tqdm import wandb import numpy as np import torch import torch.nn as nn from torch.utils.data import DataLoader import os import torch.optim as optim from data.util import get_dataset, IdxDataset from module.loss import GeneralizedCELoss from module.util import get_model from util import EMA class ...
25,007
39.400646
161
py
Learning-Debiased-Disentangled
Learning-Debiased-Disentangled-master/util.py
'''Modified from https://github.com/alinlab/LfF/blob/master/util.py''' import io import torch import numpy as np import torch.nn as nn class EMA: def __init__(self, label, num_classes=None, alpha=0.9): self.label = label.cuda() self.alpha = alpha self.parameter = torch.zeros(label.size(0))...
1,178
35.84375
118
py
Learning-Debiased-Disentangled
Learning-Debiased-Disentangled-master/train.py
import numpy as np import torch import random from learner import Learner import argparse if __name__ == '__main__': parser = argparse.ArgumentParser(description='Learning Debiased Representation via Disentangled Feature Augmentation (NeurIPS 21 Oral)') # training parser.add_argument("--batch_size", help=...
4,084
59.970149
170
py
Learning-Debiased-Disentangled
Learning-Debiased-Disentangled-master/module/resnet.py
''' From https://github.com/alinlab/LfF/blob/master/module/resnet.py ''' """ Properly implemented ResNet-s for CIFAR10 as described in paper [1]. The implementation and structure of this file is hugely influenced by [2] which is implemented for ImageNet and doesn't have option A for identity. Moreover, most of the imp...
6,270
27.375566
78
py
Learning-Debiased-Disentangled
Learning-Debiased-Disentangled-master/module/mlp.py
''' Modified from https://github.com/alinlab/LfF/blob/master/module/mlp.py''' import torch import torch.nn as nn import torch.nn.functional as F class MLP_DISENTANGLE(nn.Module): def __init__(self, num_classes = 10): super(MLP_DISENTANGLE, self).__init__() self.feature = nn.Sequential( ...
2,245
26.728395
77
py
Learning-Debiased-Disentangled
Learning-Debiased-Disentangled-master/module/loss.py
'''From https://github.com/alinlab/LfF/blob/master/module/loss.py''' import torch import torch.nn as nn import torch.nn.functional as F import numpy as np class GeneralizedCELoss(nn.Module): def __init__(self, q=0.7): super(GeneralizedCELoss, self).__init__() self.q = q ...
813
28.071429
79
py
Learning-Debiased-Disentangled
Learning-Debiased-Disentangled-master/module/util.py
''' Modified from https://github.com/alinlab/LfF/blob/master/module/util.py ''' import torch.nn as nn from module.resnet import resnet20 from module.mlp import * from torchvision.models import resnet18, resnet50 def get_model(model_tag, num_classes): if model_tag == "ResNet20": return resnet20(num_classes...
1,099
34.483871
79
py
Learning-Debiased-Disentangled
Learning-Debiased-Disentangled-master/data/util.py
'''Modified from https://github.com/alinlab/LfF/blob/master/data/util.py''' import os import torch from torch.utils.data.dataset import Dataset, Subset from torchvision import transforms as T from glob import glob from PIL import Image class IdxDataset(Dataset): def __init__(self, dataset): self.dataset =...
9,788
31.73913
160
py
fast-dpsgd
fast-dpsgd-main/opacusdp.py
''' Opacus experiments for all the models ''' import time import torch import torch.nn.functional as F from opacus import PrivacyEngine from opacus.layers import DPLSTM from torch import nn, optim import data import utils from pytorch import get_data, model_dict class LSTMNet(nn.Module): def __init__(self, voca...
3,656
31.078947
99
py
fast-dpsgd
fast-dpsgd-main/runtime_experiment.py
import argparse import pprint import subprocess from utils import pr_green, pr_red def launch(expt, batch_size, epochs): """Runs expt at batch_size for all the scripts""" errors = [] # yapf: disable cmds = [ ('jax', f'CUDA_VISIBLE_DEVICES=0 python jaxdp.py {expt} --no_dpsgd --epochs {epochs} ...
5,190
59.360465
163
py
fast-dpsgd
fast-dpsgd-main/pytorch.py
''' Model file and non-differentially private file ''' import time import torch import torch.nn.functional as F from torch import nn, optim import data import utils class EmbeddingNet(nn.Module): def __init__(self, vocab_size: int, **_): super().__init__() # Embedding dimension: vocab_size + <un...
5,651
30.4
92
py
fast-dpsgd
fast-dpsgd-main/utils.py
import argparse import pickle def get_parser(experiments): parser = argparse.ArgumentParser() parser.add_argument('experiment', choices=experiments) parser.add_argument('--dpsgd', dest='dpsgd', action='store_true') parser.add_argument('--no_dpsgd', dest='dpsgd', action='store_false') parser.add_ar...
1,703
36.043478
88
py
fast-dpsgd
fast-dpsgd-main/data.py
import numpy as np import tensorflow as tf from keras.preprocessing import sequence def dataloader(x, y, batch_size): if batch_size > len(x): raise ValueError('Batch Size too big.') num_eg = len(x) assert num_eg == len(y) for i in range(0, num_eg, batch_size): yield x[i:i + batch_size]...
5,648
36.410596
96
py
fast-dpsgd
fast-dpsgd-main/jaxdp.py
''' Code for JAX implementations presented in: Enabling Fast Differentially Private SGD via Just-in-Time Compilation and Vectorization ''' import itertools import time from functools import partial import haiku as hk import jax import jax.numpy as jnp import numpy as np from jax import grad, jit, random, vmap from ja...
11,056
35.734219
99
py
fast-dpsgd
fast-dpsgd-main/tf1dp.py
"""Based on: https://github.com/tensorflow/privacy/blob/master/tutorials/mnist_dpsgd_tutorial_vectorized.py""" import os import time from functools import partial import tensorflow.compat.v1 as tf from tensorflow_privacy.privacy.analysis.gdp_accountant import (compute_eps_poisson, ...
7,118
43.49375
110
py
fast-dpsgd
fast-dpsgd-main/tf2dp.py
import time from functools import partial import tensorflow as tf from tensorflow_privacy.privacy.analysis.gdp_accountant import (compute_eps_poisson, compute_mu_poisson) from jax.tree_util import tree_multimap import data import utils def get_logreg_m...
10,368
39.346304
100
py
fast-dpsgd
fast-dpsgd-main/pyvacydp.py
''' Pyvacy implementations ''' import time import torch import torch.nn.functional as F from pyvacy import analysis, optim from torch import nn import data import utils from pytorch import get_data, model_dict def main(args): print(args) assert args.dpsgd torch.backends.cudnn.benchmark = True trai...
1,971
29.8125
90
py
fast-dpsgd
fast-dpsgd-main/owkindp.py
''' Code for Grad-CNN implementations ''' import time import torch import torch.nn.functional as F from gradcnn import crb, make_optimizer from torch import nn, optim import data import utils from pytorch import get_data class MNISTNet(crb.Module): def __init__(self, **_): super().__init__() se...
4,604
28.519231
94
py
fast-dpsgd
fast-dpsgd-main/memory_experiment.py
import argparse import pickle import subprocess from utils import pr_green, pr_red # yapf: disable CMDS = dict(( ('jax', 'python jaxdp.py {} --no_dpsgd --no_save --dummy_data'), ('tf2', 'python tf2dp.py {} --no_dpsgd --no_xla --no_save --dummy_data'), ('tf1', 'python tf1dp.py {} --no_...
5,000
37.767442
114
py
fast-dpsgd
fast-dpsgd-main/backpackdp.py
''' BackPACK experiments in this file ''' import time import torch import torch.nn.functional as F from backpack import backpack, extend from backpack.extensions import BatchGrad, BatchL2Grad from torch import nn from torch.optim import Optimizer import data import utils from pytorch import get_data, model_dict def...
4,755
31.8
98
py
nocturne
nocturne-main/setup.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Run via ```python setup.py develop``` to install Nocturne in your environment.""" import logging import multiprocessin...
3,205
30.431373
84
py
nocturne
nocturne-main/cfgs/config.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Set path to all the Waymo data and the parsed Waymo files.""" import os from pathlib import Path from hydra import com...
1,939
35.603774
88
py
nocturne
nocturne-main/examples/create_env.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Test step and rendering functions.""" import hydra from cfgs.config import set_display_window from nocturne import Act...
1,824
36.244898
74
py
nocturne
nocturne-main/examples/rendering.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Example of how to make movies of Nocturne scenarios.""" import os import hydra import imageio import matplotlib.pyplot...
6,141
28.960976
77
py
nocturne
nocturne-main/examples/nocturne_functions.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Example of how to make movies of Nocturne scenarios.""" import os import hydra import matplotlib.pyplot as plt import ...
5,998
43.768657
83
py
nocturne
nocturne-main/examples/imitation_learning/waymo_data_loader.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Dataloader for imitation learning in Nocturne.""" from collections import defaultdict import random import torch from ...
8,395
40.564356
97
py
nocturne
nocturne-main/examples/imitation_learning/model.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Model for an imitation learning agent.""" import torch from torch import nn from torch.distributions.multivariate_norma...
6,354
39.221519
103
py
nocturne
nocturne-main/examples/imitation_learning/filters.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """A streaming mean-std filter used to whiten inputs.""" import torch from torch import nn class MeanStdFilter(nn.Module...
2,385
28.825
77
py
nocturne
nocturne-main/examples/imitation_learning/train.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Imitation learning training script (behavioral cloning).""" from datetime import datetime from pathlib import Path impo...
9,424
35.111111
79
py
nocturne
nocturne-main/examples/imitation_learning/replay_video.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Replay a video of a trained controller.""" from collections import defaultdict import json from pathlib import Path imp...
8,334
43.572193
86
py
nocturne
nocturne-main/examples/sample_factory_files/visualize_sample_factory.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Use to create movies of trained policies.""" import argparse from collections import deque import json import sys impor...
11,171
39.923077
116
py
nocturne
nocturne-main/examples/sample_factory_files/run_sample_factory.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Runner script for sample factory. To run in single agent mode on one file for testing. python -m run_sample_factory a...
14,308
39.535411
120
py
nocturne
nocturne-main/examples/sample_factory_files/results/plot_successes.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Util for plotting eval_sample_factory.py output.""" import matplotlib.pyplot as plt import numpy as np if __name__ == ...
1,625
40.692308
75
py
nocturne
nocturne-main/examples/rllib_files/run_rllib.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Example run script for RLlib.""" import os import hydra from omegaconf import OmegaConf from cfgs.config import set_di...
5,607
31.229885
84
py
nocturne
nocturne-main/examples/on_policy_files/nocturne_runner.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # Code modified from https://github.com/marlbenchmark/on-policy """Runner for PPO from https://github.com/marlbenchmark/on...
21,461
37.120782
117
py
nocturne
nocturne-main/algos/ppo/env_wrappers.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # Code modified from https://github.com/marlbenchmark/on-policy """ Modified from OpenAI Baselines code to work with multi...
29,079
32.502304
99
py
nocturne
nocturne-main/algos/ppo/__init__.py
0
0
0
py
nocturne
nocturne-main/algos/ppo/base_runner.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # Code modified from https://github.com/marlbenchmark/on-policy import wandb import os import numpy as np import torch fro...
7,111
38.292818
84
py
nocturne
nocturne-main/algos/ppo/r_mappo/r_mappo.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # Code modified from https://github.com/marlbenchmark/on-policy import numpy as np import torch import torch.nn as nn from...
10,421
41.538776
116
py
nocturne
nocturne-main/algos/ppo/r_mappo/__init__.py
0
0
0
py
nocturne
nocturne-main/algos/ppo/r_mappo/algorithm/r_actor_critic.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # Code modified from https://github.com/marlbenchmark/on-policy import torch import torch.nn as nn from algos.ppo.ppo_util...
8,798
43.439394
121
py
nocturne
nocturne-main/algos/ppo/r_mappo/algorithm/rMAPPOPolicy.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # Code modified from https://github.com/marlbenchmark/on-policy import torch from algos.ppo.r_mappo.algorithm.r_actor_crit...
7,556
47.133758
120
py
nocturne
nocturne-main/algos/ppo/utils/multi_discrete.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # Code modified from https://github.com/marlbenchmark/on-policy import gym import numpy as np # An old version of OpenAI...
2,738
45.423729
198
py
nocturne
nocturne-main/algos/ppo/utils/valuenorm.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # Code modified from https://github.com/marlbenchmark/on-policy import numpy as np import torch import torch.nn as nn c...
3,604
35.785714
85
py
nocturne
nocturne-main/algos/ppo/utils/shared_buffer.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # Code modified from https://github.com/marlbenchmark/on-policy import torch import numpy as np from algos.ppo.utils.util ...
29,299
49.08547
120
py
nocturne
nocturne-main/algos/ppo/utils/util.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # Code modified from https://github.com/marlbenchmark/on-policy import numpy as np import math import torch def check(in...
2,524
28.360465
75
py
nocturne
nocturne-main/algos/ppo/utils/separated_buffer.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # Code modified from https://github.com/marlbenchmark/on-policy import torch import numpy as np from collections import de...
24,402
47.227273
231
py
nocturne
nocturne-main/algos/ppo/utils/__init__.py
0
0
0
py
nocturne
nocturne-main/algos/ppo/ppo_utils/distributions.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # Code modified from https://github.com/marlbenchmark/on-policy import torch import torch.nn as nn from .util import init ...
4,168
26.427632
85
py
nocturne
nocturne-main/algos/ppo/ppo_utils/cnn.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # Code modified from https://github.com/marlbenchmark/on-policy from torchvision import transforms import torch.nn as nn f...
2,471
29.518519
78
py
nocturne
nocturne-main/algos/ppo/ppo_utils/mlp.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # Code modified from https://github.com/marlbenchmark/on-policy import torch.nn as nn from .util import init, get_clones "...
2,308
32.463768
77
py
nocturne
nocturne-main/algos/ppo/ppo_utils/encoder.py
0
0
0
py
nocturne
nocturne-main/algos/ppo/ppo_utils/popart.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # Code modified from https://github.com/marlbenchmark/on-policy import math import numpy as np import torch import torch.n...
4,510
36.280992
79
py
nocturne
nocturne-main/algos/ppo/ppo_utils/util.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # Code modified from https://github.com/marlbenchmark/on-policy import copy import numpy as np import torch import torch....
690
25.576923
76
py
nocturne
nocturne-main/algos/ppo/ppo_utils/act.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # Code modified from https://github.com/marlbenchmark/on-policy from .distributions import Bernoulli, Categorical, DiagGau...
8,915
43.58
99
py
nocturne
nocturne-main/algos/ppo/ppo_utils/rnn.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # Code modified from https://github.com/marlbenchmark/on-policy import torch import torch.nn as nn """RNN modules.""" cl...
3,188
34.043956
88
py
nocturne
nocturne-main/nocturne/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Import file for Nocturne objects.""" from nocturne_cpp import (Action, CollisionType, ObjectType, Object, RoadLine, ...
963
29.125
82
py
nocturne
nocturne-main/nocturne/envs/base_env.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Default environment for Nocturne.""" from typing import Any, Dict, Sequence, Union from collections import defaultdict...
26,180
46.088129
113
py
nocturne
nocturne-main/nocturne/envs/wrappers.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Wrappers and env constructors for the environments.""" from gym.spaces import Box import numpy as np from nocturne.env...
3,370
30.212963
96
py
nocturne
nocturne-main/nocturne/envs/__init__.py
"""Import file for tests.""" from nocturne.envs.base_env import BaseEnv __all__ = [ "BaseEnv", ]
102
13.714286
42
py
nocturne
nocturne-main/nocturne/utils/eval/average_displacement.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Average displacement error computation.""" from collections import defaultdict from itertools import repeat import json...
9,552
41.0837
93
py
nocturne
nocturne-main/nocturne/utils/eval/goal_reaching_rate.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Goal reaching rate computation.""" from pathlib import Path import numpy as np import torch from nocturne import Simul...
4,169
37.611111
96
py
nocturne
nocturne-main/nocturne/utils/eval/collision_rate.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Collision rate computation.""" from pathlib import Path import numpy as np import torch from nocturne import Simulatio...
4,539
40.651376
113
py
nocturne
nocturne-main/nocturne/utils/eval/goal_by_intersection.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Goal reaching rate and collision rate computation as a function of number of intersections in expert trajectory.""" fro...
10,583
39.707692
118
py
nocturne
nocturne-main/scripts/utils.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Storage for SLURM running utilities.""" class Overrides(object): """Utility class used to convert commands into a...
843
30.259259
77
py
nocturne
nocturne-main/scripts/visualization/visualize_waymo_map.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Plot the text file representation of a protobuf.""" import matplotlib.patches as mpatches import matplotlib.pyplot as p...
5,023
31.205128
107
py
nocturne
nocturne-main/scripts/visualization/waymo_movie.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Make a movie from a random file.""" import os import hydra import imageio import matplotlib.pyplot as plt import numpy...
1,378
27.729167
84
py
nocturne
nocturne-main/scripts/cluster_scripts/run_sample_factory_cluster.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Run sample factory experiments on a SLURM cluster.""" import argparse import os import pathlib import shutil from datet...
3,119
30.836735
82
py
nocturne
nocturne-main/scripts/cluster_scripts/run_rllib_cluster.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Run rllib experiments on a SLURM cluster.""" import argparse import os import pathlib import shutil from datetime impor...
2,735
28.73913
82
py
nocturne
nocturne-main/scripts/cluster_scripts/utils.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Storage for SLURM running utilities.""" class Overrides(object): """Utility class used to convert commands into a...
843
30.259259
77
py
nocturne
nocturne-main/scripts/cluster_scripts/run_ppo_cluster.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Run on-policy PPO experiments on a SLURM cluster.""" import argparse import os import pathlib import shutil from dateti...
3,396
31.663462
82
py
nocturne
nocturne-main/scripts/cluster_scripts/run_imitation_cluster.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Run sample factory experiments on a SLURM cluster.""" import argparse import os import pathlib import shutil from date...
3,004
29.663265
82
py
nocturne
nocturne-main/scripts/data_analysis/data_analysis.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Utils that we use to understand the datasets we are working with.""" import os import hydra import matplotlib.pyplot a...
5,126
38.137405
82
py
nocturne
nocturne-main/scripts/data_analysis/speed_test.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Utils that we use to understand the datasets we are working with.""" import json import os import time import hydra im...
1,937
33
84
py
nocturne
nocturne-main/scripts/data_analysis/corner_case_search.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Run through the data to look for cases where there are undesirable corner cases. The cases we currently check for are:...
6,273
43.496454
102
py
nocturne
nocturne-main/scripts/json_generation/make_solvable_files.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Find all cases where collisions are required to achieve the goal. Due to errors in Waymo labeling, some space that is ...
6,495
37.898204
92
py
nocturne
nocturne-main/scripts/json_generation/waymo_scenario_construction.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Construct a scenarios.json file from a waymos protobuf.""" from collections import defaultdict import math import json...
6,947
32.403846
97
py
nocturne
nocturne-main/scripts/json_generation/run_waymo_constructor.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Utils for converting TFRecords into Nocturne compatible JSON.""" import argparse from pathlib import Path import os imp...
4,662
36.910569
83
py
nocturne
nocturne-main/scripts/paper_plots/eval_sample_factory.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Run a policy over the entire train set. TODO(ev) refactor, this is wildly similar to visualize_sample_factory """ fro...
61,047
45.318665
118
py
nocturne
nocturne-main/scripts/paper_plots/eval_il_agents.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Run script that generates summary statistics for a folder of IL agents.""" import json import os import numpy as np im...
2,665
40.65625
114
py
nocturne
nocturne-main/scripts/paper_plots/create_zsc_plot.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Utilities for plotting ZSC results.""" import os import matplotlib.pyplot as plt import numpy as np def create_heat_...
3,813
37.918367
99
py
nocturne
nocturne-main/scripts/paper_plots/generate_scenes.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Example of how to make movies of Nocturne scenarios.""" import hydra import imageio import matplotlib.pyplot as plt imp...
5,323
33.797386
79
py
nocturne
nocturne-main/tests/test_dynamics.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Test expert action computation from inverse dynamics.""" from hydra.core.global_hydra import GlobalHydra from hydra imp...
3,137
37.740741
81
py
nocturne
nocturne-main/tests/test_config.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Test configurations passed to the scenario.""" from hydra.core.global_hydra import GlobalHydra from hydra import compos...
1,705
32.45098
73
py
nocturne
nocturne-main/tests/test_rl_env.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Test step and rendering functions.""" import time import os from hydra import compose, initialize from hydra.core.glob...
2,294
34.859375
78
py
nocturne
nocturne-main/tests/test_simulation_functions.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Test that all available environment calls work + check collisions are recorded correctly.""" import os from hydra.core...
7,339
43.484848
107
py
E2E-TBSA
E2E-TBSA-master/main.py
import argparse from model import * from utils import * from evals import evaluate import random import os separator = '========================================================================================' def run(dataset, model, params): """ run the experiment :param dataset: dataset :param model...
13,387
47.683636
197
py
E2E-TBSA
E2E-TBSA-master/utils.py
import string from nltk import ngrams import numpy as np # DO NOT change the random seed, otherwise, the train-test split will be inconsistent with those in the baselines np.random.seed(7894) import os import pickle def ot2bio_ote(ote_tag_sequence): """ ot2bio function for ote tag sequence :param ote_tag_...
32,288
32.810471
113
py
E2E-TBSA
E2E-TBSA-master/model.py
import dynet_config dynet_config.set(mem='4096', random_seed=1314159) import dynet as dy import random from utils import * from evals import * from nltk import word_tokenize def norm_vec(vec): """ normalize a dynet vector expression :param vec: :return: """ sum_item = dy.sum_elems(vec) nor...
29,635
39.990318
117
py
E2E-TBSA
E2E-TBSA-master/process_data.py
# coding: UTF-8 __author__ = 'lixin77' from scrapy.selector import Selector #import cPickle import nltk from nltk import word_tokenize import sys import string def process_text(text): """ process the text and filter some special symbol :param text: :return: """ # string preprocessing and aspec...
9,144
34.583658
112
py
E2E-TBSA
E2E-TBSA-master/config.py
laptop14 = { "dim_ote_h": 50, "dim_ts_h": 50, "input_win": 1, "stm_win": 3, "optimizer": "adam", "n_epoch": 30, "dropout": 0.5, "tagging_schema": "BIEOS", "lr_decay": 0.05, "use_char": 0, "dynet_seed": 1314159, "random_seem": 13456, "epsilon": 0.5 } rest_total = { ...
906
18.297872
30
py
E2E-TBSA
E2E-TBSA-master/evals.py
from utils import * import numpy as np SMALL_POSITIVE_CONST = 1e-4 def evaluate_ote(gold_ot, pred_ot): """ evaluate the model performce for the ote task :param gold_ot: gold standard ote tags :param pred_ot: predicted ote tags :return: """ assert len(gold_ot) == len(pred_ot) n_samples ...
5,028
36.251852
111
py
fork--wilds-public
fork--wilds-public-main/setup.py
import setuptools import os import sys here = os.path.abspath(os.path.dirname(__file__)) sys.path.insert(0, os.path.join(here, 'wilds')) from version import __version__ print(f'Version {__version__}') with open("README.md", "r", encoding="utf-8") as fh: long_description = fh.read() setuptools.setup( name="w...
1,281
28.136364
128
py
fork--wilds-public
fork--wilds-public-main/examples/losses.py
import torch.nn as nn from wilds.common.metrics.loss import ElementwiseLoss, Loss, MultiTaskLoss from wilds.common.metrics.all_metrics import MSE def initialize_loss(config, d_out): if config.loss_function == 'cross_entropy': return ElementwiseLoss(loss_fn=nn.CrossEntropyLoss(reduction='none')) elif c...
939
38.166667
87
py
fork--wilds-public
fork--wilds-public-main/examples/evaluate.py
import argparse import json import os import urllib.request from ast import literal_eval from typing import Dict, List from urllib.parse import urlparse import numpy as np import torch from wilds import benchmark_datasets from wilds import get_dataset from wilds.datasets.wilds_dataset import WILDSDataset, WILDSSubset...
9,843
33.784452
124
py