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
xcos
xcos-master/src/model/face_recog.py
from torch.nn import (Linear, Conv2d, BatchNorm1d, BatchNorm2d, PReLU, ReLU, Sigmoid, Dropout, MaxPool2d, AdaptiveAvgPool2d, Sequential, Module, Parameter) # import torch.nn.functional as F import torch from collections import namedtuple import math from .networks import nor...
15,351
37.094293
112
py
xcos
xcos-master/src/model/model.py
import os import sys sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) # noqa import torch import torch.nn as nn import torch.nn.functional as F from .base_model import BaseModel from .networks import MnistGenerator, MnistDiscriminator from .face_recog import Backbone_FC2Conv, Backbone, A...
9,784
39.26749
102
py
xcos
xcos-master/src/model/networks.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn.utils import spectral_norm def normal_init(m, mean, std): if isinstance(m, nn.ConvTranspose2d) or isinstance(m, nn.Conv2d): m.weight.data.normal_(mean, std) m.bias.data.zero_() class MnistGenerator(nn.Module): #...
2,779
38.714286
129
py
xcos
xcos-master/src/model/__init__.py
0
0
0
py
xcos
xcos-master/src/model/xcos_modules.py
import torch import torch.nn as nn import torch.nn.functional as F from .networks import normal_init cos = nn.CosineSimilarity(dim=1, eps=1e-6) def l2normalize(x): return F.normalize(x, p=2, dim=1) class FrobeniusInnerProduct(nn.Module): def __init__(self): super(FrobeniusInnerProduct, self).__in...
10,474
33.916667
94
py
xcos
xcos-master/src/model/metric.py
import os import torch from abc import abstractmethod import tempfile import numpy as np from torchvision import transforms from utils.util import DeNormalize, lib_path, import_given_path from utils.verification import evaluate_accuracy from utils.logging_config import logger class BaseMetric(torch.nn.Module): ...
8,283
35.982143
114
py
tinker
tinker-master/tinker-build/tinker-patch-cli/tool_output/merge_mapping.py
#!/usr/bin/python # coding: utf-8 """ 当工程使用了applymapping之后,会遇到这样的问题 1.类和方法上个版本被keep住了,这个版本不keep 2.类和方法上个版本没有被keep住,这个版本又keep住了 这两个问题会导致proguard报warning,官方建议是手动解决冲突 (http://proguard.sourceforge.net/manual/troubleshooting.html#mappingconflict1) 不解决的话默认以mapping文件为最高优先级处理,这样混淆会带来一些问题 该方案为 简单来说,上个版本的mapping称为mappin...
6,630
38.945783
122
py
tinker
tinker-master/tinker-build/tinker-patch-cli/tool_output/proguard_warning.py
#!/usr/bin/python # coding: utf8 import os import sys def print_usage(): print >>sys.stderr, \ """usage: python proguard_warning.py mapping.txt warning.txt the output mapping file is 'mapping_edit.txt' in the cwd directory """ sys.exit(1) class MappingData: raw_line = "" ...
3,821
34.06422
116
py
Cellibrium
Cellibrium-master/Percolibrium/Percolators/python/anomalysensor.py
import math import cPickle FORGETRATE = 0.5 def update_real_Q(qname, newq): oldav = 0 oldvar = 0.1 [state, oldav, oldvar] = load_special_Q(qname, oldav, oldvar) if state == True: if oldvar == 0: oldvar = 0.5 nextav = w_average(newq, oldav) newvar ...
2,249
23.456522
125
py
Cellibrium
Cellibrium-master/Percolibrium/Percolators/python/load_env_graph.py
#!/usr/bin/env python from lib.neo4j import Neo4j import urllib, urllib2, json, sys, os, time, pprint, time, pyinotify, glob config = {} execfile("conf/config.conf", config) neo4j = Neo4j(config['neo4j_url'], config['neo4j_user'], config['neo4j_pass']) pp = pprint.PrettyPrinter(indent=4) def insert_into_db(): whi...
1,936
23.2125
86
py
Cellibrium
Cellibrium-master/Percolibrium/Percolators/python/mon_env_graph.py
#!/usr/bin/env python from lib.neo4j import Neo4j import urllib, urllib2, json, sys, os, time, pprint, time, pyinotify, glob config = {} execfile("conf/config.conf", config) neo4j = Neo4j(config['neo4j_url'], config['neo4j_user'], config['neo4j_pass']) pp = pprint.PrettyPrinter(indent=4) res = [] mylist = [] class...
1,078
28.972222
109
py
Cellibrium
Cellibrium-master/Percolibrium/Percolators/python/logging.py
######################################################################################################## # # Examples, how to encode logs as semantic graphs # ######################################################################################################## import sys import time import socket from cellibri...
12,224
46.753906
291
py
Cellibrium
Cellibrium-master/Percolibrium/Percolators/python/env_graph.py
#!/usr/bin/env python from lib.neo4j import Neo4j from multiprocessing import Process import urllib, urllib2, json, sys, os, time, pprint, time, pyinotify, glob config = {} execfile("conf/config.conf", config) neo4j = Neo4j(config['neo4j_url'], config['neo4j_user'], config['neo4j_pass']) pp = pprint.PrettyPrinter(i...
3,540
27.328
220
py
Cellibrium
Cellibrium-master/Percolibrium/Percolators/python/test_cellibrium.py
######################################################################################################## # # TEST # ######################################################################################################## import sys import time import os import socket import re from cellibrium import Cellibrium c...
3,839
26.042254
138
py
Cellibrium
Cellibrium-master/Percolibrium/Percolators/python/cellibrium.py
import sys import time import re import socket from datetime import datetime class Cellibrium: GR_CONTAINS = 3 GR_FOLLOWS = 2 # i.e. influenced by GR_EXPRESSES = 4 #represents, etc GR_NEAR = 1 # approx like GR_CONTEXT = 5 # approx like ALL_CONTEXTS = "any" A = { "a...
30,510
41.494429
156
py
Cellibrium
Cellibrium-master/Percolibrium/Percolators/python/hello.py
from flask import Flask app = Flask(__name__) @app.route("/") def hello(): return "Hello world"
102
11.875
24
py
Cellibrium
Cellibrium-master/Percolibrium/Percolators/python/lib/neo4j.py
# /usr/bin/env python import urllib, urllib2, json, sys, shlex, re, os, base64 class Neo4j: def __init__(self, neo4j_url, neo4j_user, neo4j_pass): self.neo4j_user = neo4j_user self.neo4j_pass = neo4j_pass self.neo4j_url = neo4j_url def neo4j_rest_cypher(self, query_data): b64 = base64.b64encode('%s:%s' % ...
3,640
31.508929
102
py
Cellibrium
Cellibrium-master/Percolibrium/Percolators/python/lib/__init__.py
0
0
0
py
PrincipledPruningBNN
PrincipledPruningBNN-main/bayesian-tensorflow/setup.py
# Imports from setuptools import setup, find_packages import pathlib # Get the long description from the README file here = pathlib.Path(__file__).parent.resolve() long_description = (here / "README.md").read_text(encoding="utf-8") # Setup setup( # Basic info name='bayesian-tensorflow', version='1.0.0...
1,000
26.805556
67
py
PrincipledPruningBNN
PrincipledPruningBNN-main/bayesian-tensorflow/src/bayesian_tensorflow/inference.py
# Imports import tensorflow as tf # Local functions from bayesian_tensorflow import losses # Custom training step function, for Bayes-by-Backprop @tf.function def BBB(model, optim, x_batch, y_batch, n_data): """ This function performs gradient descent on a mini-batch of data, when using Bayes-by-Backprop ...
3,759
36.227723
105
py
PrincipledPruningBNN
PrincipledPruningBNN-main/bayesian-tensorflow/src/bayesian_tensorflow/losses.py
# Imports import math from keras import backend as K import tensorflow as tf # Accuracy loss function for regression models, for Bayes-by-Backprop @tf.function def AccLossBBB(y_true, y_pred): """ This function computes the accuracy loss term of the Variational Free Energy (VFE) for the Bayes-by-Backprop ...
1,705
30.592593
100
py
PrincipledPruningBNN
PrincipledPruningBNN-main/bayesian-tensorflow/src/bayesian_tensorflow/activations.py
# Imports import math from keras import backend as K import tensorflow as tf # ReLU function @tf.function def relu_moments(h_mean, h_var): """ This functions computes the first and second (central) moment of a Normal distribution passing through a ReLU function. It takes the mean and variance of...
2,544
28.252874
94
py
PrincipledPruningBNN
PrincipledPruningBNN-main/bayesian-tensorflow/src/bayesian_tensorflow/__init__.py
# Import activations from .activations import * # Import evaluation functions from .evaluation import * # Import layers from .layers import * # Import inference functions from .inference import * # Import losses from .losses import *
237
16
29
py
PrincipledPruningBNN
PrincipledPruningBNN-main/bayesian-tensorflow/src/bayesian_tensorflow/evaluation.py
# Imports import tensorflow as tf # Local functions from bayesian_tensorflow import losses # Custom training step function for Bayes-by-Backprop @tf.function def BBB(model, x_batch, y_batch, n_data): """ This function evaluation the Variational Free Energy (VFE) when using the Bayes-by-Backprop (BBB) in...
1,898
29.142857
103
py
PrincipledPruningBNN
PrincipledPruningBNN-main/bayesian-tensorflow/src/bayesian_tensorflow/layers/bayes_by_backprop.py
# Imports from keras import backend as K from keras import initializers, activations import tensorflow as tf # Dense layer class DenseBBB(tf.keras.layers.Layer): """ Variational fully connected layer (dense), following Bayes-by-Backprop (BBB). It takes the number of units as its input, all other inp...
22,719
41.706767
132
py
PrincipledPruningBNN
PrincipledPruningBNN-main/bayesian-tensorflow/src/bayesian_tensorflow/layers/variance_backpropagation.py
# Imports import math from keras import backend as K from keras import initializers import tensorflow as tf # Local functions from bayesian_tensorflow import activations # Dense layer class DenseVBP(tf.keras.layers.Layer): """ Variational fully connected layer (dense), following Variance Back-Propagation (V...
21,930
41.09405
132
py
PrincipledPruningBNN
PrincipledPruningBNN-main/bayesian-tensorflow/src/bayesian_tensorflow/layers/__init__.py
# Bayes-by-Backprop layers from .bayes_by_backprop import DenseBBB from .bayes_by_backprop import GammaBBB from .bayes_by_backprop import GRUCellBBB # Variational-Back-Propagation layers from .variance_backpropagation import DenseVBP from .variance_backpropagation import GammaVBP from .variance_backpropagation import ...
330
35.777778
48
py
PrincipledPruningBNN
PrincipledPruningBNN-main/experiments/figures/__init__.py
# Imports import numpy as np import matplotlib.pyplot as plt from matplotlib.gridspec import GridSpec # Custom function for plotting losses after training def PlotTrainingLosses(kl_theta, kl_tau, acc_loss, figsize=[12,8]): """ This function plots the VFE loss and its sperates terms. """ # Genera...
1,865
29.590164
67
py
PrincipledPruningBNN
PrincipledPruningBNN-main/experiments/datasets/uci.py
# Imports import pandas as pd # Dataset loader function def load(name, seed=None): """ This function loads the UCI datasets from their respective CSV-files, specified by the `name` input. - Datasets: boston / concrete / energy / kin8nm / naval / powerplant / wine / yacht """ if name ==...
4,357
39.728972
110
py
PrincipledPruningBNN
PrincipledPruningBNN-main/experiments/datasets/toy.py
# Imports import numpy as np import tensorflow as tf import math # Custom function to load toy dataset def load(name): """ This function creates the toy dataset specified by the `name` input. - Datasets: sine / sawtooth / square """ # Create training signal x = np.arange(0, 8, 0.01...
609
23.4
72
py
PrincipledPruningBNN
PrincipledPruningBNN-main/experiments/datasets/__init__.py
# Import all sub-modules from . import toy from . import uci
60
19.333333
24
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/tools/extra/summarize.py
#!/usr/bin/env python """Net summarization tool. This tool summarizes the structure of a net in a concise but comprehensive tabular listing, taking a prototxt file as input. Use this tool to check at a glance that the computation you've specified is the computation you expect. """ from caffe.proto import caffe_pb2 ...
4,880
33.617021
95
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/tools/extra/extract_seconds.py
#!/usr/bin/env python import datetime import os import sys def extract_datetime_from_line(line, year): # Expected format: I0210 13:39:22.381027 25210 solver.cpp:204] Iteration 100, lr = 0.00992565 line = line.strip().split() month = int(line[0][1:3]) day = int(line[0][3:]) timestamp = line[1] p...
2,208
29.260274
97
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/tools/extra/resize_and_crop_images.py
#!/usr/bin/env python from mincepie import mapreducer, launcher import gflags import os import cv2 from PIL import Image # gflags gflags.DEFINE_string('image_lib', 'opencv', 'OpenCV or PIL, case insensitive. The default value is the faster OpenCV.') gflags.DEFINE_string('input_folder', '', ...
4,602
40.845455
99
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/tools/extra/parse_log.py
#!/usr/bin/env python """ Parse training log Evolved from parse_log.sh """ import os import re import extract_seconds import argparse import csv from collections import OrderedDict def parse_log(path_to_log): """Parse log file Returns (train_dict_list, test_dict_list) train_dict_list and test_dict_lis...
7,136
32.824645
86
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/examples/web_demo/app.py
import os import time import cPickle import datetime import logging import flask import werkzeug import optparse import tornado.wsgi import tornado.httpserver import numpy as np import pandas as pd from PIL import Image import cStringIO as StringIO import urllib import exifutil import caffe REPO_DIRNAME = os.path.abs...
7,793
33.184211
105
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/examples/web_demo/exifutil.py
""" This script handles the skimage exif problem. """ from PIL import Image import numpy as np ORIENTATIONS = { # used in apply_orientation 2: (Image.FLIP_LEFT_RIGHT,), 3: (Image.ROTATE_180,), 4: (Image.FLIP_TOP_BOTTOM,), 5: (Image.FLIP_LEFT_RIGHT, Image.ROTATE_90), 6: (Image.ROTATE_270,), 7...
1,046
25.175
51
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/examples/pycaffe/caffenet.py
from __future__ import print_function from caffe import layers as L, params as P, to_proto from caffe.proto import caffe_pb2 # helper function for common structures def conv_relu(bottom, ks, nout, stride=1, pad=0, group=1): conv = L.Convolution(bottom, kernel_size=ks, stride=stride, ...
2,112
36.732143
91
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/examples/pycaffe/tools.py
import numpy as np class SimpleTransformer: """ SimpleTransformer is a simple class for preprocessing and deprocessing images for caffe. """ def __init__(self, mean=[128, 128, 128]): self.mean = np.array(mean, dtype=np.float32) self.scale = 1.0 def set_mean(self, mean): ...
3,457
27.344262
79
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/examples/pycaffe/layers/pascal_multilabel_datalayers.py
# imports import json import time import pickle import scipy.misc import skimage.io import caffe import numpy as np import os.path as osp from xml.dom import minidom from random import shuffle from threading import Thread from PIL import Image from tools import SimpleTransformer class PascalMultilabelDataLayerSync...
6,846
30.552995
78
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/examples/pycaffe/layers/pyloss.py
import caffe import numpy as np class EuclideanLossLayer(caffe.Layer): """ Compute the Euclidean Loss in the same manner as the C++ EuclideanLossLayer to demonstrate the class interface for developing layers in Python. """ def setup(self, bottom, top): # check input pair if len(bo...
1,223
31.210526
79
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/examples/finetune_flickr_style/assemble_data.py
#!/usr/bin/env python """ Form a subset of the Flickr Style data, download images to dirname, and write Caffe ImagesDataLayer training file. """ import os import urllib import hashlib import argparse import numpy as np import pandas as pd from skimage import io import multiprocessing # Flickr returns a special image i...
3,636
35.737374
94
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/src/caffe/test/test_data/generate_sample_data.py
""" Generate data used in the HDF5DataLayer and GradientBasedSolver tests. """ import os import numpy as np import h5py script_dir = os.path.dirname(os.path.abspath(__file__)) # Generate HDF5DataLayer sample_data.h5 num_cols = 8 num_rows = 10 height = 6 width = 5 total_size = num_cols * num_rows * height * width da...
2,104
24.670732
70
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/python/draw_net.py
#!/usr/bin/env python """ Draw a graph of the net architecture. """ from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter from google.protobuf import text_format import caffe import caffe.draw from caffe.proto import caffe_pb2 def parse_args(): """Parse input arguments """ parser = Argument...
1,934
31.79661
81
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/python/detect.py
#!/usr/bin/env python """ detector.py is an out-of-the-box windowed detector callable from the command line. By default it configures and runs the Caffe reference ImageNet model. Note that this model was trained for image classification and not detection, and finetuning for detection can be expected to improve results...
5,734
31.95977
88
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/python/classify.py
#!/usr/bin/env python """ classify.py is an out-of-the-box image classifer callable from the command line. By default it configures and runs the Caffe reference ImageNet model. """ import numpy as np import os import sys import argparse import glob import time import caffe def main(argv): pycaffe_dir = os.path....
4,262
29.669065
88
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/python/train.py
#!/usr/bin/env python """ Trains a model using one or more GPUs. """ from multiprocessing import Process import caffe def train( solver, # solver proto definition snapshot, # solver snapshot to restore gpus, # list of device ids timing=False, # show timing info for compute and com...
3,145
30.148515
85
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/python/caffe/net_spec.py
"""Python net specification. This module provides a way to write nets directly in Python, using a natural, functional style. See examples/pycaffe/caffenet.py for an example. Currently this works as a thin wrapper around the Python protobuf interface, with layers and parameters automatically generated for the "layers"...
8,277
34.835498
88
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/python/caffe/classifier.py
#!/usr/bin/env python """ Classifier is an image classifier specialization of Net. """ import numpy as np import caffe class Classifier(caffe.Net): """ Classifier extends Net for image class prediction by scaling, center cropping, or oversampling. Parameters ---------- image_dims : dimensio...
3,537
34.737374
78
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/python/caffe/coord_map.py
""" Determine spatial relationships between layers to relate their coordinates. Coordinates are mapped from input-to-output (forward), but can be mapped output-to-input (backward) by the inverse mapping too. This helps crop and align feature maps among other uses. """ from __future__ import division import numpy as np...
6,721
35.139785
79
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/python/caffe/detector.py
#!/usr/bin/env python """ Do windowed detection by classifying a number of images/crops at once, optionally using the selective search window proposal method. This implementation follows ideas in Ross Girshick, Jeff Donahue, Trevor Darrell, Jitendra Malik. Rich feature hierarchies for accurate object detection...
8,541
38.364055
80
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/python/caffe/__init__.py
from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver, NCCL, Timer from ._caffe import init_log, log, set_mode_cpu, set_mode_gpu, set_device, Layer, get_solver, layer_type_list, set_random_seed, solver_count, set_solver_count, solver_rank, set_solver_rank, set_mul...
552
60.444444
216
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/python/caffe/pycaffe.py
""" Wrap the internal caffe C++ module (_caffe.so) with a clean, Pythonic interface. """ from collections import OrderedDict try: from itertools import izip_longest except: from itertools import zip_longest as izip_longest import numpy as np from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \...
11,615
32.572254
89
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/python/caffe/draw.py
""" Caffe network visualization: draw the NetParameter protobuffer. .. note:: This requires pydot>=1.0.2, which is not included in requirements.txt since it requires graphviz and other prerequisites outside the scope of the Caffe. """ from caffe.proto import caffe_pb2 """ pydot is not supported under p...
8,789
34.877551
112
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/python/caffe/io.py
import numpy as np import skimage.io from scipy.ndimage import zoom from skimage.transform import resize try: # Python3 will most likely not be able to load protobuf from caffe.proto import caffe_pb2 except: import sys if sys.version_info >= (3, 0): print("Failed to include caffe_pb2, things mi...
12,743
32.1875
110
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/python/caffe/test/test_coord_map.py
import unittest import numpy as np import random import caffe from caffe import layers as L from caffe import params as P from caffe.coord_map import coord_map_from_to, crop def coord_net_spec(ks=3, stride=1, pad=0, pool=2, dstride=2, dpad=0): """ Define net spec for simple conv-pool-deconv pattern common t...
6,894
34.725389
79
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/python/caffe/test/test_python_layer_with_param_str.py
import unittest import tempfile import os import six import caffe class SimpleParamLayer(caffe.Layer): """A layer that just multiplies by the numeric value of its param string""" def setup(self, bottom, top): try: self.value = float(self.param_str) except ValueError: ...
2,031
31.774194
79
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/python/caffe/test/test_io.py
import numpy as np import unittest import caffe class TestBlobProtoToArray(unittest.TestCase): def test_old_format(self): data = np.zeros((10,10)) blob = caffe.proto.caffe_pb2.BlobProto() blob.data.extend(list(data.flatten())) shape = (1,1,10,10) blob.num, blob.channels, b...
1,694
28.736842
65
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/python/caffe/test/test_solver.py
import unittest import tempfile import os import numpy as np import six import caffe from test_net import simple_net_file class TestSolver(unittest.TestCase): def setUp(self): self.num_output = 13 net_f = simple_net_file(self.num_output) f = tempfile.NamedTemporaryFile(mode='w+', delete=F...
2,165
33.380952
76
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/python/caffe/test/test_layer_type_list.py
import unittest import caffe class TestLayerTypeList(unittest.TestCase): def test_standard_types(self): #removing 'Data' from list for type_name in ['Data', 'Convolution', 'InnerProduct']: self.assertIn(type_name, caffe.layer_type_list(), '%s not in layer_type_lis...
338
27.25
65
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/python/caffe/test/test_net.py
import unittest import tempfile import os import numpy as np import six from collections import OrderedDict import caffe def simple_net_file(num_output): """Make a simple net prototxt, based on test_net.cpp, returning the name of the (temporary) file.""" f = tempfile.NamedTemporaryFile(mode='w+', delete...
11,640
28.848718
82
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/python/caffe/test/test_draw.py
import os import unittest from google.protobuf import text_format import caffe.draw from caffe.proto import caffe_pb2 def getFilenames(): """Yields files in the source tree which are Net prototxts.""" result = [] root_dir = os.path.abspath(os.path.join( os.path.dirname(__file__), '..', '..', '.....
1,114
28.342105
79
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/python/caffe/test/test_nccl.py
import sys import unittest import caffe class TestNCCL(unittest.TestCase): def test_newuid(self): """ Test that NCCL uids are of the proper type according to python version """ if caffe.has_nccl(): uid = caffe.NCCL.new_uid() if sys.version_info.maj...
457
21.9
55
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/python/caffe/test/test_net_spec.py
import unittest import tempfile import caffe from caffe import layers as L from caffe import params as P def lenet(batch_size): n = caffe.NetSpec() n.data, n.label = L.DummyData(shape=[dict(dim=[batch_size, 1, 28, 28]), dict(dim=[batch_size, 1, 1, 1])], ...
3,756
40.744444
80
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/python/caffe/test/test_python_layer.py
import unittest import tempfile import os import six import caffe class SimpleLayer(caffe.Layer): """A layer that just multiplies by ten""" def setup(self, bottom, top): pass def reshape(self, bottom, top): top[0].reshape(*bottom[0].data.shape) def forward(self, bottom, top): ...
5,510
31.609467
81
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/scripts/cpp_lint.py
#!/usr/bin/env python # # Copyright (c) 2009 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list...
187,569
37.483792
93
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/scripts/split_caffe_proto.py
#!/usr/bin/env python import mmap import re import os import errno script_path = os.path.dirname(os.path.realpath(__file__)) # a regex to match the parameter definitions in caffe.proto r = re.compile(r'(?://.*\n)*message ([^ ]*) \{\n(?: .*\n|\n)*\}') # create directory to put caffe.proto fragments try: os.mkdir(...
941
25.166667
65
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/scripts/download_model_binary.py
#!/usr/bin/env python import os import sys import time import yaml import hashlib import argparse from six.moves import urllib required_keys = ['caffemodel', 'caffemodel_url', 'sha1'] def reporthook(count, block_size, total_size): """ From http://blog.moleculea.com/2012/10/04/urlretrieve-progres-indicator/ ...
2,531
31.461538
78
py
Stochastic-Quantization
Stochastic-Quantization-master/caffe/scripts/copy_notebook.py
#!/usr/bin/env python """ Takes as arguments: 1. the path to a JSON file (such as an IPython notebook). 2. the path to output file If 'metadata' dict in the JSON file contains 'include_in_docs': true, then copies the file to output file, appending the 'metadata' property as YAML front-matter, adding the field 'categor...
1,089
32.030303
87
py
multi-head-attention-labeller
multi-head-attention-labeller-master/variants.py
from modules import * import collections import numpy import pickle import re import tensorflow as tf class Model(object): """ Implements several variants of the multi-head attention labeller (MHAL). These were mainly experimental, so don't take them as granted. The performances reported are obtained ...
47,419
49.879828
110
py
multi-head-attention-labeller
multi-head-attention-labeller-master/experiment.py
from collections import Counter from collections import OrderedDict from evaluator import Evaluator from model import Model # from second_model import Model # from variants import Model import gc import math import numpy as np import os import pandas as pd import random import sys import time import visualize import wa...
31,116
43.580229
114
py
multi-head-attention-labeller
multi-head-attention-labeller-master/modules.py
from math import ceil import tensorflow as tf def layer_normalization(layer, epsilon=1e-8): """ Implements layer normalization. :param layer: has 2-dimensional, the first dimension is the batch_size :param epsilon: a small number to avoid numerical issues, such as zero division. :return: normalize...
103,822
47.021739
102
py
multi-head-attention-labeller
multi-head-attention-labeller-master/disable_tokens.py
import random random.seed(100) def add_another_column(dataset, extension): """ The original dataset file has multiple columns, the first one being the token and the last one the label. This method builds another file containing these as well as an additional middle column, representing the supervi...
3,741
36.79798
85
py
multi-head-attention-labeller
multi-head-attention-labeller-master/model.py
from math import ceil from modules import cosine_distance_loss, label_smoothing import collections import numpy import pickle import re import tensorflow as tf class Model(object): """ Implements the multi-head attention labeller (MHAL). """ def __init__(self, config, label2id_sent, label2id_tok): ...
45,808
48.846572
118
py
multi-head-attention-labeller
multi-head-attention-labeller-master/conlleval.py
#!/usr/bin/env python # Python version of the evaluation script from CoNLL'00- # Originates from: https://github.com/spyysalo/conlleval.py # Intentional differences: # - accept any space as delimiter by default # - optional file argument (default STDIN) # - option to set boundary (-b argument) # - LaTeX output (-l a...
8,967
30.914591
86
py
multi-head-attention-labeller
multi-head-attention-labeller-master/evaluator.py
from collections import OrderedDict from sklearn.metrics import classification_report import conlleval import numpy as np import time class Evaluator: """ Evaluates the results of a joint text classifier. """ def __init__(self, label2id_sent, label2id_tok, conll03_eval): self.id2label_sent = ...
14,918
46.512739
99
py
multi-head-attention-labeller
multi-head-attention-labeller-master/second_model.py
from modules import label_smoothing import collections import numpy import pickle import re import tensorflow as tf class Model(object): """ Implements the multi-head attention labeller (MHAL) without keys, queries, and values. It only uses a simple, soft attention. """ def __init__(self, con...
41,034
48.026284
105
py
multi-head-attention-labeller
multi-head-attention-labeller-master/visualize.py
import matplotlib as mpl mpl.use("agg") mpl.rcParams['xtick.labelsize'] = 20 mpl.rcParams['ytick.labelsize'] = 20 import matplotlib.pyplot as plt import time from tqdm import tqdm import numpy as np html_header = '<!DOCTYPE html>\n<html>\n<font size="3">\n<head>\n<meta charset="UTF-8">\n<body>\n' html_footer = '</body...
8,269
44.191257
98
py
P-STMO
P-STMO-main/run_3dhp.py
import os import glob import torch import random import logging import numpy as np from tqdm import tqdm import torch.nn as nn import torch.utils.data import torch.optim as optim from common.opt import opts from common.utils import * from common.camera import get_uvd2xyz from common.load_data_3dhp_mae import Fusion fro...
16,320
38.233173
170
py
P-STMO
P-STMO-main/run.py
import os import glob import torch import random import logging import numpy as np from tqdm import tqdm import torch.nn as nn import torch.utils.data import torch.optim as optim from common.opt import opts from common.utils import * from common.camera import get_uvd2xyz from common.load_data_hm36_tds import Fusion fro...
15,226
37.745547
168
py
P-STMO
P-STMO-main/run_in_the_wild.py
import os import glob import torch import random import logging import numpy as np from tqdm import tqdm import torch.nn as nn import torch.utils.data import torch.optim as optim from common.opt import opts from common.utils import * from common.camera import get_uvd2xyz from common.load_data_hm36_tds_in_the_wild impor...
15,554
37.790524
168
py
P-STMO
P-STMO-main/common/load_data_hm36_tds_in_the_wild.py
import torch.utils.data as data import numpy as np from common.utils import deterministic_random from common.camera import world_to_camera, normalize_screen_coordinates from common.generator_tds import ChunkedGenerator class Fusion(data.Dataset): def __init__(self, opt, dataset, root_path, train=True, MAE=False,...
9,334
50.291209
128
py
P-STMO
P-STMO-main/common/h36m_dataset.py
import numpy as np import copy from common.skeleton import Skeleton from common.mocap_dataset import MocapDataset from common.camera import normalize_screen_coordinates h36m_skeleton = Skeleton(parents=[-1, 0, 1, 2, 3, 4, 0, 6, 7, 8, 9, 0, 11, 12, 13, 14, 12, 16, 17, 18, 19, 20, 19, ...
10,701
41.300395
119
py
P-STMO
P-STMO-main/common/visualization.py
# Copyright (c) 2018-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt from matplotlib.animation import FuncAnimation, write...
28,111
39.742029
119
py
P-STMO
P-STMO-main/common/generator_3dhp.py
import numpy as np class ChunkedGenerator: def __init__(self, batch_size, cameras, poses_3d, poses_2d, valid_frame, chunk_length=1, pad=0, causal_shift=0, shuffle=False, random_seed=1234, augment=False, reverse_aug= False,kps_left=None, kps_right=None, joints_lef...
8,837
43.19
120
py
P-STMO
P-STMO-main/common/load_data_3dhp_mae.py
import torch.utils.data as data import numpy as np from common.utils import deterministic_random from common.camera import world_to_camera, normalize_screen_coordinates from common.generator_3dhp import ChunkedGenerator class Fusion(data.Dataset): def __init__(self, opt, root_path, train=True, MAE=False): ...
9,051
45.420513
125
py
P-STMO
P-STMO-main/common/camera.py
import sys import numpy as np import torch def normalize_screen_coordinates(X, w, h): assert X.shape[-1] == 2 return X / w * 2 - [1, h / w] def image_coordinates(X, w, h): assert X.shape[-1] == 2 # Reverse camera frame normalization return (X + [1, h / w]) * w / 2 def world_to_camera(X, R, t): Rt = ...
2,451
25.652174
87
py
P-STMO
P-STMO-main/common/mocap_dataset.py
class MocapDataset: def __init__(self, fps, skeleton): self._skeleton = skeleton self._fps = fps self._data = None self._cameras = None def remove_joints(self, joints_to_remove): kept_joints = self._skeleton.remove_joints(joints_to_remove) for subject in se...
842
22.416667
68
py
P-STMO
P-STMO-main/common/generator_tds.py
import numpy as np class ChunkedGenerator: def __init__(self, batch_size, cameras, poses_3d, poses_2d, chunk_length=1, pad=0, causal_shift=0, shuffle=False, random_seed=1234, augment=False, reverse_aug= False,kps_left=None, kps_right=None, joints_left=None, joint...
7,836
42.06044
120
py
P-STMO
P-STMO-main/common/utils.py
import torch import numpy as np import hashlib from torch.autograd import Variable import os def deterministic_random(min_value, max_value, data): digest = hashlib.sha256(data.encode()).digest() raw_value = int.from_bytes(digest[:4], byteorder='little', signed=False) return int(raw_value / (2 ** 32 - 1...
7,304
31.039474
118
py
P-STMO
P-STMO-main/common/data_to_npz_3dhp_test.py
import os import numpy as np from common.utils_3dhp import * import h5py import scipy.io as scio data_path=r'F:\mpi_inf_3dhp\mpi_inf_3dhp_test_set' cam_set = [0, 1, 2, 4, 5, 6, 7, 8] # joint_set = [8, 6, 15, 16, 17, 10, 11, 12, 24, 25, 26, 19, 20, 21, 5, 4, 7] joint_set = [7, 5, 14, 15, 16, 9, 10, 11, 23, 24, 25, 18...
1,133
20.807692
81
py
P-STMO
P-STMO-main/common/data_to_npz_3dhp.py
import os import numpy as np from common.utils_3dhp import * import scipy.io as scio data_path=r'F:\mpi_inf_3dhp\data' cam_set = [0, 1, 2, 4, 5, 6, 7, 8] # joint_set = [8, 6, 15, 16, 17, 10, 11, 12, 24, 25, 26, 19, 20, 21, 5, 4, 7] joint_set = [7, 5, 14, 15, 16, 9, 10, 11, 23, 24, 25, 18, 19, 20, 4, 3, 6] dic_seq={}...
1,764
25.343284
78
py
P-STMO
P-STMO-main/common/opt.py
import argparse import os import math import time import torch class opts(): def __init__(self): self.parser = argparse.ArgumentParser() def init(self): self.parser.add_argument('--layers', default=3, type=int) self.parser.add_argument('--channel', default=256, type=int) self.p...
5,367
42.290323
94
py
P-STMO
P-STMO-main/common/draw_3d_keypoint_3dhp.py
import matplotlib import matplotlib.pyplot as plt import numpy as np import matplotlib.image as mpimg from mpl_toolkits.mplot3d import Axes3D import scipy.io as scio parent = [16, 15, 1, 2, 3, 1, 5, 6, 14, 8, 9, 14, 11, 12, 14, 14, 1] data = scio.loadmat('../checkpoint/inference_data.mat') joints_right=[2, 3, 4, 8, 9,...
1,455
28.714286
141
py
P-STMO
P-STMO-main/common/utils_3dhp.py
def mpii_get_sequence_info(subject_id, sequence): switcher = { "1 1": [6416,25], "1 2": [12430,50], "2 1": [6502,25], "2 2": [6081,25], "3 1": [12488,50], "3 2": [12283,50], "4 1": [6171,25], "4 2": [6675,25], "5 1": [12820,50], "5 2...
547
20.92
49
py
P-STMO
P-STMO-main/common/skeleton.py
import numpy as np class Skeleton: def __init__(self, parents, joints_left, joints_right): assert len(joints_left) == len(joints_right) self._parents = np.array(parents) self._joints_left = joints_left self._joints_right = joints_right self._compute_metadata() def nu...
2,532
29.518072
73
py
P-STMO
P-STMO-main/common/draw_2d_keypoint_3dhp.py
import matplotlib import matplotlib.pyplot as plt import numpy as np import matplotlib.image as mpimg import scipy.io as scio keypoints = np.load('../dataset/data_test_3dhp.npz',allow_pickle=True) image = mpimg.imread(r'..\3dhp_test\TS6\imageSequence\img_000061.jpg') parents=[1,15,1,2,3,1,5,6,14,8,9,14,11,12,-1,14,15...
1,532
25.894737
93
py
P-STMO
P-STMO-main/common/load_data_hm36_tds.py
import torch.utils.data as data import numpy as np from common.utils import deterministic_random from common.camera import world_to_camera, normalize_screen_coordinates from common.generator_tds import ChunkedGenerator class Fusion(data.Dataset): def __init__(self, opt, dataset, root_path, train=True, MAE=False,...
9,325
50.241758
128
py
P-STMO
P-STMO-main/in_the_wild/generators.py
# Copyright (c) 2018-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # from itertools import zip_longest import numpy as np class ChunkedGenerator: """ Batched data generator, used for tr...
20,264
46.682353
132
py
P-STMO
P-STMO-main/in_the_wild/arguments.py
# Copyright (c) 2018-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import argparse def parse_args(): parser = argparse.ArgumentParser(description='Training script') # General argument...
7,306
69.941748
156
py