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 |
|---|---|---|---|---|---|---|
crossover-sgd | crossover-sgd-master/print_model.py | import torch
import torchvision
import torchvision.datasets as datasets
import torchvision.models as models
model = models.resnet50().cuda()
for name, param in model.named_parameters():
if('bn' in name) or name.endswith(".bias"):
print(len(param.shape)) | 256 | 31.125 | 44 | py |
crossover-sgd | crossover-sgd-master/folder2lmdb.py | import os
import sys
import six
import string
import argparse
import lmdb
import pickle
import msgpack
import tqdm
from PIL import Image
import torch
import torch.utils.data as data
from torch.utils.data import DataLoader
from torchvision.transforms import transforms
from torchvision.datasets import ImageFolder
from ... | 3,736 | 28.65873 | 88 | py |
crossover-sgd | crossover-sgd-master/utils.py | # original code: https://github.com/eladhoffer/convNet.pytorch/blob/master/preprocess.py
import torch
import random
__all__ = ["Compose", "Lighting", "ColorJitter"]
class Compose(object):
"""Composes several transforms together.
Args:
transforms (list of ``Transform`` objects): list of transforms to... | 3,204 | 25.487603 | 88 | py |
crossover-sgd | crossover-sgd-master/cifar10_210303.py | import argparse
import copy
import os
import socket
import time
import random
import sys
import numpy as np
from itertools import cycle
from functools import reduce
import torch
import torch.backends.cudnn as cudnn
import torch.distributed as dist
import torch.multiprocessing as mp
from torch.multiprocessing import P... | 38,469 | 37.051434 | 342 | py |
crossover-sgd | crossover-sgd-master/cifar10_download.py | import argparse
import copy
import os
import socket
import time
import random
import sys
import numpy as np
from itertools import cycle
from functools import reduce
import torch
import torch.backends.cudnn as cudnn
import torch.distributed as dist
import torch.multiprocessing as mp
from torch.multiprocessing import P... | 1,607 | 24.125 | 118 | py |
crossover-sgd | crossover-sgd-master/imagenet_lmdb_test.py | import argparse
import copy
import os
import socket
import time
import random
import sys
import numpy as np
from itertools import cycle
from functools import reduce
import torch
import torch.backends.cudnn as cudnn
import torch.distributed as dist
import torch.multiprocessing as mp
from torch.multiprocessing import P... | 35,946 | 37.20085 | 364 | py |
crossover-sgd | crossover-sgd-master/imagenet_test_3peer.py | import argparse
import copy
import os
import socket
import time
import random
import sys
import numpy as np
from itertools import cycle
from functools import reduce
import torch
import torch.backends.cudnn as cudnn
import torch.distributed as dist
import torch.multiprocessing as mp
from torch.multiprocessing import P... | 42,087 | 36.951307 | 342 | py |
crossover-sgd | crossover-sgd-master/cifar10_test.py | import argparse
import copy
import os
import socket
import time
import random
import sys
import numpy as np
from itertools import cycle
from functools import reduce
import torch
import torch.backends.cudnn as cudnn
import torch.distributed as dist
import torch.multiprocessing as mp
from torch.multiprocessing import P... | 35,366 | 37.275974 | 363 | py |
crossover-sgd | crossover-sgd-master/imagenet_test_2group.py | import argparse
import copy
import os
import socket
import time
import random
import sys
import numpy as np
from itertools import cycle
from functools import reduce
import torch
import torch.backends.cudnn as cudnn
import torch.distributed as dist
import torch.multiprocessing as mp
from torch.multiprocessing import P... | 29,445 | 35.853567 | 352 | py |
crossover-sgd | crossover-sgd-master/unzip_imagenet.py | import numpy as np
import torchvision
import torch
import torchvision.transforms as transforms
import random
def make_dataloader():
ii64 = np.iinfo(np.int64)
r = random.randint(0, ii64.max)
torch.manual_seed(r)
normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406],
... | 1,307 | 33.421053 | 130 | py |
crossover-sgd | crossover-sgd-master/lars.py | """ Layer-wise adaptive rate scaling for SGD in PyTorch! """
import torch
from torch.optim.optimizer import Optimizer, required
import math
class LARS(Optimizer):
r"""Implements layer-wise adaptive rate scaling for SGD.
Args:
params (iterable): iterable of parameters to optimize or dicts defining
... | 6,870 | 41.41358 | 111 | py |
crossover-sgd | crossover-sgd-master/imagenet_test_morethan2group.py | import argparse
import copy
import os
import socket
import time
import random
import sys
import numpy as np
from itertools import cycle
from functools import reduce
import torch
import torch.backends.cudnn as cudnn
import torch.distributed as dist
import torch.multiprocessing as mp
from torch.multiprocessing import P... | 29,692 | 35.7943 | 351 | py |
crossover-sgd | crossover-sgd-master/220606_aws/imagenet_test.py | import argparse
import copy
import os
import socket
import time
import threading
import random
import sys
import numpy as np
import csv
from itertools import cycle
from functools import reduce
import torch
import torch.backends.cudnn as cudnn
import torch.distributed as dist
import torch.multiprocessing as mp
from to... | 29,307 | 34.057416 | 340 | py |
crossover-sgd | crossover-sgd-master/experiment_utils/cluster_manager.py | # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
"""
Cluster manager providing model checkpointing services in case of job
preemption or termination
"""
import os
impor... | 5,162 | 35.359155 | 79 | py |
crossover-sgd | crossover-sgd-master/gossip_module/ad_psgd_modified.py | # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
"""
Bi-Distributed Gossip Wrapper
:description: Multi-Threaded Bipartite-Distributed Gossip Wrapper, designed
... | 25,869 | 41.973422 | 102 | py |
crossover-sgd | crossover-sgd-master/gossip_module/graph_manager.py | # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
"""
Graph Manager Class
:description: Class provides an API for loading different peer-to-peer
communication topolog... | 10,695 | 35.505119 | 91 | py |
crossover-sgd | crossover-sgd-master/gossip_module/distributed.py | # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
"""
Distributed Gossip Wrapper
:description: Multi-Threaded Gossip Model Wrapper; designed for efficient
m... | 23,982 | 38.252046 | 94 | py |
crossover-sgd | crossover-sgd-master/gossip_module/ad_psgd.py | # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
"""
Bi-Distributed Gossip Wrapper
:description: Multi-Threaded Bipartite-Distributed Gossip Wrapper, designed
... | 17,857 | 39.402715 | 85 | py |
crossover-sgd | crossover-sgd-master/gossip_module/mixing_manager.py | # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
"""
Mixing Manager Class
:description: Class provides an API for dynamically selecting mixing weights
for ... | 1,653 | 28.017544 | 76 | py |
crossover-sgd | crossover-sgd-master/gossip_module/gossiper.py | # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
"""
Gossipers
:description: Gossiper's are designed for multi-peer communication (i.e., send
and recv from... | 13,507 | 37.594286 | 87 | py |
crossover-sgd | crossover-sgd-master/gossip_module/gossiper_modified.py | # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
"""
Gossipers
:description: Gossiper's are designed for multi-peer communication (i.e., send
and recv from... | 13,056 | 37.860119 | 87 | py |
crossover-sgd | crossover-sgd-master/gossip_module/utils/helpers.py | # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
"""
Collection of commonly used uitility functions
"""
import collections
import logging
import math
import sys
import ... | 5,542 | 31.226744 | 170 | py |
crossover-sgd | crossover-sgd-master/models/shufflenetv2.py | import torch
import torch.nn as nn
from .utils import load_state_dict_from_url
__all__ = [
'ShuffleNetV2', 'shufflenet_v2_x0_5', 'shufflenet_v2_x1_0',
'shufflenet_v2_x1_5', 'shufflenet_v2_x2_0'
]
model_urls = {
'shufflenetv2_x0.5': 'https://download.pytorch.org/models/shufflenetv2_x0.5-f707e7126e.pth',
... | 7,698 | 35.837321 | 114 | py |
crossover-sgd | crossover-sgd-master/models/_utils.py | from collections import OrderedDict
import torch
from torch import nn
from torch.jit.annotations import Dict
class IntermediateLayerGetter(nn.ModuleDict):
"""
Module wrapper that returns intermediate layers from a model
It has a strong assumption that the modules have been registered
into the model ... | 2,604 | 37.308824 | 89 | py |
crossover-sgd | crossover-sgd-master/models/inception.py | from collections import namedtuple
import warnings
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.jit.annotations import Optional
from torch import Tensor
from .utils import load_state_dict_from_url
__all__ = ['Inception3', 'inception_v3', 'InceptionOutputs', '_InceptionOutputs']
mode... | 16,694 | 36.68623 | 119 | py |
crossover-sgd | crossover-sgd-master/models/resnet.py | import torch
import torch.nn as nn
from .utils import load_state_dict_from_url
__all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101',
'resnet152', 'resnext50_32x4d', 'resnext101_32x8d',
'wide_resnet50_2', 'wide_resnet101_2']
model_urls = {
'resnet18': 'https://download.pytor... | 14,212 | 39.149718 | 107 | py |
crossover-sgd | crossover-sgd-master/models/squeezenet.py | import torch
import torch.nn as nn
import torch.nn.init as init
from .utils import load_state_dict_from_url
__all__ = ['SqueezeNet', 'squeezenet1_0', 'squeezenet1_1']
model_urls = {
'squeezenet1_0': 'https://download.pytorch.org/models/squeezenet1_0-a815701f.pth',
'squeezenet1_1': 'https://download.pytorch.or... | 5,449 | 38.492754 | 86 | py |
crossover-sgd | crossover-sgd-master/models/vgg.py | import torch
import torch.nn as nn
from .utils import load_state_dict_from_url
__all__ = [
'VGG', 'vgg11', 'vgg11_bn', 'vgg13', 'vgg13_bn', 'vgg16', 'vgg16_bn',
'vgg19_bn', 'vgg19',
]
model_urls = {
'vgg11': 'https://download.pytorch.org/models/vgg11-bbd30ac9.pth',
'vgg13': 'https://download.pytorch... | 7,233 | 38.315217 | 113 | py |
crossover-sgd | crossover-sgd-master/models/mnasnet.py | import warnings
import torch
import torch.nn as nn
from .utils import load_state_dict_from_url
__all__ = ['MNASNet', 'mnasnet0_5', 'mnasnet0_75', 'mnasnet1_0', 'mnasnet1_3']
_MODEL_URLS = {
"mnasnet0_5":
"https://download.pytorch.org/models/mnasnet0.5_top1_67.823-3ffadce67e.pth",
"mnasnet0_75": None,
... | 10,608 | 40.120155 | 83 | py |
crossover-sgd | crossover-sgd-master/models/utils.py | try:
from torch.hub import load_state_dict_from_url
except ImportError:
from torch.utils.model_zoo import load_url as load_state_dict_from_url
| 151 | 29.4 | 74 | py |
crossover-sgd | crossover-sgd-master/models/densenet.py | import re
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.checkpoint as cp
from collections import OrderedDict
from .utils import load_state_dict_from_url
from torch import Tensor
from torch.jit.annotations import List
__all__ = ['DenseNet', 'densenet121', 'densenet169', 'densene... | 11,775 | 41.057143 | 112 | py |
crossover-sgd | crossover-sgd-master/models/googlenet.py | import warnings
from collections import namedtuple
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.jit.annotations import Optional, Tuple
from torch import Tensor
from .utils import load_state_dict_from_url
__all__ = ['GoogLeNet', 'googlenet', "GoogLeNetOutputs", "_GoogLeNetOutputs"]
mod... | 11,009 | 36.195946 | 119 | py |
crossover-sgd | crossover-sgd-master/models/mobilenet.py | from torch import nn
from .utils import load_state_dict_from_url
__all__ = ['MobileNetV2', 'mobilenet_v2']
model_urls = {
'mobilenet_v2': 'https://download.pytorch.org/models/mobilenet_v2-b0353104.pth',
}
def _make_divisible(v, divisor, min_value=None):
"""
This function is taken from the original tf ... | 6,957 | 35.814815 | 116 | py |
crossover-sgd | crossover-sgd-master/models/alexnet.py | import torch
import torch.nn as nn
from .utils import load_state_dict_from_url
__all__ = ['AlexNet', 'alexnet']
model_urls = {
'alexnet': 'https://download.pytorch.org/models/alexnet-owt-4df8aa71.pth',
}
class AlexNet(nn.Module):
def __init__(self, num_classes=1000):
super(AlexNet, self).__init__... | 2,102 | 30.863636 | 83 | py |
crossover-sgd | crossover-sgd-master/models/video/resnet.py | import torch
import torch.nn as nn
from ..utils import load_state_dict_from_url
__all__ = ['r3d_18', 'mc3_18', 'r2plus1d_18']
model_urls = {
'r3d_18': 'https://download.pytorch.org/models/r3d_18-b3b3357e.pth',
'mc3_18': 'https://download.pytorch.org/models/mc3_18-a90a0ba3.pth',
'r2plus1d_18': 'https://d... | 10,982 | 31.114035 | 105 | py |
crossover-sgd | crossover-sgd-master/models/segmentation/fcn.py | from torch import nn
from ._utils import _SimpleSegmentationModel
__all__ = ["FCN"]
class FCN(_SimpleSegmentationModel):
"""
Implements a Fully-Convolutional Network for semantic segmentation.
Arguments:
backbone (nn.Module): the network used to compute the features for the model.
... | 1,164 | 30.486486 | 87 | py |
crossover-sgd | crossover-sgd-master/models/segmentation/_utils.py | from collections import OrderedDict
import torch
from torch import nn
from torch.nn import functional as F
class _SimpleSegmentationModel(nn.Module):
__constants__ = ['aux_classifier']
def __init__(self, backbone, classifier, aux_classifier=None):
super(_SimpleSegmentationModel, self).__init__()
... | 1,040 | 28.742857 | 88 | py |
crossover-sgd | crossover-sgd-master/models/segmentation/segmentation.py | from .._utils import IntermediateLayerGetter
from ..utils import load_state_dict_from_url
from .. import resnet
from .deeplabv3 import DeepLabHead, DeepLabV3
from .fcn import FCN, FCNHead
__all__ = ['fcn_resnet50', 'fcn_resnet101', 'deeplabv3_resnet50', 'deeplabv3_resnet101']
model_urls = {
'fcn_resnet50_coco':... | 4,264 | 38.859813 | 108 | py |
crossover-sgd | crossover-sgd-master/models/segmentation/deeplabv3.py | import torch
from torch import nn
from torch.nn import functional as F
from ._utils import _SimpleSegmentationModel
__all__ = ["DeepLabV3"]
class DeepLabV3(_SimpleSegmentationModel):
"""
Implements DeepLabV3 model from
`"Rethinking Atrous Convolution for Semantic Image Segmentation"
<https://arxiv.... | 2,984 | 30.755319 | 101 | py |
crossover-sgd | crossover-sgd-master/models/quantization/shufflenetv2.py | import torch
import torch.nn as nn
from torchvision.models.utils import load_state_dict_from_url
import torchvision.models.shufflenetv2
import sys
from .utils import _replace_relu, quantize_model
shufflenetv2 = sys.modules['torchvision.models.shufflenetv2']
__all__ = [
'QuantizableShuffleNetV2', 'shufflenet_v2_x0... | 5,857 | 36.793548 | 117 | py |
crossover-sgd | crossover-sgd-master/models/quantization/inception.py | import warnings
from collections import namedtuple
import torch
import torch.nn as nn
import torch.nn.functional as F
from torchvision.models import inception as inception_module
from torchvision.models.inception import InceptionOutputs
from torch.jit.annotations import Optional
from torchvision.models.utils import lo... | 7,906 | 34.457399 | 106 | py |
crossover-sgd | crossover-sgd-master/models/quantization/resnet.py | import torch
from torchvision.models.resnet import Bottleneck, BasicBlock, ResNet, model_urls
import torch.nn as nn
from torchvision.models.utils import load_state_dict_from_url
from torch.quantization import QuantStub, DeQuantStub, fuse_modules
from torch._jit_internal import Optional
from .utils import _replace_relu,... | 6,056 | 33.611429 | 107 | py |
crossover-sgd | crossover-sgd-master/models/quantization/utils.py | import torch
from torch import nn
def _replace_relu(module):
reassign = {}
for name, mod in module.named_children():
_replace_relu(mod)
# Checking for explicit type instead of instance
# as we only want to replace modules of the exact type
# not inherited classes
if typ... | 1,439 | 34.121951 | 74 | py |
crossover-sgd | crossover-sgd-master/models/quantization/googlenet.py | import warnings
import torch
import torch.nn as nn
from torch.nn import functional as F
from torch.jit.annotations import Optional
from torchvision.models.utils import load_state_dict_from_url
from torchvision.models.googlenet import (
GoogLeNetOutputs, BasicConv2d, Inception, InceptionAux, GoogLeNet, model_urls)
... | 5,607 | 32.580838 | 102 | py |
crossover-sgd | crossover-sgd-master/models/quantization/mobilenet.py | from torch import nn
from torchvision.models.utils import load_state_dict_from_url
from torchvision.models.mobilenet import InvertedResidual, ConvBNReLU, MobileNetV2, model_urls
from torch.quantization import QuantStub, DeQuantStub, fuse_modules
from .utils import _replace_relu, quantize_model
__all__ = ['Quantizable... | 3,148 | 32.147368 | 94 | py |
crossover-sgd | crossover-sgd-master/models/detection/image_list.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from torch.jit.annotations import List, Tuple
from torch import Tensor
class ImageList(object):
"""
Structure that holds a list of images (of possibly
varying sizes) as a single tensor.
This works by padding the image... | 875 | 29.206897 | 71 | py |
crossover-sgd | crossover-sgd-master/models/detection/backbone_utils.py | from collections import OrderedDict
from torch import nn
from torchvision.ops.feature_pyramid_network import FeaturePyramidNetwork, LastLevelMaxPool
from torchvision.ops import misc as misc_nn_ops
from .._utils import IntermediateLayerGetter
from .. import resnet
class BackboneWithFPN(nn.Module):
"""
Adds a ... | 4,296 | 43.760417 | 118 | py |
crossover-sgd | crossover-sgd-master/models/detection/mask_rcnn.py | from collections import OrderedDict
import torch
from torch import nn
import torch.nn.functional as F
from torchvision.ops import misc as misc_nn_ops
from torchvision.ops import MultiScaleRoIAlign
from ..utils import load_state_dict_from_url
from .faster_rcnn import FasterRCNN
from .backbone_utils import resnet_fpn... | 17,577 | 51.945783 | 117 | py |
crossover-sgd | crossover-sgd-master/models/detection/_utils.py | import math
import torch
from torch.jit.annotations import List, Tuple
from torch import Tensor
import torchvision
class BalancedPositiveNegativeSampler(object):
"""
This class samples batches, ensuring that they contain a fixed proportion of positives
"""
def __init__(self, batch_size_per_image, po... | 13,880 | 38.434659 | 107 | py |
crossover-sgd | crossover-sgd-master/models/detection/faster_rcnn.py | from collections import OrderedDict
import torch
from torch import nn
import torch.nn.functional as F
from torchvision.ops import misc as misc_nn_ops
from torchvision.ops import MultiScaleRoIAlign
from ..utils import load_state_dict_from_url
from .generalized_rcnn import GeneralizedRCNN
from .rpn import AnchorGener... | 17,456 | 46.958791 | 116 | py |
crossover-sgd | crossover-sgd-master/models/detection/generalized_rcnn.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
Implements the Generalized R-CNN framework
"""
from collections import OrderedDict
from typing import Union
import torch
from torch import nn
import warnings
from torch.jit.annotations import Tuple, List, Dict, Optional
from torch import Tenso... | 4,683 | 40.087719 | 118 | py |
crossover-sgd | crossover-sgd-master/models/detection/transform.py | import random
import math
import torch
from torch import nn, Tensor
from torch.nn import functional as F
import torchvision
from torch.jit.annotations import List, Tuple, Dict, Optional
from .image_list import ImageList
from .roi_heads import paste_masks_in_image
@torch.jit.unused
def _resize_image_and_masks_onnx(im... | 11,576 | 40.199288 | 115 | py |
crossover-sgd | crossover-sgd-master/models/detection/rpn.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from torch.nn import functional as F
from torch import nn, Tensor
import torchvision
from torchvision.ops import boxes as box_ops
from . import _utils as det_utils
from .image_list import ImageList
from torch.jit.annotations import ... | 21,351 | 41.114398 | 117 | py |
crossover-sgd | crossover-sgd-master/models/detection/roi_heads.py | import torch
import torchvision
import torch.nn.functional as F
from torch import nn, Tensor
from torchvision.ops import boxes as box_ops
from torchvision.ops import roi_align
from . import _utils as det_utils
from torch.jit.annotations import Optional, List, Dict, Tuple
def fastrcnn_loss(class_logits, box_regre... | 33,893 | 38.003452 | 118 | py |
crossover-sgd | crossover-sgd-master/models/detection/keypoint_rcnn.py | import torch
from torch import nn
from torchvision.ops import MultiScaleRoIAlign
from ..utils import load_state_dict_from_url
from .faster_rcnn import FasterRCNN
from .backbone_utils import resnet_fpn_backbone
__all__ = [
"KeypointRCNN", "keypointrcnn_resnet50_fpn"
]
class KeypointRCNN(FasterRCNN):
"""
... | 17,873 | 52.196429 | 116 | py |
crossover-sgd | crossover-sgd-master/220606_실험/220613/imagenet_test.py | import argparse
import copy
import os
import socket
import time
import random
import sys
import numpy as np
from itertools import cycle
from functools import reduce
import torch
import torch.backends.cudnn as cudnn
import torch.distributed as dist
import torch.multiprocessing as mp
from torch.multiprocessing import P... | 33,010 | 36.34276 | 351 | py |
crossover-sgd | crossover-sgd-master/220606_실험/220613/imagenet_test_no_fa_no_seg.py | import argparse
import copy
import os
import socket
import time
import random
import sys
import numpy as np
from itertools import cycle
from functools import reduce
import torch
import torch.backends.cudnn as cudnn
import torch.distributed as dist
import torch.multiprocessing as mp
from torch.multiprocessing import P... | 32,450 | 36.129291 | 359 | py |
SImMER | SImMER-main/docs/conf.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# SImMER documentation build configuration file, created by
# sphinx-quickstart on Sat Feb 22 22:19:42 2020.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# aut... | 6,404 | 27.9819 | 96 | py |
sparc | sparc-master/optimization.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HugginFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENS... | 6,736 | 40.84472 | 116 | py |
sparc | sparc-master/mips_phrase.py | import argparse
import json
import os
import random
import logging
from collections import namedtuple, Counter
from time import time
import h5py
import numpy as np
import faiss
import torch
from tqdm import tqdm
from scipy.sparse import vstack
logging.basicConfig(format='%(asctime)s - %(levelname)s - %(name)s - %(... | 22,652 | 46.391213 | 125 | py |
sparc | sparc-master/modeling.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HugginFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENS... | 44,237 | 45.419727 | 124 | py |
sparc | sparc-master/post.py | import collections
import json
import logging
import os
import shutil
import torch
import math
import pandas as pd
import numpy as np
import six
import h5py
from multiprocessing import Process
from time import time
from scipy.sparse import csr_matrix, save_npz, hstack, vstack
from termcolor import colored, cprint
from ... | 30,818 | 43.730044 | 129 | py |
sparc | sparc-master/file_utils.py | """
Utilities for working with the local dataset cache.
This file is adapted from the AllenNLP library at https://github.com/allenai/allennlp
Copyright by the AllenNLP authors.
"""
from __future__ import (absolute_import, division, print_function, unicode_literals)
import json
import logging
import os
import shutil
im... | 8,295 | 32.184 | 112 | py |
sparc | sparc-master/run_server.py | import json
import argparse
import torch
import tokenization
import os
import random
import numpy as np
import requests
import logging
import math
import ssl
import copy
from time import time
from flask import Flask, request, jsonify, render_template, redirect
from flask_cors import CORS
from tornado.wsgi import WSGICo... | 20,456 | 40.494929 | 122 | py |
sparc | sparc-master/train.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HugginFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENS... | 49,832 | 50.963504 | 124 | py |
sparc | sparc-master/pre.py | import collections
import json
import logging
import h5py
import os
import pandas as pd
import six
import random
import torch
import pickle as pkl
import numpy as np
import copy
import unicodedata
from tqdm import tqdm
from tfidf_doc_ranker import TfidfDocRanker
import tokenization
from post import _improve_answer_sp... | 34,540 | 40.416067 | 121 | py |
ls-iq | ls-iq-main/examples/01_LSIQ/04_episode_25/lsiq_experiments.py | import os
from time import perf_counter
from contextlib import contextmanager
import numpy as np
import torch
import torch.optim as optim
from torch.utils.tensorboard import SummaryWriter
from mushroom_rl.core import Core
from mushroom_rl.environments import Gym
from mushroom_rl.utils.dataset import compute_J, comput... | 8,041 | 41.326316 | 118 | py |
ls-iq | ls-iq-main/examples/01_LSIQ/02_episode_5/lsiq_experiments.py | import os
from time import perf_counter
from contextlib import contextmanager
import numpy as np
import torch
import torch.optim as optim
from torch.utils.tensorboard import SummaryWriter
from mushroom_rl.core import Core
from mushroom_rl.environments import Gym
from mushroom_rl.utils.dataset import compute_J, comput... | 8,041 | 41.326316 | 118 | py |
ls-iq | ls-iq-main/examples/01_LSIQ/01_episode/lsiq_experiments.py | import os
from time import perf_counter
from contextlib import contextmanager
import numpy as np
import torch
import torch.optim as optim
from torch.utils.tensorboard import SummaryWriter
from mushroom_rl.core import Core
from mushroom_rl.environments import Gym
from mushroom_rl.utils.dataset import compute_J, comput... | 8,041 | 41.326316 | 118 | py |
ls-iq | ls-iq-main/examples/01_LSIQ/03_episode_10/lsiq_experiments.py | import os
from time import perf_counter
from contextlib import contextmanager
import numpy as np
import torch
import torch.optim as optim
from torch.utils.tensorboard import SummaryWriter
from mushroom_rl.core import Core
from mushroom_rl.environments import Gym
from mushroom_rl.utils.dataset import compute_J, comput... | 8,041 | 41.326316 | 118 | py |
ls-iq | ls-iq-main/imitation_lib/imitation/iqfo_sac.py | import torch
import torch.nn.functional as F
import numpy as np
from copy import deepcopy
from mushroom_rl.core import Serializable
from mushroom_rl.approximators import Regressor
from mushroom_rl.approximators.parametric import TorchApproximator
from imitation_lib.imitation.iq_sac import IQ_SAC
from mushroom_rl.utils... | 16,253 | 59.2 | 136 | py |
ls-iq | ls-iq-main/imitation_lib/imitation/sqil_sac.py | import numpy as np
import torch
from .iq_sac import IQ_SAC
from mushroom_rl.utils.torch import to_float_tensor
class SQIL(IQ_SAC):
def __init__(self, R_min=0.0, R_max=1.0, plcy_loss_mode="plcy", **kwargs):
super(SQIL, self).__init__(plcy_loss_mode=plcy_loss_mode, **kwargs)
self._R_min = R_min
... | 7,681 | 55.072993 | 153 | py |
ls-iq | ls-iq-main/imitation_lib/imitation/lsiq.py | import torch
import numpy as np
from .iq_sac import IQ_SAC
import torch.nn.functional as F
from mushroom_rl.utils.torch import to_float_tensor
class LSIQ(IQ_SAC):
def __init__(self, Q_max=1.0, Q_min =-1.0, loss_mode_exp="fix", Q_exp_loss=None,
treat_absorbing_states=False, target_clipping=True,... | 8,596 | 43.087179 | 131 | py |
ls-iq | ls-iq-main/imitation_lib/imitation/lsiqfo_hc.py | import torch
import torch.nn.functional as F
import numpy as np
from imitation_lib.imitation.lsiq_hc import LSIQ_HC
from mushroom_rl.utils.minibatches import minibatch_generator
from mushroom_rl.utils.torch import to_float_tensor
from imitation_lib.utils.action_models import GaussianInvActionModel, LearnableVarGaussia... | 15,761 | 60.093023 | 136 | py |
ls-iq | ls-iq-main/imitation_lib/imitation/lsiq_hc.py | from copy import deepcopy
import torch
import numpy as np
from .lsiq_h import LSIQ_H
import torch.nn.functional as F
from mushroom_rl.utils.parameters import to_parameter
from mushroom_rl.approximators import Regressor
from mushroom_rl.approximators.parametric import TorchApproximator
from mushroom_rl.utils.torch impo... | 4,770 | 46.237624 | 111 | py |
ls-iq | ls-iq-main/imitation_lib/imitation/lsiq_h.py | from copy import deepcopy
import torch
import numpy as np
from .lsiq import LSIQ
import torch.nn.functional as F
from mushroom_rl.approximators import Regressor
from mushroom_rl.approximators.parametric import TorchApproximator
from mushroom_rl.utils.torch import to_float_tensor
class LSIQ_H(LSIQ):
def __init__... | 5,980 | 46.094488 | 122 | py |
ls-iq | ls-iq-main/imitation_lib/imitation/gail_TRPO.py | from copy import deepcopy
import torch
import torch.nn.functional as F
import numpy as np
from mushroom_rl.approximators import Regressor
from mushroom_rl.approximators.parametric import TorchApproximator
from mushroom_rl.utils.torch import get_gradient, zero_grad, to_float_tensor
from mushroom_rl.utils.dataset impor... | 16,190 | 48.362805 | 130 | py |
ls-iq | ls-iq-main/imitation_lib/imitation/lsiqfo.py | import torch
import torch.nn.functional as F
import numpy as np
from copy import deepcopy
from mushroom_rl.core import Serializable
from mushroom_rl.approximators import Regressor
from mushroom_rl.approximators.parametric import TorchApproximator
from imitation_lib.imitation.lsiq import LSIQ
from mushroom_rl.utils.min... | 16,205 | 59.470149 | 136 | py |
ls-iq | ls-iq-main/imitation_lib/imitation/vail_TRPO.py | from copy import deepcopy
import torch
import torch.nn.functional as F
import numpy as np
from imitation_lib.imitation import GAIL_TRPO
from imitation_lib.utils import to_float_tensors
class VAIL(GAIL_TRPO):
def __init__(self, **kwargs):
# call base constructor
super(VAIL, self).__init__(**kwa... | 1,130 | 32.264706 | 108 | py |
ls-iq | ls-iq-main/imitation_lib/imitation/lsiqfo_h.py | import torch
import torch.nn.functional as F
import numpy as np
from imitation_lib.imitation.lsiq_h import LSIQ_H
from mushroom_rl.utils.minibatches import minibatch_generator
from mushroom_rl.utils.torch import to_float_tensor
from imitation_lib.utils.action_models import GaussianInvActionModel, LearnableVarGaussianI... | 15,757 | 60.077519 | 136 | py |
ls-iq | ls-iq-main/imitation_lib/imitation/iq_sac.py | from copy import deepcopy
import numpy as np
import torch
import torch.optim as optim
import torch.nn.functional as F
from mushroom_rl.approximators import Regressor
from mushroom_rl.approximators.parametric import TorchApproximator
from mushroom_rl.utils.replay_memory import ReplayMemory
from mushroom_rl.utils.miniba... | 30,680 | 43.336705 | 153 | py |
ls-iq | ls-iq-main/imitation_lib/imitation/iqfo_orig.py | import torch
import torch.nn.functional as F
import numpy as np
from mushroom_rl.approximators import Regressor
from mushroom_rl.approximators.parametric import TorchApproximator
from imitation_lib.imitation.iq_sac import IQ_SAC
from mushroom_rl.utils.minibatches import minibatch_generator
from mushroom_rl.utils.torch ... | 3,743 | 50.287671 | 111 | py |
ls-iq | ls-iq-main/imitation_lib/imitation/offline/iq_offline.py | import torch
import numpy as np
from mushroom_rl.utils.minibatches import minibatch_generator
from mushroom_rl.utils.torch import to_float_tensor
from imitation_lib.imitation.iq_sac import IQ_SAC
class IQ_Offline(IQ_SAC):
def __init__(self, **kwargs):
if "regularizer_mode" in kwargs.keys():
... | 11,084 | 50.082949 | 153 | py |
ls-iq | ls-iq-main/imitation_lib/imitation/offline/lsiq_offline.py | import torch
from torch.functional import F
import numpy as np
from mushroom_rl.utils.minibatches import minibatch_generator
from mushroom_rl.utils.torch import to_float_tensor
from imitation_lib.imitation.lsiq import LSIQ
class LSIQ_Offline(LSIQ):
def __init__(self, loss_mode_exp="fix", regularizer_mode="off", ... | 13,415 | 53.315789 | 153 | py |
ls-iq | ls-iq-main/imitation_lib/imitation/offline/lsiq_offline_dm.py | from copy import deepcopy
import torch
from torch.functional import F
import numpy as np
from mushroom_rl.utils.minibatches import minibatch_generator
from mushroom_rl.utils.torch import to_float_tensor
from mushroom_rl.approximators import Regressor
from mushroom_rl.approximators.parametric import TorchApproximator
fr... | 13,813 | 48.870036 | 153 | py |
ls-iq | ls-iq-main/imitation_lib/imitation/offline/behavioral_cloning.py | import numpy as np
import torch
from torch.nn import GaussianNLLLoss
import torch.nn.functional as F
from mushroom_rl.core import Agent
from mushroom_rl.approximators import Regressor
from mushroom_rl.utils.torch import to_float_tensor
from mushroom_rl.utils.minibatches import minibatch_generator
from mushroom_rl.appro... | 4,611 | 45.585859 | 125 | py |
ls-iq | ls-iq-main/imitation_lib/utils/distributions.py | from torch.distributions import constraints
from torch.distributions.transforms import PowerTransform
from torch.distributions import TransformedDistribution, Gamma
class InverseGamma(TransformedDistribution):
def __init__(self, concentration, rate, validate_args=None):
base_dist = Gamma(concentration, ... | 818 | 28.25 | 65 | py |
ls-iq | ls-iq-main/imitation_lib/utils/math.py | from typing import Optional
import numpy as np
import torch
import torch.nn.functional as F
from mushroom_rl.utils.angles import euler_to_quat
from mushroom_rl.utils.torch import to_float_tensor
class GailDiscriminatorLoss(torch.nn.modules.BCEWithLogitsLoss):
def __init__(self, entcoeff=1e-3, weight: Optional[... | 3,886 | 36.737864 | 184 | py |
ls-iq | ls-iq-main/imitation_lib/utils/action_models.py | from copy import deepcopy
import numpy as np
import torch
import torch.nn.functional as F
from mushroom_rl.core import Serializable
from mushroom_rl.approximators import Regressor
from mushroom_rl.approximators.parametric import TorchApproximator
from mushroom_rl.utils.torch import to_float_tensor
from mushroom_rl.uti... | 44,164 | 40.743856 | 120 | py |
ls-iq | ls-iq-main/imitation_lib/utils/networks.py | import numpy as np
import torch
import torch.nn as nn
from torch.nn import ModuleList
import torch.nn.functional as F
from mushroom_rl.utils.preprocessors import RunningStandardization
class BiasedTanh(torch.nn.Module):
def __init__(self, mult=0.5, bias=0.5):
super(BiasedTanh, self).__init__()
s... | 19,213 | 36.527344 | 141 | py |
pytorch-seq2seq | pytorch-seq2seq-master/setup.py | from setuptools import setup, find_packages
# To use a consistent encoding
from codecs import open
from os import path
here = path.abspath(path.dirname(__file__))
# Get the long description from the README file
with open(path.join(here, 'README.md'), encoding='utf-8') as f:
long_description = f.read()
setup(
... | 2,611 | 33.368421 | 96 | py |
pytorch-seq2seq | pytorch-seq2seq-master/examples/sample.py | import os
import argparse
import logging
import torch
from torch.optim.lr_scheduler import StepLR
import torchtext
import seq2seq
from seq2seq.trainer import SupervisedTrainer
from seq2seq.models import EncoderRNN, DecoderRNN, Seq2seq
from seq2seq.loss import Perplexity
from seq2seq.optim import Optimizer
from seq2se... | 5,477 | 38.985401 | 138 | py |
pytorch-seq2seq | pytorch-seq2seq-master/scripts/integration_test.py | import os
import argparse
import logging
import torch
import torchtext
import seq2seq
from seq2seq.trainer import SupervisedTrainer
from seq2seq.models import EncoderRNN, DecoderRNN, TopKDecoder, Seq2seq
from seq2seq.loss import Perplexity
from seq2seq.dataset import SourceField, TargetField
from seq2seq.evaluator im... | 4,427 | 36.846154 | 138 | py |
pytorch-seq2seq | pytorch-seq2seq-master/tests/test_checkpoint.py | import unittest
import os
import shutil
import mock
from mock import ANY
from seq2seq.util.checkpoint import Checkpoint
class TestCheckpoint(unittest.TestCase):
EXP_DIR = "test_experiment"
def tearDown(self):
path = self._get_experiment_dir()
if os.path.exists(path):
shutil.rmt... | 3,989 | 40.134021 | 100 | py |
pytorch-seq2seq | pytorch-seq2seq-master/tests/test_supervised_trainer.py | import unittest
import os
import mock
import torchtext
from seq2seq.dataset import SourceField, TargetField
from seq2seq.trainer import SupervisedTrainer
class TestSupervisedTrainer(unittest.TestCase):
def setUp(self):
test_path = os.path.dirname(os.path.realpath(__file__))
src = SourceField()
... | 1,810 | 32.537037 | 86 | py |
pytorch-seq2seq | pytorch-seq2seq-master/tests/test_optim_optim.py | import unittest
import torch
from torch.optim.lr_scheduler import StepLR
import mock
from seq2seq.optim import Optimizer
class TestOptimizer(unittest.TestCase):
def test_init(self):
params = [torch.nn.Parameter(torch.randn(2,3,4))]
try:
optimizer = Optimizer(torch.optim.Adam(params))... | 1,162 | 31.305556 | 78 | py |
pytorch-seq2seq | pytorch-seq2seq-master/tests/test_evaluator.py | from __future__ import division
import os
import math
import unittest
from mock import MagicMock, patch, call, ANY
import torchtext
from seq2seq.dataset import SourceField, TargetField
from seq2seq.evaluator import Evaluator
from seq2seq.models import Seq2seq, EncoderRNN, DecoderRNN
class TestPredictor(unittest.Test... | 1,941 | 38.632653 | 118 | py |
pytorch-seq2seq | pytorch-seq2seq-master/tests/test_fields.py | import os
import unittest
import torchtext
from seq2seq.dataset import SourceField, TargetField
class TestField(unittest.TestCase):
def test_sourcefield(self):
field = SourceField()
self.assertTrue(isinstance(field, torchtext.data.Field))
self.assertTrue(field.batch_first)
self.a... | 1,860 | 35.490196 | 83 | py |
pytorch-seq2seq | pytorch-seq2seq-master/tests/test_topkdecoder.py | import unittest
import torch
import torch.nn.functional as F
import numpy as np
from seq2seq.models import DecoderRNN, TopKDecoder
class TestDecoderRNN(unittest.TestCase):
@classmethod
def setUpClass(self):
self.vocab_size = 3
def test_init(self):
decoder = DecoderRNN(self.vocab_size, 5... | 6,285 | 42.652778 | 116 | py |
pytorch-seq2seq | pytorch-seq2seq-master/tests/test_decoder_rnn.py | import os
import unittest
import torch
from seq2seq.models import DecoderRNN
class TestDecoderRNN(unittest.TestCase):
@classmethod
def setUpClass(self):
self.vocab_size = 100
def test_input_dropout_WITH_PROB_ZERO(self):
rnn = DecoderRNN(self.vocab_size, 50, 16, 0, 1, input_dropout_p=0)
... | 1,895 | 31.135593 | 82 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.