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 |
|---|---|---|---|---|---|---|
pybo | pybo-master/pybo/demos/animated2.py | """
Animated demo showing progress of Bayesian optimization on a simple
two-dimensional function.
"""
from __future__ import division
from __future__ import absolute_import
from __future__ import print_function
import numpy as np
from reggie import make_gp, MCMC
from ezplot import figure, show
from pybo import init... | 3,847 | 30.032258 | 80 | py |
pybo | pybo-master/pybo/demos/bandit.py | """
Animated demo showing optimization of a bandit with independent arms.
"""
from __future__ import division
from __future__ import absolute_import
from __future__ import print_function
import numpy as np
from reggie import BetaBernoulli
from ezplot import figure, show
def main():
"""Run the demo."""
# de... | 1,684 | 23.779412 | 73 | py |
pybo | pybo-master/pybo/demos/subprocess.py | """
This demo illustrates how to use pybo to optimize a black-box function that
calls an external process. In particular this calls the command line calculator
`bc` to optimize a simple quadratic.
"""
from __future__ import division
from __future__ import absolute_import
from __future__ import print_function
import n... | 1,013 | 23.142857 | 79 | py |
pybo | pybo-master/pybo/demos/solve.py | """
Demo which illustrates how to use solve_bayesopt as a simple method for global
optimization. The return values are the sequence of recommendations made by the
algorithm as well as the final model. The point `xbest[-1]` is the final
recommendation, i.e. the expected maximizer.
"""
from __future__ import division
fr... | 1,238 | 22.826923 | 79 | py |
pybo | pybo-master/pybo/demos/interactive.py | """
This demo illustrates how to use pybo to optimize a black-box function that
requires a human in the loop. This script will prompt the user for a numerical
value at a particular design point every time it needs a new observation.
"""
from __future__ import division
from __future__ import absolute_import
from __futu... | 1,067 | 23.837209 | 78 | py |
pybo | pybo-master/pybo/demos/animated.py | """
Animated demo showing progress of Bayesian optimization on a simple
(but highly multimodal) one-dimensional function.
"""
from __future__ import division
from __future__ import absolute_import
from __future__ import print_function
import numpy as np
from reggie import make_gp, MCMC
from ezplot import figure, sho... | 3,215 | 27.460177 | 79 | py |
pybo | pybo-master/pybo/demos/__init__.py | 0 | 0 | 0 | py | |
RLNLocalization | RLNLocalization-main/main.py | # =====================================================
# Train the segmentation Network for the three tissues
# =====================================================
import time
from op.run_op import Trainer
from op.args_op import TrainParsers
if __name__ == '__main__':
exp_name = "UNetSeg"
args = TrainPars... | 1,250 | 30.275 | 110 | py |
RLNLocalization | RLNLocalization-main/statistic_test.py | # ========================================
# Perform alignment based on Prior Library
# ========================================
import os
import numpy as np
import matplotlib.pyplot as plt
from tqdm import tqdm
from PIL import Image
from scipy.ndimage import center_of_mass
from medpy.metric import dc
from torchvision... | 5,288 | 37.326087 | 120 | py |
RLNLocalization | RLNLocalization-main/utils.py | import os
import torch
import numpy as np
from matplotlib import pyplot as plt
from medpy.metric import dc
from dipy.align import imaffine
from dipy.align import transforms
def check_dir(path):
if not os.path.exists(path):
os.makedirs(path, exist_ok=True)
def set_device(cuda):
"""
Set the torch ... | 4,994 | 26.75 | 129 | py |
RLNLocalization | RLNLocalization-main/refine_infer.py | # =====================================================
# Test the segmentation Network for the three tissues
# =====================================================
from op import args_op as ini_op
from op.run_op import RefineTester
if __name__ == '__main__':
exp_name = "RefineLocate-v2"
args = ini_op.Refin... | 451 | 24.111111 | 55 | py |
RLNLocalization | RLNLocalization-main/refine_train.py | # =====================================================
# Train the segmentation Network for the three tissues
# =====================================================
import time
from op.run_op import Refiner
from op.args_op import RefineParsers
if __name__ == '__main__':
exp_name = "RefineLocate-v2"
args = ... | 1,260 | 30.525 | 110 | py |
RLNLocalization | RLNLocalization-main/prior_localize.py | import os
import numpy as np
from PIL import Image
from matplotlib import pyplot as plt
from torchvision import transforms as T
from scipy.ndimage import center_of_mass
PRIOR_PATH = 'PRIOR_right'
SAVE_PATH = 'Prior_Results_right'
GT_PATH = '../Dataset/Data'
mask_transform = T.Compose([
T.Resize((256, 256), Image.... | 3,704 | 35.683168 | 119 | py |
RLNLocalization | RLNLocalization-main/infer.py | # =====================================================
# Test the segmentation Network for the three tissues
# =====================================================
from op import args_op as ini_op
from op.run_op import Tester
if __name__ == '__main__':
exp_name = "UNetSeg"
args = ini_op.TestParsers(exp_nam... | 425 | 22.666667 | 55 | py |
RLNLocalization | RLNLocalization-main/models/__init__.py | from models.AutoEncoder.model import U_Net
from models.Regress.model import Locator, GLLocator, MSLocator, MCLocator, SLocator
| 127 | 41.666667 | 83 | py |
RLNLocalization | RLNLocalization-main/models/Regress/model.py | import torch
from torch import nn
from torch.nn import functional as F
import numpy as np
from utils import tensor2array
from medpy.metric import dc
class conv_block(nn.Module):
"""
Convolution Block
"""
def __init__(self, in_ch, out_ch):
super(conv_block, self).__init__()
self.conv ... | 5,554 | 26.775 | 85 | py |
RLNLocalization | RLNLocalization-main/models/Regress/__init__.py | 0 | 0 | 0 | py | |
RLNLocalization | RLNLocalization-main/models/AutoEncoder/model.py | import torch
from torch import nn
from torch.nn import functional as F
import numpy as np
from utils import tensor2array
from medpy.metric import dc
class conv_block(nn.Module):
"""
Convolution Block
"""
def __init__(self, in_ch, out_ch):
super(conv_block, self).__init__()
self.conv ... | 3,901 | 27.071942 | 85 | py |
RLNLocalization | RLNLocalization-main/models/AutoEncoder/__init__.py | 0 | 0 | 0 | py | |
RLNLocalization | RLNLocalization-main/op/model_op.py | from models import U_Net, Locator, MCLocator
def load_model(args):
if "UNet" in args.exp_name:
model = U_Net(
in_ch=args.in_dim,
out_ch=args.out_dim,
feat_n=args.feat_n,
loss_weight=args.loss_weight
)
elif "Locate-v1" in args.exp_name:
mo... | 681 | 23.357143 | 44 | py |
RLNLocalization | RLNLocalization-main/op/args_op.py | import os
class BaseParsers(object):
def __init__(self, exp_name):
self.exp_name = exp_name
self.log_path = os.path.join("../Exps", exp_name, "logs")
self.ckpt_path = os.path.join("../Exps", exp_name, "ckpts")
self.save_path = os.path.join("../Exps", exp_name, "save")
self.... | 1,830 | 25.157143 | 76 | py |
RLNLocalization | RLNLocalization-main/op/data_op.py | import os
import torch
import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
from scipy.ndimage import center_of_mass
from random import uniform
from torch.utils.data import Dataset
from torchvision import transforms as T
from torchvision.transforms.functional import crop, to_tensor
def load_list(t... | 9,157 | 36.076923 | 108 | py |
RLNLocalization | RLNLocalization-main/op/run_op.py | import os
import torch
from PIL import Image
import matplotlib.pyplot as plt
from torch.utils.data import DataLoader
from op.data_op import RLNDataset, RLNRefineDataset, RLNRriorDataset
from utils import Recorder, set_device, tensor2array
import os
import torch
import numpy as np
from medpy.metric import dc
from dateti... | 13,171 | 34.6 | 112 | py |
RLNLocalization | RLNLocalization-main/op/__init__.py | 0 | 0 | 0 | py | |
metfaces-dataset | metfaces-dataset-master/metfaces.py | # Copyright 2020 NVIDIA Corporation
#
# 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/LICENSE-2.0
#
# Unless required by applicable law or agreed to in wr... | 7,389 | 45.772152 | 180 | py |
Wasserstein2Barycenters | Wasserstein2Barycenters-main/src/distributions.py | import torch
import numpy as np
from scipy.linalg import sqrtm
import sklearn.datasets
import random
def symmetrize(X):
return np.real((X + X.T) / 2)
class Sampler:
def __init__(
self, device='cuda',
requires_grad=False,
):
self.device = device
self.requires_grad = requires... | 16,356 | 33.006237 | 119 | py |
Wasserstein2Barycenters | Wasserstein2Barycenters-main/src/benchmarks.py | import torch
import torch.nn as nn
import numpy as np
from scipy.stats import ortho_group
from scipy.linalg import sqrtm
from .tools import calculate_frechet_distance
from tqdm import tqdm_notebook as tqdm
from . import distributions
def symmetrize(X):
return np.real((X + X.T) / 2)
def get_barycenter_cov(covs, al... | 10,558 | 40.735178 | 111 | py |
Wasserstein2Barycenters | Wasserstein2Barycenters-main/src/plotters.py | import numpy as np
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import torch
import gc
def plot_rgb_cloud(cloud, ax):
colors = np.clip(cloud, 0, 1)
ax.scatter(cloud[:, 0], cloud[:, 1], cloud[:, 2], c=colors)
ax.set_xlabel('Red'); ax.set_ylabe... | 6,593 | 37.115607 | 112 | py |
Wasserstein2Barycenters | Wasserstein2Barycenters-main/src/tools.py | import os, sys
import torchvision.datasets as datasets
import numpy as np
import pandas as pd
from tqdm import tqdm
from scipy.linalg import sqrtm
import os, sys
import argparse
import collections
from scipy.io import savemat
from tqdm import trange
from torchvision.utils import save_image
from torch.utils.data import... | 5,715 | 34.725 | 106 | py |
Wasserstein2Barycenters | Wasserstein2Barycenters-main/src/layers.py | import torch
import torch.autograd as autograd
import torch.nn as nn
import torch.nn.functional as F
class ConvexQuadratic(nn.Module):
'''Convex Quadratic Layer'''
__constants__ = ['in_features', 'out_features', 'quadratic_decomposed', 'weight', 'bias']
def __init__(self, in_features, out_features, bias=T... | 2,893 | 33.047059 | 105 | py |
Wasserstein2Barycenters | Wasserstein2Barycenters-main/src/icnn.py | import torch
import torch.autograd as autograd
import torch.nn as nn
import torch.nn.functional as F
from .layers import ConvexQuadratic, Conv2dConvexQuadratic
class DenseICNN(nn.Module):
'''Fully Conncted ICNN with input-quadratic skip connections'''
def __init__(
self, in_dim,
hidden_la... | 8,460 | 37.990783 | 115 | py |
zind | zind-main/download_data.py | import argparse
import hashlib
import json
import logging
import os
import sys
import time
from multiprocessing import cpu_count
from multiprocessing.pool import ThreadPool
from typing import Dict, List
import requests
from tqdm import tqdm as progress_bar
LOG_FILE_NAME = "zind.log"
BRIDGE_API_URL = (
"https://ap... | 16,737 | 33.654244 | 119 | py |
zind | zind-main/code/partition_zind.py | # """ Script to partition ZInD to train/val/test (0.8 : 0.1 : 0.1).
# The train/val/test splits will have similar distributions under the following metrics:
# 1. Layout complexities (cuboid, L-shape, etc.)
# 2. Number of floors
# 3. Number of primary panoramas
# 4. Number of secondary panoramas
# 5. Total area (to ens... | 8,190 | 39.349754 | 175 | py |
zind | zind-main/code/visualize_zind_cli.py | # """CLI script to visualize & validate data for the public-facing Zillow Indoor Dataset (ZInD).
#
# Validation includes:
# (1) required JSON fields are presented
# (2) verify non self-intersection of room floor_plan_layouts
# (3) verify that windows/doors/openings lie on the room layout geometry
# (4) verify that ... | 9,753 | 33.711744 | 117 | py |
zind | zind-main/code/render.py | """
This module contains some common rendering routines.
"""
import itertools
import logging
import os
import sys
from typing import List, Dict, Any
import cv2
import numpy as np
from pano_image import PanoImage
from transformations import TransformationSpherical, Transformation3D
from utils import Polygon, PolygonTyp... | 12,117 | 37.469841 | 111 | py |
zind | zind-main/code/utils.py | """
This module contains some common routines and types used by other modules.
"""
import collections
from enum import Enum
from typing import List, NamedTuple, Tuple
import numpy as np
import shapely.geometry
# We use OpenCV's type as the underlying 2D image type.
Image = np.ndarray
CHECK_RIGHT_ANGLE_THRESH = 0.1
... | 1,941 | 24.552632 | 112 | py |
zind | zind-main/code/transformations.py | """
This module provides utilities to handle the various coordinate system transformations:
1. Spherical to/from cartesian
2. 3D room layout to/from pano pixels
3. 3D room floor_plan_layouts to/from 2D top-down merged floor_plan_layouts
"""
import collections
import logging
import math
import sys
from typing import Lis... | 7,990 | 33.895197 | 110 | py |
zind | zind-main/code/pano_image.py | """PanoImage module provides utilities to represent and work with 360 images (in Equirectangular projection).
Typical usage example:
pano_image = PanoImage(image_file_path) # Load a 360 panorama.
pano_image.draw_XXX(...) # Draw various elements like markers and lines.
pano_image_cv = pano_image.... | 10,955 | 35.398671 | 116 | py |
zind | zind-main/code/floor_plan.py | """FloorPlan module provides utilities to represent and work with ZInD floor plans.
Typical usage example:
zfp = FloorPlan(input_json_file) # Load and parse ZInD JSON file as a Zillow FloorPlan object.
top_down_layouts = zfp.floor_plan_layouts["raw"] # Retrieve the 2D merged top-down floor plan layouts and WDO.
pano... | 21,972 | 43.842857 | 118 | py |
LasagneNLP | LasagneNLP-master/bi_lstm.py | __author__ = 'max'
import time
import sys
import argparse
from lasagne_nlp.utils import utils
import lasagne_nlp.utils.data_processor as data_processor
import theano.tensor as T
import theano
import lasagne
from lasagne_nlp.networks.networks import build_BiLSTM
import lasagne.nonlinearities as nonlinearities
def mai... | 13,356 | 47.394928 | 153 | py |
LasagneNLP | LasagneNLP-master/bi_lstm_cnn_crf.py | __author__ = 'max'
import time
import sys
import argparse
from lasagne_nlp.utils import utils
import lasagne_nlp.utils.data_processor as data_processor
from lasagne_nlp.utils.objectives import crf_loss, crf_accuracy
import lasagne
import theano
import theano.tensor as T
from lasagne_nlp.networks.networks import build_... | 15,909 | 48.256966 | 153 | py |
LasagneNLP | LasagneNLP-master/bi_lstm_highcnn.py | __author__ = 'max'
import time
import sys
import argparse
from lasagne_nlp.utils import utils
import lasagne_nlp.utils.data_processor as data_processor
import theano.tensor as T
import theano
import lasagne
from lasagne_nlp.networks.networks import build_BiLSTM_HighCNN
import lasagne.nonlinearities as nonlinearities
... | 15,407 | 50.019868 | 153 | py |
LasagneNLP | LasagneNLP-master/bi_lstm_cnn.py | __author__ = 'max'
import time
import sys
import argparse
from lasagne_nlp.utils import utils
import lasagne_nlp.utils.data_processor as data_processor
import theano.tensor as T
import theano
import lasagne
from lasagne_nlp.networks.networks import build_BiLSTM_CNN
import lasagne.nonlinearities as nonlinearities
def... | 15,385 | 49.94702 | 153 | py |
LasagneNLP | LasagneNLP-master/bi_rnn.py | __author__ = 'max'
import time
import sys
import argparse
from lasagne_nlp.utils import utils
from lasagne_nlp.utils.regularization import dima
import lasagne_nlp.utils.data_processor as data_processor
import theano.tensor as T
import theano
import lasagne
from lasagne_nlp.networks.networks import build_BiRNN
import l... | 13,596 | 47.734767 | 138 | py |
LasagneNLP | LasagneNLP-master/lasagne_nlp/__init__.py | __author__ = 'max'
| 19 | 9 | 18 | py |
LasagneNLP | LasagneNLP-master/lasagne_nlp/networks/parser.py | __author__ = 'max'
import theano.tensor as T
from lasagne.layers import MergeLayer
from lasagne import init
__all__ = [
"DepParserLayer",
]
class DepParserLayer(MergeLayer):
"""
"""
def __init__(self, incoming, num_labels, mask_input=None, W_h=init.GlorotUniform(), W_c=init.GlorotUniform(),
... | 3,727 | 36.656566 | 113 | py |
LasagneNLP | LasagneNLP-master/lasagne_nlp/networks/highway.py | __author__ = 'max'
import theano.tensor as T
import numpy as np
from lasagne import init
from lasagne.layers import Layer
import lasagne.nonlinearities as nonlinearities
__all__ = [
"HighwayDenseLayer",
]
class HighwayDenseLayer(Layer):
"""
lasagne_nlp.networks.highway.HighwayDenseLayer(incoming, W_h=in... | 3,869 | 39.736842 | 109 | py |
LasagneNLP | LasagneNLP-master/lasagne_nlp/networks/networks.py | __author__ = 'max'
import lasagne
import lasagne.nonlinearities as nonlinearities
from lasagne.layers import Gate
from lasagne_nlp.networks.crf import CRFLayer
from lasagne_nlp.networks.highway import HighwayDenseLayer
def build_BiRNN(incoming, num_units, mask=None, grad_clipping=0, nonlinearity=nonlinearities.tanh,... | 16,251 | 56.631206 | 132 | py |
LasagneNLP | LasagneNLP-master/lasagne_nlp/networks/graph.py | __author__ = 'max'
import theano.tensor as T
from lasagne.layers import MergeLayer
from lasagne import init
import lasagne.nonlinearities as nonlinearities
from theano.tensor.sort import argsort
__all__ = [
"GraphConvLayer",
]
class GraphConvLayer(MergeLayer):
"""
lasagne_nlp.networks.graph.GraphConvLa... | 6,385 | 43.657343 | 124 | py |
LasagneNLP | LasagneNLP-master/lasagne_nlp/networks/dropout.py | __author__ = 'max'
import theano
from lasagne.random import get_rng
from theano.sandbox.rng_mrg import MRG_RandomStreams as RandomStreams
from lasagne.layers import Layer
__all__ = [
"GaussianDropoutLayer",
]
class GaussianDropoutLayer(Layer):
"""Gaussian Dropout layer
Multiply values by gaussian varia... | 1,635 | 30.461538 | 116 | py |
LasagneNLP | LasagneNLP-master/lasagne_nlp/networks/crf.py | __author__ = 'max'
import theano.tensor as T
from lasagne import init
from lasagne.layers import MergeLayer
class CRFLayer(MergeLayer):
"""
lasagne_nlp.networks.crf.CRFLayer(incoming, num_labels,
mask_input=None, W=init.GlorotUniform(), b=init.Constant(0.), **kwargs)
Parameters
----------
i... | 4,409 | 42.235294 | 117 | py |
LasagneNLP | LasagneNLP-master/lasagne_nlp/networks/__init__.py | __author__ = 'max'
| 19 | 9 | 18 | py |
LasagneNLP | LasagneNLP-master/lasagne_nlp/theano/__init__.py | __author__ = 'max'
| 19 | 9 | 18 | py |
LasagneNLP | LasagneNLP-master/lasagne_nlp/theano/nlinalg.py | from __future__ import print_function
__author__ = 'max'
import numpy
import theano
from theano.tensor import as_tensor_variable
from theano.gof import Op, Apply
from theano.tensor.nlinalg import matrix_inverse
class LogAbsDet(Op):
"""
Computes the logarithm of absolute determinants of a sequence of square... | 1,320 | 24.403846 | 75 | py |
LasagneNLP | LasagneNLP-master/lasagne_nlp/utils/regularization.py | __author__ = 'max'
import theano.tensor as T
import theano.tensor.nlinalg as nlinalg
def dima(x):
return -T.log(nlinalg.Det()(T.dot(x.T, x))) | 148 | 17.625 | 47 | py |
LasagneNLP | LasagneNLP-master/lasagne_nlp/utils/utils.py | __author__ = 'max'
import logging
import sys
import numpy as np
import lasagne
from gensim.models.word2vec import Word2Vec
import gzip
import theano
def get_logger(name, level=logging.INFO, handler=sys.stdout,
formatter='%(asctime)s - %(name)s - %(levelname)s - %(message)s'):
logger = logging.getL... | 6,567 | 38.329341 | 117 | py |
LasagneNLP | LasagneNLP-master/lasagne_nlp/utils/data_processor.py | __author__ = 'max'
import numpy as np
import theano
from alphabet import Alphabet
from lasagne_nlp.utils import utils as utils
root_symbol = "##ROOT##"
root_label = "<ROOT>"
word_end = "##WE##"
MAX_LENGTH = 130
MAX_CHAR_LENGTH = 45
logger = utils.get_logger("LoadData")
def read_conll_sequence_labeling(path, word_a... | 27,450 | 43.0626 | 136 | py |
LasagneNLP | LasagneNLP-master/lasagne_nlp/utils/objectives.py | """
objectives for some loss functions
"""
__author__ = 'max'
import numpy as np
import theano
import theano.tensor as T
import lasagne_nlp.theano.nlinalg as nlinalg
def theano_logsumexp(x, axis=None):
"""
Compute log(sum(exp(x), axis=axis) in a numerically stable
fashion.
Parameters
----------
... | 8,314 | 37.85514 | 119 | py |
LasagneNLP | LasagneNLP-master/lasagne_nlp/utils/alphabet.py | __author__ = 'max'
"""
Alphabet maps objects to integer ids. It provides two way mapping from the index to the objects.
"""
import json
import os
from lasagne_nlp.utils import utils as utils
class Alphabet:
def __init__(self, name, keep_growing=True):
self.__name = name
self.instance2index = {}... | 3,173 | 31.060606 | 116 | py |
LasagneNLP | LasagneNLP-master/lasagne_nlp/utils/__init__.py | __author__ = 'max'
| 19 | 9 | 18 | py |
SSC | SSC-master/main.py | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
python script to train the SSC model
---
Jie Li
[email protected]
Nanjing University of Science and Technology
Aug 25, 2019
"""
from utils.seed import seed_torch
import os
import torch
import argparse
import numpy as np
from tqdm import tqdm
from torch.autograd impor... | 10,137 | 39.552 | 142 | py |
SSC | SSC-master/sscMetrics.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
from sklearn.metrics import accuracy_score, precision_recall_fscore_support
# from sklearn.metrics import precision_score, recall_score
"""
---- Input:
predict:
type, numpy.ndarray
shape, (BS=batch_size, C=class_num, W, H, D), onehot... | 6,687 | 40.283951 | 118 | py |
SSC | SSC-master/test.py | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
python script to evaluate the SSC model
---
Jie Li
[email protected]
Nanjing University of Science and Technology
Aug 25, 2019
"""
import os
import torch
import argparse
import datetime
from dataloaders import make_data_loader
from models import make_model
from main i... | 2,574 | 33.333333 | 120 | py |
SSC | SSC-master/config.py | import numpy as np
import torch
class Path(object):
@staticmethod
def db_root_dir(dataset):
if dataset == 'nyu':
# folder that contains dataset/.
return {'train': '/home/mcheem/data/datasets/NYU_SSC/NYUtrain_npz',
'val': '/home/mcheem/data/datasets/NYU_SSC/NY... | 1,795 | 36.416667 | 93 | py |
SSC | SSC-master/infer_ros.py | #!/usr/bin/env python3
from utils.seed import seed_torch
import os
# Network dependencies
import torch
import argparse
import numpy as np
from torch.autograd import Variable
# ROS dependencies
import rospy
from sensor_msgs.msg import Image
import tf.transformations as tr
import tf
from cv_bridge import CvBridge
# lo... | 6,176 | 35.550296 | 253 | py |
SSC | SSC-master/infer.py | from utils.seed import seed_torch
import os
import torch
import argparse
import numpy as np
from pathlib import Path
import imageio
import glob
from tqdm import tqdm
from torch.autograd import Variable
import datetime
from models import make_model
import config
import VoxelUtils as vu
from utils import utils
parser... | 4,225 | 37.072072 | 237 | py |
SSC | SSC-master/models/PALNet.py | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
PALNet
[email protected]
"""
import torch
import torch.nn as nn
from torch.nn import functional as F
from .projection_layer import Project2Dto3D
# ----------------------------------------------------------------------
# takes the depth and fTSDF as inputs
class SSC_P... | 6,635 | 32.346734 | 95 | py |
SSC | SSC-master/models/DDR.py | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
DDR
[email protected]
"""
import torch
import torch.nn as nn
from torch.nn import functional as F
# ----------------------------------------------------------------------
class BasicDDR2d(nn.Module):
def __init__(self, c, k=3, dilation=1, residual=True):
s... | 5,848 | 36.254777 | 120 | py |
SSC | SSC-master/models/projection_layer.py | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
Project feature tensers of 2D image to 3D space
[email protected]
"""
import torch.nn as nn
from torch_scatter import scatter_max
class Project2Dto3D(nn.Module):
def __init__(self, w=240, h=144, d=240):
super(Project2Dto3D, self).__init__()
self.w ... | 922 | 27.84375 | 89 | py |
SSC | SSC-master/models/AICNet.py | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
AICNet
[email protected]
"""
import torch
import torch.nn as nn
from torch.nn import functional as F
from .projection_layer import Project2Dto3D
from .DDR import BottleneckDDR2d, BottleneckDDR3d, DownsampleBlock3d
class BasicAIC3d(nn.Module):
def __init__(self, ch... | 8,927 | 40.142857 | 124 | py |
SSC | SSC-master/models/GRFNet.py | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
GRFNet
[email protected]
"""
import torch
import torch.nn as nn
from torch.nn import functional as F
from .projection_layer import Project2Dto3D
from .DDR import DDR_ASPP3d
from .DDR import BottleneckDDR2d, BottleneckDDR3d, DownsampleBlock3d
class Conv3dGRUCell(nn.Mod... | 7,381 | 39.119565 | 113 | py |
SSC | SSC-master/models/__init__.py | from .PALNet import SSC_PALNet
from .DDRNet import SSC_RGBD_DDRNet
from .AICNet import SSC_RGBD_AICNet
from .GRFNet import SSC_RGBD_GRFNet
def make_model(modelname, num_classes):
if modelname == 'palnet':
return SSC_PALNet(num_classes)
if modelname == 'ddrnet':
return SSC_RGBD_DDRNet(num_class... | 499 | 25.315789 | 43 | py |
SSC | SSC-master/models/DDRNet.py | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
DDRNet
[email protected]
"""
import torch
import torch.nn as nn
from .projection_layer import Project2Dto3D
from .DDR import DDR_ASPP3d
from .DDR import BottleneckDDR2d, BottleneckDDR3d, DownsampleBlock3d
# DDRNet
# ----------------------------------------------------... | 4,722 | 36.784 | 101 | py |
SSC | SSC-master/voxel_utils/setup.py | import os
from distutils.core import setup, Extension
import numpy as np
os.environ["CC"] = "g++"
os.environ["CXX"] = "g++"
if 'CUDA_PATH' in os.environ:
CUDA_PATH = os.environ['CUDA_PATH']
else:
print("Could not find CUDA_PATH in environment variables. Defaulting to /usr/local/cuda!")
CUDA_PATH = "/usr/loca... | 1,031 | 31.25 | 93 | py |
SSC | SSC-master/voxel_utils/scripts/configure.py | from distutils import sysconfig
print(sysconfig.get_config_var('LDSHARED').replace("gcc", "g++"))
| 98 | 32 | 65 | py |
SSC | SSC-master/dataloaders/dataloader.py | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
Class of pytorch data loader
---
Jie Li
[email protected]
Nanjing University of Science and Technology
Aug 10, 2019
"""
import glob
import imageio
import numpy as np
import numpy.matlib
import torch.utils.data
from pathlib import Path
from torchvision import transforms... | 24,291 | 44.920605 | 180 | py |
SSC | SSC-master/dataloaders/__init__.py |
from .dataloader import NYUDataset
from config import Path
from torch.utils.data import DataLoader
def make_data_loader(args, **kwargs):
if args.dataset:
base_dirs = Path.db_root_dir(args.dataset)
print('Training data:{}'.format(base_dirs['train']))
train_loader = DataLoader(
... | 883 | 28.466667 | 88 | py |
SSC | SSC-master/utils/seed.py |
import numpy as np
import scipy.misc
import os
import random
import torch
def seed_torch(seed=3055):
random.seed(seed)
os.environ['PYTHONHASHSEED'] = str(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
torch.cuda.manual_seed_all(seed) # if you are using mult... | 416 | 18.857143 | 66 | py |
SSC | SSC-master/utils/utils.py | import numpy as np
import config
import VoxelUtils as vu
def compute_tsdf(depth_data, vox_origin, cam_k, cam_pose0, voxel_size=(240,144,240)):
"""
Computes TSDF grid from a depth map at the specified voxel origin using CUDA C++ implementation wrapped
as python module.
"""
# cam_info_CPU, vox_info_... | 11,584 | 43.72973 | 119 | py |
Unilm | Unilm-master/conver_torch_to_tf.py | """
@author: liucong
@contact: [email protected]
@time: 2020/7/27 13:39
"""
from convert_unilm_pytorch_checkpoint_to_original_tf import convert_pytorch_checkpoint_to_tf
from modeling_unilm import UnilmForLM
import os
os.environ['CUDA_DEVICE_ORDER'] = 'PCI_BUS_ID'
os.environ['CUDA_VISIBLE_DEVICES'] = "-1"
def f(... | 626 | 25.125 | 92 | py |
Unilm | Unilm-master/modeling_unilm.py | # coding=utf-8
"""PyTorch UniLM model. """
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import copy
import math
import logging
import numpy as np
import torch
from torch import nn
import torch.nn.functional as F
from torch.nn.modules.loss import _Loss
fr... | 31,656 | 44.095442 | 238 | py |
Unilm | Unilm-master/run_seq2seq.py | # coding=utf-8
import os
import logging
import glob
import math
import json
import argparse
import random
from pathlib import Path
from tqdm import tqdm, trange
import numpy as np
import torch
from torch.utils.data import RandomSampler
from torch.utils.data.distributed import DistributedSampler
import torch.distribute... | 19,869 | 50.343669 | 330 | py |
Unilm | Unilm-master/configuration_unilm.py | # coding=utf-8
""" UniLM model configuration """
from __future__ import absolute_import, division, print_function, unicode_literals
import json
import logging
import sys
from io import open
from transformers.configuration_utils import PretrainedConfig
logger = logging.getLogger(__name__)
UNILM_PRETRAINED_CONFIG_A... | 4,038 | 44.382022 | 116 | py |
Unilm | Unilm-master/decode_seq2seq.py | # coding=utf-8
# The MIT License (MIT)
# Copyright (c) Microsoft Corporation
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# t... | 12,437 | 46.473282 | 225 | py |
Unilm | Unilm-master/convert_unilm_pytorch_checkpoint_to_original_tf.py | """
@author: liucong
@contact: [email protected]
@time: 2020/7/27 13:53
"""
import argparse
import os
import numpy as np
import tensorflow as tf
import torch
from modeling_unilm import UnilmForLM
def convert_pytorch_checkpoint_to_tf(model: UnilmForLM, ckpt_dir: str, model_name: str):
tensors_to_transpose =... | 3,081 | 35.258824 | 118 | py |
Unilm | Unilm-master/__init__.py | """
@author: liucong
@contact: [email protected]
@time: 2020/6/16 15:44
""" | 79 | 15 | 31 | py |
Unilm | Unilm-master/utils_seq2seq.py | # coding=utf-8
from random import randint, shuffle, choice
from random import random as rand
import math
import numpy as np
import torch
import torch.utils.data
def get_random_word(vocab_words):
i = randint(0, len(vocab_words)-1)
return vocab_words[i]
def batch_list_to_batch_tensors(batch):
batch_ten... | 33,772 | 38.134415 | 175 | py |
Unilm | Unilm-master/tokenization_unilm.py | # coding=utf-8
"""Tokenization classes for UniLM."""
from __future__ import absolute_import, division, print_function, unicode_literals
import logging
from transformers.tokenization_bert import BertTokenizer, whitespace_tokenize
logger = logging.getLogger(__name__)
VOCAB_FILES_NAMES = {'vocab_file': 'vocab.txt'}
... | 868 | 22.486486 | 82 | py |
DoTra | DoTra-main/latAEModels.py | #Source code for 'Domain Transformer: Predicting Samples of Unseen, Future Domains' by Johannes Schneider, IJCNN, 2022, https://arxiv.org/abs/2106.06057; Github; https://github.com/JohnTailor/DoTra
#Licence: Use it however you like, but cite the paper :-)
#Models for Cycle-GAN on encoded data
import torch.nn as nn
i... | 2,462 | 31.84 | 198 | py |
DoTra | DoTra-main/main.py | # Source code for 'Domain Transformer: Predicting Samples of Unseen, Future Domains' by Johannes Schneider, IJCNN, 2022, https://arxiv.org/abs/2106.06057; Github; https://github.com/JohnTailor/DoTra
# Licence: Use it however you like, but cite the paper :-)
#Main routine to train models
import sklearn
import torch
... | 7,497 | 48.006536 | 366 | py |
DoTra | DoTra-main/runExp.py | #Source code for 'Domain Transformer: Predicting Samples of Unseen, Future Domains' by Johannes Schneider, IJCNN, 2022, https://arxiv.org/abs/2106.06057; Github; https://github.com/JohnTailor/DoTra
#Licence: Use it however you like, but cite the paper :-)
print("Source code for 'Domain Transformer: Predicting Samples... | 2,956 | 88.606061 | 522 | py |
DoTra | DoTra-main/optCycEncoded.py | #Source code for 'Domain Transformer: Predicting Samples of Unseen, Future Domains' by Johannes Schneider, IJCNN, 2022, https://arxiv.org/abs/2106.06057; Github; https://github.com/JohnTailor/DoTra
#Licence: Use it however you like, but cite the paper :-)
#Based on https://github.com/yunjey/mnist-svhn-transfer/
imp... | 14,096 | 47.947917 | 264 | py |
DoTra | DoTra-main/imgutil.py | #Source code for 'Domain Transformer: Predicting Samples of Unseen, Future Domains' by Johannes Schneider, IJCNN, 2022, https://arxiv.org/abs/2106.06057; Github; https://github.com/JohnTailor/DoTra
#Licence: Use it however you like, but cite the paper :-)
import numpy as np
from scipy import ndimage
def nor(x): retu... | 1,282 | 26.891304 | 198 | py |
DoTra | DoTra-main/doTraModel.py | #Source code for 'Domain Transformer: Predicting Samples of Unseen, Future Domains' by Johannes Schneider, IJCNN, 2022, https://arxiv.org/abs/2106.06057; Github; https://github.com/JohnTailor/DoTra
#Licence: Use it however you like, but cite the paper :-)
import torch.nn as nn
import torch.nn.functional as F
import t... | 5,990 | 41.792857 | 198 | py |
DoTra | DoTra-main/classifierModels.py | #Source code for 'Domain Transformer: Predicting Samples of Unseen, Future Domains' by Johannes Schneider, IJCNN, 2022, https://arxiv.org/abs/2106.06057; Github; https://github.com/JohnTailor/DoTra
#Licence: Use it however you like, but cite the paper :-)
#Classifier models
import numpy as np
import torch
import tor... | 4,359 | 43.948454 | 246 | py |
DoTra | DoTra-main/AEModels.py | #Source code for 'Domain Transformer: Predicting Samples of Unseen, Future Domains' by Johannes Schneider, IJCNN, 2022, https://arxiv.org/abs/2106.06057; Github; https://github.com/JohnTailor/DoTra
#Licence: Use it however you like, but cite the paper :-)
#Autoencoder models and training
import numpy as np
import pi... | 10,633 | 49.398104 | 203 | py |
DoTra | DoTra-main/trainClassifiers.py | #Source code for 'Domain Transformer: Predicting Samples of Unseen, Future Domains' by Johannes Schneider, IJCNN, 2022, https://arxiv.org/abs/2106.06057; Github; https://github.com/JohnTailor/DoTra
#Licence: Use it however you like, but cite the paper :-)
#Training of classifiers (and also DoTra on paired samples)
i... | 11,382 | 45.461224 | 258 | py |
DoTra | DoTra-main/dutils.py | #Source code for 'Domain Transformer: Predicting Samples of Unseen, Future Domains' by Johannes Schneider, IJCNN, 2022, https://arxiv.org/abs/2106.06057; Github; https://github.com/JohnTailor/DoTra
#Licence: Use it however you like, but cite the paper :-)
from scipy import ndimage
from torch.utils.data import Dataset... | 2,472 | 44.796296 | 198 | py |
Disco | Disco-master/Python/plotDiscoR.py | import sys
import h5py as h5
import numpy as np
import matplotlib.pyplot as plt
def loadCheckpoint(filename):
f = h5.File(filename, "r")
piph = f['Data']['Cells'][:,-1][...]
prim = f['Data']['Cells'][:,:-1][...]
index = f['Grid']['Index'][...]
idPhi0 = f['Grid']['Id_phi0'][...]
nphi = f['Grid... | 2,180 | 26.607595 | 79 | py |
OpenFWI | OpenFWI-main/pytorch_ssim.py | # From https://github.com/Po-Hsun-Su/pytorch-ssim/blob/master/pytorch_ssim/__init__.py
import torch
import torch.nn.functional as F
from torch.autograd import Variable
import numpy as np
from math import exp
def gaussian(window_size, sigma):
gauss = torch.Tensor([exp(-(x - window_size//2)**2/float(2*sigma**2)) fo... | 2,722 | 35.306667 | 104 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.