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 |
|---|---|---|---|---|---|---|
MNC | MNC-master/tools/demo.py | #!/usr/bin/python
# --------------------------------------------------------
# Multitask Network Cascade
# Modified from py-faster-rcnn (https://github.com/rbgirshick/py-faster-rcnn)
# Copyright (c) 2016, Haozhi Qi
# Licensed under The MIT License [see LICENSE for details]
# -------------------------------------------... | 7,538 | 38.265625 | 93 | py |
MNC | MNC-master/tools/train_net.py | #!/usr/bin/env python
# --------------------------------------------------------
# Multitask Network Cascade
# Modified from py-faster-rcnn (https://github.com/rbgirshick/py-faster-rcnn)
# Copyright (c) 2016, Haozhi Qi
# Licensed under The MIT License [see LICENSE for details]
# ---------------------------------------... | 3,331 | 32.656566 | 78 | py |
MNC | MNC-master/lib/caffeWrapper/TesterWrapper.py | # --------------------------------------------------------
# Multitask Network Cascade
# Modified from py-faster-rcnn (https://github.com/rbgirshick/py-faster-rcnn)
# Copyright (c) 2016, Haozhi Qi
# Licensed under The MIT License [see LICENSE for details]
# --------------------------------------------------------
impo... | 21,633 | 51.13012 | 123 | py |
MNC | MNC-master/lib/caffeWrapper/SolverWrapper.py | # --------------------------------------------------------
# Multitask Network Cascade
# Modified from py-faster-rcnn (https://github.com/rbgirshick/py-faster-rcnn)
# Copyright (c) 2016, Haozhi Qi
# Licensed under The MIT License [see LICENSE for details]
# --------------------------------------------------------
imp... | 6,147 | 43.230216 | 103 | py |
MNC | MNC-master/lib/pylayer/proposal_layer.py | # --------------------------------------------------------
# Multitask Network Cascade
# Modified from py-faster-rcnn (https://github.com/rbgirshick/py-faster-rcnn)
# Copyright (c) 2016, Haozhi Qi
# Licensed under The MIT License [see LICENSE for details]
# --------------------------------------------------------
impo... | 10,386 | 43.965368 | 121 | py |
MNC | MNC-master/lib/pylayer/mnc_data_layer.py | # --------------------------------------------------------
# Multitask Network Cascade
# Modified from py-faster-rcnn (https://github.com/rbgirshick/py-faster-rcnn)
# Copyright (c) 2016, Haozhi Qi
# Licensed under The MIT License [see LICENSE for details]
# --------------------------------------------------------
impo... | 5,826 | 37.589404 | 103 | py |
MNC | MNC-master/lib/pylayer/proposal_target_layer.py | # --------------------------------------------------------
# Multitask Network Cascade
# Modified from py-faster-rcnn (https://github.com/rbgirshick/py-faster-rcnn)
# Copyright (c) 2016, Haozhi Qi
# Licensed under The MIT License [see LICENSE for details]
# --------------------------------------------------------
impo... | 9,255 | 41.654378 | 97 | py |
MNC | MNC-master/lib/pylayer/mask_layer.py | # --------------------------------------------------------
# Multitask Network Cascade
# Written by Haozhi Qi
# Copyright (c) 2016, Haozhi Qi
# Licensed under The MIT License [see LICENSE for details]
# --------------------------------------------------------
import caffe
import cv2
import numpy as np
from transform.m... | 3,988 | 37.728155 | 124 | py |
MNC | MNC-master/lib/pylayer/stage_bridge_layer.py | # --------------------------------------------------------
# Multitask Network Cascade
# Written by Haozhi Qi
# Copyright (c) 2016, Haozhi Qi
# Licensed under The MIT License [see LICENSE for details]
# --------------------------------------------------------
import caffe
import numpy as np
import yaml
from transform.... | 11,685 | 44.648438 | 112 | py |
MNC | MNC-master/lib/pylayer/anchor_target_layer.py | # --------------------------------------------------------
# Multitask Network Cascade
# Modified from py-faster-rcnn (https://github.com/rbgirshick/py-faster-rcnn)
# Copyright (c) 2016, Haozhi Qi
# Licensed under The MIT License [see LICENSE for details]
# --------------------------------------------------------
impo... | 9,757 | 40.879828 | 94 | py |
MNC | MNC-master/lib/pylayer/cfm_data_layer.py | # --------------------------------------------------------
# Multitask Network Cascade
# Written by Haozhi Qi
# Copyright (c) 2016, Haozhi Qi
# Licensed under The MIT License [see LICENSE for details]
# --------------------------------------------------------
import cv2
import yaml
import scipy
import numpy as np
impo... | 11,892 | 44.39313 | 122 | py |
flowseq | flowseq-master/flownmt/utils.py | import logging
import sys
from typing import Tuple, List
import torch
from torch._six import inf
def get_logger(name, level=logging.INFO, handler=sys.stdout,
formatter='%(asctime)s - %(name)s - %(levelname)s - %(message)s'):
logger = logging.getLogger(name)
logger.setLevel(logging.INFO)
for... | 7,058 | 30.513393 | 108 | py |
flowseq | flowseq-master/flownmt/flownmt.py | import os
import json
import math
from typing import Dict, Tuple
import torch
import torch.nn as nn
import torch.distributed as dist
from apex.parallel import DistributedDataParallel
from apex.parallel.distributed import flat_dist_call
from flownmt.modules import Encoder
from flownmt.modules import Posterior
from flow... | 29,121 | 44.432137 | 154 | py |
flowseq | flowseq-master/flownmt/modules/decoders/simple.py | from overrides import overrides
from typing import Dict, Tuple
import torch
import torch.nn as nn
import torch.nn.functional as F
from flownmt.modules.decoders.decoder import Decoder
from flownmt.nnet.attention import GlobalAttention
class SimpleDecoder(Decoder):
"""
Simple Decoder to predict translations fr... | 3,347 | 33.875 | 138 | py |
flowseq | flowseq-master/flownmt/modules/decoders/transformer.py | from overrides import overrides
from typing import Dict, Tuple
import torch
import torch.nn as nn
import torch.nn.functional as F
from flownmt.modules.decoders.decoder import Decoder
from flownmt.nnet.attention import MultiHeadAttention
from flownmt.nnet.transformer import TransformerDecoderLayer
from flownmt.nnet.pos... | 3,889 | 35.018519 | 138 | py |
flowseq | flowseq-master/flownmt/modules/decoders/decoder.py | from typing import Dict, Tuple
import torch
import torch.nn as nn
from flownmt.nnet.criterion import LabelSmoothedCrossEntropyLoss
class Decoder(nn.Module):
"""
Decoder to predict translations from latent z
"""
_registry = dict()
def __init__(self, vocab_size, latent_dim, label_smoothing=0., _sh... | 2,946 | 30.351064 | 138 | py |
flowseq | flowseq-master/flownmt/modules/decoders/rnn.py | from overrides import overrides
from typing import Dict, Tuple
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.utils.rnn import pad_packed_sequence, pack_padded_sequence
from flownmt.modules.decoders.decoder import Decoder
from flownmt.nnet.attention import GlobalAttention
class Recu... | 4,558 | 36.368852 | 138 | py |
flowseq | flowseq-master/flownmt/modules/priors/prior.py | import math
from typing import Dict, Tuple, Union
import torch
import torch.nn as nn
from flownmt.flows.nmt import NMTFlow
from flownmt.modules.priors.length_predictors import LengthPredictor
class Prior(nn.Module):
"""
class for Prior with a NMTFlow inside
"""
_registry = dict()
def __init__(se... | 9,219 | 41.293578 | 186 | py |
flowseq | flowseq-master/flownmt/modules/priors/length_predictors/diff_softmax.py | from overrides import overrides
from typing import Dict, Tuple
import torch
import torch.nn as nn
import torch.nn.functional as F
from flownmt.modules.priors.length_predictors.predictor import LengthPredictor
from flownmt.nnet.criterion import LabelSmoothedCrossEntropyLoss
class DiffSoftMaxLengthPredictor(LengthPred... | 4,818 | 38.178862 | 120 | py |
flowseq | flowseq-master/flownmt/modules/priors/length_predictors/predictor.py | from typing import Dict, Tuple
import torch
import torch.nn as nn
class LengthPredictor(nn.Module):
"""
Length Predictor
"""
_registry = dict()
def __init__(self):
super(LengthPredictor, self).__init__()
self.length_unit = None
def set_length_unit(self, length_unit):
... | 1,712 | 26.629032 | 120 | py |
flowseq | flowseq-master/flownmt/modules/priors/length_predictors/utils.py | from typing import Tuple
import numpy as np
import torch
import torch.nn.functional as F
def discretized_mix_logistic_loss(x, means, logscales, logit_probs,
bin_size, lower, upper) -> torch.Tensor:
"""
loss for discretized mixture logistic distribution
Args:
x: [b... | 3,823 | 29.592 | 114 | py |
flowseq | flowseq-master/flownmt/modules/priors/length_predictors/diff_discretized_mix_logistic.py | from overrides import overrides
from typing import Dict, Tuple
import torch
import torch.nn as nn
import torch.nn.functional as F
from flownmt.modules.priors.length_predictors.predictor import LengthPredictor
from flownmt.modules.priors.length_predictors.utils import discretized_mix_logistic_loss, discretized_mix_logi... | 4,046 | 39.069307 | 120 | py |
flowseq | flowseq-master/flownmt/modules/encoders/encoder.py | from overrides import overrides
from typing import Dict, Tuple
import torch
import torch.nn as nn
class Encoder(nn.Module):
"""
Src Encoder to encode source sentence
"""
_registry = dict()
def __init__(self, vocab_size, embed_dim, padding_idx):
super(Encoder, self).__init__()
self... | 1,549 | 28.245283 | 82 | py |
flowseq | flowseq-master/flownmt/modules/encoders/transformer.py | from overrides import overrides
from typing import Dict, Tuple
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from flownmt.modules.encoders.encoder import Encoder
from flownmt.nnet.transformer import TransformerEncoderLayer
from flownmt.nnet.positional_encoding import PositionalEncoding... | 2,782 | 34.227848 | 132 | py |
flowseq | flowseq-master/flownmt/modules/encoders/rnn.py | from overrides import overrides
from typing import Dict, Tuple
import torch
import torch.nn as nn
import torch.nn.functional as F
from flownmt.modules.encoders.encoder import Encoder
from torch.nn.utils.rnn import pad_packed_sequence, pack_padded_sequence
class RecurrentCore(nn.Module):
def __init__(self, embed,... | 2,897 | 36.153846 | 119 | py |
flowseq | flowseq-master/flownmt/modules/posteriors/shift_rnn.py | from overrides import overrides
from typing import Tuple, Dict
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.utils.rnn import pad_packed_sequence, pack_padded_sequence
from flownmt.nnet.weightnorm import LinearWeightNorm
from flownmt.modules.posteriors.posterior import Posterior
from... | 7,669 | 49.460526 | 143 | py |
flowseq | flowseq-master/flownmt/modules/posteriors/transformer.py | from overrides import overrides
from typing import Tuple, Dict
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from flownmt.nnet.weightnorm import LinearWeightNorm
from flownmt.nnet.transformer import TransformerDecoderLayer
from flownmt.nnet.positional_encoding import PositionalEncoding... | 5,026 | 42.713043 | 143 | py |
flowseq | flowseq-master/flownmt/modules/posteriors/rnn.py | from overrides import overrides
from typing import Tuple, Dict
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.utils.rnn import pad_packed_sequence, pack_padded_sequence
from flownmt.nnet.weightnorm import LinearWeightNorm
from flownmt.modules.posteriors.posterior import Posterior
from... | 6,032 | 47.264 | 143 | py |
flowseq | flowseq-master/flownmt/modules/posteriors/posterior.py | import math
from typing import Dict, Tuple
import torch
import torch.nn as nn
class Posterior(nn.Module):
"""
posterior class
"""
_registry = dict()
def __init__(self, vocab_size, embed_dim, padding_idx, _shared_embed=None):
super(Posterior, self).__init__()
if _shared_embed is No... | 3,375 | 33.10101 | 143 | py |
flowseq | flowseq-master/flownmt/flows/nmt.py | from overrides import overrides
from typing import Dict, Tuple
import torch
import torch.nn as nn
from flownmt.flows.flow import Flow
from flownmt.flows.actnorm import ActNormFlow
from flownmt.flows.linear import InvertibleMultiHeadFlow
from flownmt.flows.couplings.coupling import NICE
from flownmt.utils import squeez... | 24,648 | 44.815985 | 144 | py |
flowseq | flowseq-master/flownmt/flows/flow.py | from typing import Dict, Tuple
import torch
import torch.nn as nn
class Flow(nn.Module):
"""
Normalizing Flow base class
"""
_registry = dict()
def __init__(self, inverse):
super(Flow, self).__init__()
self.inverse = inverse
def forward(self, *inputs, **kwargs) -> Tuple[torch... | 3,608 | 30.657895 | 118 | py |
flowseq | flowseq-master/flownmt/flows/actnorm.py | from overrides import overrides
from typing import Dict, Tuple
import numpy as np
import torch
import torch.nn as nn
from torch.nn import Parameter
from flownmt.flows.flow import Flow
class ActNormFlow(Flow):
def __init__(self, in_features, inverse=False):
super(ActNormFlow, self).__init__(inverse)
... | 3,655 | 32.851852 | 112 | py |
flowseq | flowseq-master/flownmt/flows/linear.py | from overrides import overrides
from typing import Dict, Tuple
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import Parameter
from flownmt.flows.flow import Flow
class InvertibleLinearFlow(Flow):
def __init__(self, in_features, inverse=False):
super(InvertibleLinearFlow... | 7,141 | 34.356436 | 124 | py |
flowseq | flowseq-master/flownmt/flows/parallel/data_parallel.py | from overrides import overrides
from typing import Tuple
import torch
from torch.nn.parallel.replicate import replicate
from flownmt.flows.parallel.parallel_apply import parallel_apply
from torch.nn.parallel.scatter_gather import scatter_kwargs, gather
from torch.nn.parallel.data_parallel import _check_balance
from fl... | 2,891 | 37.56 | 107 | py |
flowseq | flowseq-master/flownmt/flows/parallel/parallel_apply.py | import threading
import torch
def get_a_var(obj):
if isinstance(obj, torch.Tensor):
return obj
if isinstance(obj, list) or isinstance(obj, tuple):
for result in map(get_a_var, obj):
if isinstance(result, torch.Tensor):
return result
if isinstance(obj, dict):
... | 2,756 | 33.4625 | 100 | py |
flowseq | flowseq-master/flownmt/flows/couplings/transform.py | import math
from overrides import overrides
from typing import Tuple
import torch
class Transform():
@staticmethod
def fwd(z: torch.Tensor, mask: torch.Tensor, params) -> Tuple[torch.Tensor, torch.Tensor]:
raise NotImplementedError
@staticmethod
def bwd(z: torch.Tensor, mask: torch.Tensor, pa... | 4,619 | 32.478261 | 101 | py |
flowseq | flowseq-master/flownmt/flows/couplings/coupling.py | from overrides import overrides
from typing import Tuple, Dict
import torch
from flownmt.flows.couplings.blocks import NICEConvBlock, NICERecurrentBlock, NICESelfAttnBlock
from flownmt.flows.flow import Flow
from flownmt.flows.couplings.transform import Transform, Additive, Affine, NLSQ
class NICE(Flow):
"""
... | 7,316 | 40.573864 | 155 | py |
flowseq | flowseq-master/flownmt/flows/couplings/blocks.py | import torch
import torch.nn as nn
from torch.nn.utils.rnn import pad_packed_sequence, pack_padded_sequence
from flownmt.nnet.weightnorm import Conv1dWeightNorm, LinearWeightNorm
from flownmt.nnet.attention import GlobalAttention, MultiHeadAttention
from flownmt.nnet.positional_encoding import PositionalEncoding
from ... | 5,809 | 44.748031 | 133 | py |
flowseq | flowseq-master/flownmt/optim/lr_scheduler.py | from torch.optim.optimizer import Optimizer
class _LRScheduler(object):
def __init__(self, optimizer, last_epoch=-1):
if not isinstance(optimizer, Optimizer):
raise TypeError('{} is not an Optimizer'.format(
type(optimizer).__name__))
self.optimizer = optimizer
... | 4,603 | 40.477477 | 94 | py |
flowseq | flowseq-master/flownmt/optim/adamw.py | import math
import torch
from torch.optim.optimizer import Optimizer
class AdamW(Optimizer):
r"""Implements AdamW algorithm.
This implementation is modified from torch.optim.Adam based on:
`Fixed Weight Decay Regularization in Adam`
(see https://arxiv.org/abs/1711.05101)
Adam has been proposed in... | 4,811 | 41.584071 | 116 | py |
flowseq | flowseq-master/flownmt/nnet/weightnorm.py | from overrides import overrides
import torch
import torch.nn as nn
class LinearWeightNorm(nn.Module):
"""
Linear with weight normalization
"""
def __init__(self, in_features, out_features, bias=True):
super(LinearWeightNorm, self).__init__()
self.linear = nn.Linear(in_features, out_fea... | 2,806 | 32.819277 | 91 | py |
flowseq | flowseq-master/flownmt/nnet/transformer.py | import torch.nn as nn
from flownmt.nnet.attention import MultiHeadAttention, PositionwiseFeedForward
class TransformerEncoderLayer(nn.Module):
def __init__(self, model_dim, hidden_dim, heads, dropout=0.0, mask_diag=False):
super(TransformerEncoderLayer, self).__init__()
self.slf_attn = MultiHeadA... | 1,784 | 42.536585 | 98 | py |
flowseq | flowseq-master/flownmt/nnet/positional_encoding.py | import math
import torch
import torch.nn as nn
from flownmt.utils import make_positions
class PositionalEncoding(nn.Module):
"""This module produces sinusoidal positional embeddings of any length.
Padding symbols are ignored.
"""
def __init__(self, encoding_dim, padding_idx, init_size=1024):
... | 2,348 | 36.285714 | 99 | py |
flowseq | flowseq-master/flownmt/nnet/layer_norm.py | import torch
import torch.nn as nn
def LayerNorm(normalized_shape, eps=1e-5, elementwise_affine=True, export=False):
if not export and torch.cuda.is_available():
try:
from apex.normalization import FusedLayerNorm
return FusedLayerNorm(normalized_shape, eps, elementwise_affine)
... | 428 | 32 | 81 | py |
flowseq | flowseq-master/flownmt/nnet/criterion.py | import torch.nn.functional as F
import torch.nn as nn
class LabelSmoothedCrossEntropyLoss(nn.Module):
"""
Cross Entropy loss with label smoothing.
For training, the loss is smoothed with parameter eps, while for evaluation, the smoothing is disabled.
"""
def __init__(self, label_smoothing):
... | 1,029 | 35.785714 | 107 | py |
flowseq | flowseq-master/flownmt/nnet/attention.py | from overrides import overrides
import torch
from torch.nn import Parameter
import torch.nn as nn
import torch.nn.functional as F
from flownmt.nnet.layer_norm import LayerNorm
class GlobalAttention(nn.Module):
"""
Global Attention between encoder and decoder
"""
def __init__(self, key_features, quer... | 9,245 | 35.401575 | 116 | py |
flowseq | flowseq-master/flownmt/data/dataloader.py | import codecs
import math
import random
from collections import defaultdict
import numpy as np
import torch
import os
def get_sorted_wordlist(path):
freqs = defaultdict(lambda: 0)
with codecs.open(path, "r", encoding="utf-8") as fin:
for line in fin:
words = line.strip().split()
... | 21,852 | 39.097248 | 149 | py |
flowseq | flowseq-master/experiments/nmt.py | import os
import sys
current_path = os.path.dirname(os.path.realpath(__file__))
root_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(root_path)
import time
import json
import random
import math
import numpy as np
import torch
from torch.nn.utils import clip_grad_norm_
import torch... | 34,259 | 41.559006 | 151 | py |
flowseq | flowseq-master/experiments/slurm.py | import sys
import os
current_path = os.path.dirname(os.path.realpath(__file__))
root_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(root_path)
import torch.multiprocessing as mp
import experiments.options as options
from experiments.nmt import main as single_process_main
def ma... | 1,374 | 27.645833 | 117 | py |
flowseq | flowseq-master/experiments/translate.py | import os
import sys
current_path = os.path.dirname(os.path.realpath(__file__))
root_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(root_path)
import time
import json
import random
import numpy as np
import torch
from flownmt.data import NMTDataSet, DataIterator
from flownmt imp... | 8,142 | 39.311881 | 131 | py |
flowseq | flowseq-master/experiments/distributed.py | import sys
import os
current_path = os.path.dirname(os.path.realpath(__file__))
root_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(root_path)
import json
import signal
import threading
import torch
from flownmt.data import NMTDataSet
import experiments.options as options
from ex... | 4,220 | 30.736842 | 107 | py |
PCVLabDrone2021 | PCVLabDrone2021-main/UAV Geolocalization/test.py | from pathlib import Path
import os
import gc
import argparse
import cv2
from PIL import Image
Image.MAX_IMAGE_PIXELS = 933120000
import numpy as np
import matplotlib.cm as cm
from pyqtree import Index
import pickle
import torch
import time
from models.matching import Matching
from models.utils.utils import AverageTime... | 14,274 | 45.347403 | 182 | py |
PCVLabDrone2021 | PCVLabDrone2021-main/UAV Geolocalization/Feature_extractor.py | from pathlib import Path
import argparse
import numpy as np
import torch
import json
import os
from models.matching import Matching
from models.utils.utils import (AverageTimer, VideoStreamer, load_encoder_img, frame2tensor)
torch.set_grad_enabled(False)
if __name__ == '__main__':
parser = argparse.ArgumentPars... | 5,454 | 38.528986 | 103 | py |
PCVLabDrone2021 | PCVLabDrone2021-main/UAV Geolocalization/models/matching.py | # %BANNER_BEGIN%
# ---------------------------------------------------------------------
# %COPYRIGHT_BEGIN%
#
# Magic Leap, Inc. ("COMPANY") CONFIDENTIAL
#
# Unpublished Copyright (c) 2020
# Magic Leap, Inc., All Rights Reserved.
#
# NOTICE: All information contained herein is, and remains the property
# of COMPAN... | 3,417 | 39.211765 | 77 | py |
PCVLabDrone2021 | PCVLabDrone2021-main/UAV Geolocalization/models/superglue.py | # %BANNER_BEGIN%
# ---------------------------------------------------------------------
# %COPYRIGHT_BEGIN%
#
# Magic Leap, Inc. ("COMPANY") CONFIDENTIAL
#
# Unpublished Copyright (c) 2020
# Magic Leap, Inc., All Rights Reserved.
#
# NOTICE: All information contained herein is, and remains the property
# of COMPAN... | 11,316 | 38.848592 | 86 | py |
PCVLabDrone2021 | PCVLabDrone2021-main/UAV Geolocalization/models/superpoint.py | # %BANNER_BEGIN%
# ---------------------------------------------------------------------
# %COPYRIGHT_BEGIN%
#
# Magic Leap, Inc. ("COMPANY") CONFIDENTIAL
#
# Unpublished Copyright (c) 2020
# Magic Leap, Inc., All Rights Reserved.
#
# NOTICE: All information contained herein is, and remains the property
# of COMPAN... | 8,145 | 39.128079 | 80 | py |
PCVLabDrone2021 | PCVLabDrone2021-main/UAV Geolocalization/models/utils/utils.py | from pathlib import Path
import time
from collections import OrderedDict
from threading import Thread
import numpy as np
import math
from vidgear.gears import CamGear
import cv2
import torch
import matplotlib.pyplot as plt
import matplotlib
matplotlib.use('Agg')
class AverageTimer:
""" Class to help manage printi... | 14,700 | 38.732432 | 157 | py |
bmm | bmm-master/docs/conf.py | # Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If ex... | 2,323 | 34.753846 | 79 | py |
STEP | STEP-master/src/train_gnn.py | import pytorch_lightning as pyl
import torch
import torch.nn.functional as F
import numpy as np
import datasets as dataset
import torch.utils.data
import sklearn
from option import args
from model.tgat import TGAT
class ModelLightning(pyl.LightningModule):
def __init__(self, config, backbone):
super().__... | 3,844 | 28.128788 | 122 | py |
STEP | STEP-master/src/datasets_edge.py | import torch
import torch.utils.data
import os
import numpy as np
import random
import pandas as pd
class Data:
def __init__(self, sources, destinations, timestamps, edge_idxs, labels):
self.sources = sources
self.destinations = destinations
self.timestamps = timestamps
self.edge_i... | 3,073 | 26.693694 | 92 | py |
STEP | STEP-master/src/datasets.py | import torch
import torch.utils.data
import os
import numpy as np
from option import args
import random
import pandas as pd
from utils import get_neighbor_finder, masked_get_neighbor_finder
from operator import itemgetter
class Data:
def __init__(self, sources, destinations, timestamps, edge_idxs, labels):
... | 9,798 | 39.159836 | 130 | py |
STEP | STEP-master/src/eval_gnn.py | import pytorch_lightning as pyl
import torch
import torch.nn.functional as F
import numpy as np
import datasets as dataset
import torch.utils.data
import sklearn
from option import args
from model.tgat import TGAT
class ModelLightning(pyl.LightningModule):
def __init__(self, config, backbone):
super().__... | 4,116 | 29.272059 | 122 | py |
STEP | STEP-master/src/edge_pruning.py | import pytorch_lightning as pyl
import torch
import torch.nn.functional as F
import numpy as np
import datasets_edge as dataset
import torch.utils.data
import sklearn
from option import args
from model.precom_model import Precom_Model
class ModelLightning(pyl.LightningModule):
def __init__(self, config, backbone):... | 4,096 | 29.125 | 122 | py |
STEP | STEP-master/src/train_gsn.py | import pytorch_lightning as pyl
import torch
import datasets as dataset
import torch.utils.data
from option import args
from model.tgat import TGAT
class ModelLightning(pyl.LightningModule):
def __init__(self, config, backbone):
super().__init__()
self.config = config
self.backbone = backb... | 4,863 | 31.426667 | 95 | py |
STEP | STEP-master/src/modules/time_encoding.py | import torch
import numpy as np
class TimeEncode(torch.nn.Module):
# Time Encoding proposed by TGAT
def __init__(self, dimension):
super(TimeEncode, self).__init__()
self.dimension = dimension
self.w = torch.nn.Linear(1, dimension)
self.w.weight = torch.nn.Parameter((torch.from_numpy(1 / 10 ** n... | 802 | 28.740741 | 99 | py |
STEP | STEP-master/src/modules/utils.py | import numpy as np
import torch
from sklearn.metrics import roc_auc_score
import math
import time
class MergeLayer(torch.nn.Module):
def __init__(self, dim1, dim2, dim3, dim4):
super().__init__()
self.layer_norm = torch.nn.LayerNorm(dim1 + dim2)
self.fc1 = torch.nn.Linear(dim1 + dim2, dim3)
self.fc2 ... | 1,731 | 26.935484 | 67 | py |
STEP | STEP-master/src/modules/temporal_attention.py | import torch
import torch_scatter as scatter
from torch import nn
from modules.utils import MergeLayer
class TemporalAttentionLayer2(torch.nn.Module):
"""
Temporal attention layer. Return the temporal embedding of a node given the node itself,
its neighbors and the edge timestamps.
"""
def __init__(self, ... | 6,626 | 43.47651 | 161 | py |
STEP | STEP-master/src/modules/embedding_module.py | import torch
from torch import nn
import numpy as np
import math
from modules.temporal_attention import TemporalAttentionLayer2
class EmbeddingModule(nn.Module):
def __init__(self, time_encoder, n_layers,
node_features_dims, edge_features_dims, time_features_dim, hidden_dim, dropout):
super(Embed... | 7,015 | 42.57764 | 113 | py |
STEP | STEP-master/src/model/tgat.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch_scatter as scatter
from modules.utils import MergeLayer_output, Feat_Process_Layer
from modules.embedding_module import get_embedding_module
from modules.time_encoding import TimeEncode
from model.gsn import Graph_sampling_network
from mode... | 5,947 | 48.983193 | 125 | py |
STEP | STEP-master/src/model/gsn.py | import torch
import torch.nn.functional as F
import torch_scatter as scatter
class Graph_sampling_network(torch.nn.Module):
def __init__(self, dim, batch_size, mask_ratio=0.5):
super(Graph_sampling_network, self).__init__()
self.mask_act = 'sigmoid'
self.mask_ratio = mask_ratio
sel... | 4,736 | 37.201613 | 136 | py |
STEP | STEP-master/src/model/gpn.py | import torch
from modules.utils import MergeLayer_output, Feat_Process_Layer
class Graph_pruning_network(torch.nn.Module):
def __init__(self, input_dim, hidden_dim, drop_out):
super(Graph_pruning_network, self).__init__()
self.edge_dim = input_dim
self.dims = hidden_dim
self.dropou... | 1,839 | 34.384615 | 128 | py |
SIT | SIT-master/tree_util.py | import numpy as np
import math
import matplotlib.pyplot as plt
import ipdb
import torch
def rotation_matrix(thea):
return np.array([
[np.cos(thea), -1 * np.sin(thea)],
[np.sin(thea), np.cos(thea)]
])
def generating_tree(seq, dir_list, split_interval=4, degree=3):
# seq [N n seq_len 2]
... | 6,747 | 33.080808 | 109 | py |
SIT | SIT-master/dataset.py | import pickle
import numpy as np
from torch.utils import data
from util import get_train_test_data, data_augmentation
from tree_util import tree_build, tree_label
class DatasetETHUCY(data.Dataset):
def __init__(self, data_path, dataset_name, batch_size, is_test, end_centered=True,
data_flip=Fals... | 1,893 | 34.074074 | 140 | py |
SIT | SIT-master/run.py | import argparse
from dataset import DatasetETHUCY
import util
import logging
import torch
from model.trajectory_model import TrajectoryModel
from torch.optim import Adam, lr_scheduler
import os
logging.basicConfig(format='%(asctime)s - %(levelname)s - %(name)s - %(message)s',
datefmt='%m/%d/%Y %H... | 6,964 | 36.446237 | 115 | py |
SIT | SIT-master/util.py | from typing import Dict
import os
import subprocess
import random
import pickle
import torch
import numpy as np
import argparse
class Args:
dataset = None
epoch = None
lr = None
lr_scheduler = None
lr_milestones = None
lr_gamma = None
obs_len = None
pred_len = None
train_batch_size... | 6,257 | 29.231884 | 125 | py |
SIT | SIT-master/model/component.py | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
class Activation_Fun(nn.Module):
def __init__(self, act_name):
super(Activation_Fun, self).__init__()
if act_name == 'relu':
self.act = nn.ReLU()
if act_name == 'prelu':
self.act = nn.P... | 2,946 | 31.384615 | 118 | py |
SIT | SIT-master/model/trajectory_model.py |
import torch
import torch.nn as nn
from model.component import MLP
from model.component import SelfAttention
from util import ModelArgs
class TrajectoryModel(nn.Module):
def __init__(self, args: ModelArgs):
super(TrajectoryModel, self).__init__()
in_dim = args.in_dim
obs_len = args.obs... | 6,157 | 33.022099 | 111 | py |
adanet | adanet-master/research/improve_nas/trainer/cifar100.py | # Lint as: python3
"""CIFAR-100 data and convenience functions.
Copyright 2019 The AdaNet Authors. All Rights Reserved.
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
https://www.apache.org/l... | 5,382 | 31.823171 | 79 | py |
adanet | adanet-master/research/improve_nas/trainer/cifar10.py | # Lint as: python3
"""CIFAR-10 data and convenience functions.
Copyright 2019 The AdaNet Authors. All Rights Reserved.
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
https://www.apache.org/li... | 5,373 | 32.5875 | 80 | py |
adanet | adanet-master/docs/source/conf.py | # -*- coding: utf-8 -*-
# Copyright 2018 The AdaNet Authors. All Rights Reserved.
# 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless r... | 6,636 | 31.218447 | 79 | py |
adanet | adanet-master/adanet/modelflow_test.py | # Lint as: python3
# Copyright 2020 The AdaNet Authors. All Rights Reserved.
# 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless requir... | 1,637 | 38.95122 | 74 | py |
adanet | adanet-master/adanet/core/ensemble_builder_test.py | """Test AdaNet ensemble single graph implementation.
Copyright 2018 The AdaNet Authors. All Rights Reserved.
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
https://www.apache.org/licenses/LIC... | 31,597 | 37.770552 | 83 | py |
adanet | adanet-master/adanet/core/eval_metrics_test.py | """Tests for AdaNet eval metrics.
Copyright 2019 The AdaNet Authors. All Rights Reserved.
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
https://www.apache.org/licenses/LICENSE-2.0
Unless re... | 8,994 | 35.714286 | 80 | py |
adanet | adanet-master/adanet/core/estimator_distributed_test_runner.py | # List as: python2, python3
# Copyright 2019 The AdaNet Authors. All Rights Reserved.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# U... | 15,527 | 37.626866 | 111 | py |
adanet | adanet-master/adanet/core/estimator_test.py | """Test AdaNet estimator single graph implementation.
Copyright 2018 The AdaNet Authors. All Rights Reserved.
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
https://www.apache.org/licenses/LI... | 115,180 | 33.734922 | 139 | py |
adanet | adanet-master/adanet/distributed/placement_test.py | # Copyright 2019 The AdaNet Authors. All Rights Reserved.
# 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable la... | 19,604 | 33.334501 | 80 | py |
adanet | adanet-master/adanet/autoensemble/estimator_v2_test.py | """Tests for AdaNet AutoEnsembleEstimator in TF 2.
Copyright 2019 The AdaNet Authors. All Rights Reserved.
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
https://www.apache.org/licenses/LICEN... | 5,484 | 35.324503 | 80 | py |
adanet | adanet-master/adanet/experimental/__init__.py | # Lint as: python3
# Copyright 2020 The AdaNet Authors. All Rights Reserved.
# 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless requir... | 1,021 | 29.969697 | 74 | py |
adanet | adanet-master/adanet/experimental/storages/storage.py | # Lint as: python3
# Copyright 2019 The AdaNet Authors. All Rights Reserved.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless req... | 1,910 | 29.822581 | 80 | py |
adanet | adanet-master/adanet/experimental/storages/in_memory_storage.py | # Lint as: python3
# Copyright 2019 The AdaNet Authors. All Rights Reserved.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless req... | 2,113 | 34.233333 | 78 | py |
adanet | adanet-master/adanet/experimental/work_units/keras_tuner_work_unit.py | # Lint as: python3
# Copyright 2019 The AdaNet Authors. All Rights Reserved.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless req... | 1,584 | 37.658537 | 74 | py |
adanet | adanet-master/adanet/experimental/work_units/keras_trainer_work_unit.py | # Lint as: python3
# Copyright 2019 The AdaNet Authors. All Rights Reserved.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless req... | 2,301 | 40.107143 | 79 | py |
adanet | adanet-master/adanet/experimental/work_units/__init__.py | # Lint as: python3
# Copyright 2020 The AdaNet Authors. All Rights Reserved.
# 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless requir... | 899 | 35 | 87 | py |
adanet | adanet-master/adanet/experimental/phases/autoensemble_phase.py | # Lint as: python3
# Copyright 2020 The AdaNet Authors. All Rights Reserved.
# 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless requir... | 6,425 | 34.899441 | 87 | py |
adanet | adanet-master/adanet/experimental/phases/repeat_phase.py | # Lint as: python3
# Copyright 2020 The AdaNet Authors. All Rights Reserved.
# 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless requir... | 3,035 | 38.947368 | 78 | py |
adanet | adanet-master/adanet/experimental/phases/keras_tuner_phase.py | # Lint as: python3
# Copyright 2019 The AdaNet Authors. All Rights Reserved.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless req... | 2,683 | 36.277778 | 83 | py |
adanet | adanet-master/adanet/experimental/phases/phase.py | # Lint as: python3
# Copyright 2019 The AdaNet Authors. All Rights Reserved.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless req... | 2,294 | 28.805195 | 80 | py |
adanet | adanet-master/adanet/experimental/phases/__init__.py | # Lint as: python3
# Copyright 2020 The AdaNet Authors. All Rights Reserved.
# 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless requir... | 1,131 | 35.516129 | 76 | py |
adanet | adanet-master/adanet/experimental/phases/keras_trainer_phase.py | # Lint as: python3
# Copyright 2019 The AdaNet Authors. All Rights Reserved.
# 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless requir... | 2,844 | 39.070423 | 87 | py |
adanet | adanet-master/adanet/experimental/keras/ensemble_model.py | # Lint as: python3
# Copyright 2019 The AdaNet Authors. All Rights Reserved.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless req... | 2,663 | 29.62069 | 79 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.