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
larq
larq-main/larq/activations_test.py
import numpy as np import pytest import tensorflow as tf import larq as lq from larq.testing_utils import generate_real_values_with_zeros @pytest.mark.parametrize("name", ["hard_tanh", "leaky_tanh"]) def test_serialization(name): fn = tf.keras.activations.get(name) ref_fn = getattr(lq.activations, name) ...
1,259
29
74
py
larq
larq-main/larq/conftest_test.py
import pytest import tensorflow as tf from larq import context def test_eager_and_graph_mode_fixture(eager_and_graph_mode): if eager_and_graph_mode == "eager": assert tf.executing_eagerly() else: assert not tf.executing_eagerly() assert tf.compat.v1.get_default_session() is not None ...
788
23.65625
61
py
larq
larq-main/larq/quantized_variable_test.py
import numpy as np import pytest import tensorflow as tf from numpy.testing import assert_almost_equal, assert_array_equal from packaging import version from tensorflow.python.distribute.values import DistributedVariable from larq import context, testing_utils from larq.quantized_variable import QuantizedVariable from...
14,405
37.31383
94
py
larq
larq-main/larq/snapshots/snap_models_test.py
# -*- coding: utf-8 -*- # snapshottest: v1 - https://goo.gl/zC4yUc from __future__ import unicode_literals from snapshottest import Snapshot snapshots = Snapshot() snapshots['test_functional_model_summary 2.4+'] = '''+toy_model stats-----------------------------------------------------------------------------------...
8,529
65.640625
165
py
larq
larq-main/larq/snapshots/snap_quantized_variable_test.py
# -*- coding: utf-8 -*- # snapshottest: v1 - https://goo.gl/zC4yUc from __future__ import unicode_literals from snapshottest import Snapshot snapshots = Snapshot() snapshots['test_repr[eager] 1'] = "<QuantizedVariable 'x:0' shape=() dtype=float32 quantizer=<lambda> numpy=0.0>" snapshots['test_repr[eager] 2'] = "<Qu...
814
39.75
114
py
larq
larq-main/larq/snapshots/__init__.py
0
0
0
py
DAC2018
DAC2018-master/main.py
## This program is for DAC HDC contest ###### ## 2017/11/22 ## xxu8@nd.edu ## University of Notre Dame import procfunc import math import numpy as np import time import sys sys.path.append("./build/lib.linux-aarch64-2.7") import mypack #### !!!! you can import any package needed for your program ###### if __name__ ==...
2,960
47.540984
150
py
DAC2018
DAC2018-master/setup.py
from distutils.core import setup, Extension module = Extension('mypack',extra_compile_args=['-std=c++11'], include_dirs=['/usr/local/cuda/include'], sources = ['Detector.cpp'],extra_objects = ['./plugin.o', './kernel.o'], extra_link_args=['-lnvinfer', '-lnvcaffe_parser', '-lcudnn']) setup(name = 'mypack', vers...
388
54.571429
142
py
DAC2018
DAC2018-master/sender_1_client.py
## this is for GPU demo with only one FPGA and one computer for computer for display ## xxu8@nd.edu import socket import threading import struct import time import cv2 import numpy import xml.etree.ElementTree as ET NofClients = 1 class Senders_Carame_Object: def __init__(self,addr_ports=[("19...
3,833
35.865385
95
py
DAC2018
DAC2018-master/val_sample.py
import numpy as np import sys import os import xml.etree.ElementTree as ET import cv2 class bbox(): def __init__(self, xmin, ymin, xmax, ymax): self.xmin = xmin self.ymin = ymin self.xmax = xmax self.ymax = ymax self.width = ymax - ymin self.height = xmax - xmin ...
2,744
30.193182
86
py
DAC2018
DAC2018-master/demo.py
import socket import cv2 import threading import struct import sys sys.path.append("./build/lib.linux-aarch64-2.7") import mypack import procfunc import math import numpy as np import time mypack.netInit() if __name__ == "__main__": teamName = 'ICT-CAS' DAC = './' [imgDir, resultDir, timeDir, xmlDi...
1,237
33.388889
134
py
DAC2018
DAC2018-master/procfunc.py
import os import cv2 import time import numpy as np import xml.dom.minidom import random import sys sys.path.append("./build/lib.linux-aarch64-2.7") import mypack imageSize = (360, 640, 3) ##must be called to creat default directory def setupDir(homeFolder, teamName): imgDir = homeFolder + '/images' resultDi...
5,024
32.278146
153
py
DAC2018
DAC2018-master/display.py
import socket import cv2 import threading import struct import numpy import sys sys.path.append("./build/lib.linux-aarch64-2.7") import mypack mypack.netInit() ###### change your team name here teamName = "teamName" windowName = "DAC HDC contest team:"+teamName class process_display_Object: def __init...
3,619
44.822785
156
py
MAMS-for-ABSA
MAMS-for-ABSA-master/test.py
import yaml import os from train.test import test config = yaml.safe_load(open('config.yml')) mode = config['mode'] os.environ["CUDA_VISIBLE_DEVICES"] = str(config['aspect_' + mode + '_model'][config['aspect_' + mode + '_model']['type']]['gpu']) test(config)
259
31.5
129
py
MAMS-for-ABSA
MAMS-for-ABSA-master/train.py
import yaml import os from train.train import train config = yaml.safe_load(open('config.yml')) mode = config['mode'] os.environ["CUDA_VISIBLE_DEVICES"] = str(config['aspect_' + mode + '_model'][config['aspect_' + mode + '_model']['type']]['gpu']) train(config)
262
31.875
129
py
MAMS-for-ABSA
MAMS-for-ABSA-master/preprocess.py
import yaml from data_process.data_process import data_process config = yaml.safe_load(open('config.yml')) data_process(config)
129
20.666667
50
py
MAMS-for-ABSA
MAMS-for-ABSA-master/src/aspect_category_model/capsnet.py
import torch from torch import nn import torch.nn.functional as F from torch.nn import init from src.module.utils.constants import PAD_INDEX, INF from src.module.utils.sentence_clip import sentence_clip from src.module.attention.dot_attention import DotAttention from src.module.attention.scaled_dot_attention import Sca...
4,384
45.648936
119
py
MAMS-for-ABSA
MAMS-for-ABSA-master/src/aspect_category_model/recurrent_capsnet.py
import torch from torch import nn import torch.nn.functional as F from src.aspect_category_model.capsnet import CapsuleNetwork class RecurrentCapsuleNetwork(CapsuleNetwork): def __init__(self, embedding, aspect_embedding, num_layers, bidirectional, capsule_size, dropout, num_categories): super(RecurrentCa...
1,597
41.052632
118
py
MAMS-for-ABSA
MAMS-for-ABSA-master/src/aspect_category_model/bert_capsnet.py
import torch from torch import nn import torch.nn.functional as F from torch.nn import init from src.module.utils.constants import PAD_INDEX, INF from src.module.utils.sentence_clip import sentence_clip from src.module.attention.dot_attention import DotAttention from src.module.attention.scaled_dot_attention import Sca...
4,772
48.206186
119
py
MAMS-for-ABSA
MAMS-for-ABSA-master/src/aspect_term_model/capsnet.py
import torch from torch import nn import torch.nn.functional as F from torch.nn import init from src.module.utils.constants import PAD_INDEX, INF from src.module.utils.sentence_clip import sentence_clip from src.module.attention.dot_attention import DotAttention from src.module.attention.scaled_dot_attention import Sca...
4,714
46.15
119
py
MAMS-for-ABSA
MAMS-for-ABSA-master/src/aspect_term_model/recurrent_capsnet.py
import torch from torch import nn import torch.nn.functional as F from src.aspect_term_model.capsnet import CapsuleNetwork class RecurrentCapsuleNetwork(CapsuleNetwork): def __init__(self, embedding, num_layers, bidirectional, capsule_size, dropout, num_categories): super(RecurrentCapsuleNetwork, self).__...
1,528
40.324324
100
py
MAMS-for-ABSA
MAMS-for-ABSA-master/src/aspect_term_model/bert_capsnet.py
import torch from torch import nn import torch.nn.functional as F from torch.nn import init from src.module.utils.constants import PAD_INDEX, INF from src.module.utils.sentence_clip import sentence_clip from src.module.attention.dot_attention import DotAttention from src.module.attention.scaled_dot_attention import Sca...
4,780
47.785714
119
py
MAMS-for-ABSA
MAMS-for-ABSA-master/src/module/attention/concat_attention.py
import torch from torch import nn from torch.nn import init from src.module.attention.attention import Attention class ConcatAttention(Attention): def __init__(self, query_size, key_size, dropout=0): super(ConcatAttention, self).__init__(dropout) self.query_weights = nn.Parameter(torch.Tensor(quer...
1,007
41
101
py
MAMS-for-ABSA
MAMS-for-ABSA-master/src/module/attention/bilinear_attention.py
import torch from torch import nn from torch.nn import init from src.module.attention.attention import Attention class BilinearAttention(Attention): def __init__(self, query_size, key_size, dropout=0): super(BilinearAttention, self).__init__(dropout) self.weights = nn.Parameter(torch.FloatTensor(q...
659
33.736842
76
py
MAMS-for-ABSA
MAMS-for-ABSA-master/src/module/attention/tanh_bilinear_attention.py
import torch from torch import nn from torch.nn import init from src.module.attention.attention import Attention class TanhBilinearAttention(Attention): def __init__(self, query_size, key_size, dropout=0): super(TanhBilinearAttention, self).__init__(dropout) self.weights = nn.Parameter(torch.Float...
740
36.05
94
py
MAMS-for-ABSA
MAMS-for-ABSA-master/src/module/attention/tanh_concat_attention.py
import torch from torch import nn from torch.nn import init from src.module.attention.attention import Attention class TanhConcatAttention(Attention): def __init__(self, query_size, key_size, dropout=0): super(TanhConcatAttention, self).__init__(dropout) self.query_weights = nn.Parameter(torch.Ten...
1,049
41
101
py
MAMS-for-ABSA
MAMS-for-ABSA-master/src/module/attention/multi_head_attention.py
from torch import nn from torch.nn import init import math class MultiHeadAttention(nn.Module): def __init__(self, attention, num_heads, hidden_size, key_size='default', value_size='default', out_size='default'): key_size = hidden_size // num_heads if key_size == 'default' else key_size value_size...
3,451
55.590164
120
py
MAMS-for-ABSA
MAMS-for-ABSA-master/src/module/attention/dot_attention.py
from src.module.attention.attention import Attention class DotAttention(Attention): def __init__(self, dropout=0): super(DotAttention, self).__init__(dropout) def _score(self, query, key): """ query: FloatTensor (batch_size, num_queries, query_size) key: FloatTensor (batch_siz...
448
31.071429
64
py
MAMS-for-ABSA
MAMS-for-ABSA-master/src/module/attention/scaled_dot_attention.py
from src.module.attention.attention import Attention import math class ScaledDotAttention(Attention): def __init__(self, dropout=0): super(ScaledDotAttention, self).__init__(dropout) def _score(self, query, key): """ query: FloatTensor (batch_size, num_queries, query_size) key...
499
32.333333
75
py
MAMS-for-ABSA
MAMS-for-ABSA-master/src/module/attention/attention.py
from torch import nn import torch.nn.functional as F from src.module.utils import constants class Attention(nn.Module): """ The base class of attention. """ def __init__(self, dropout): super(Attention, self).__init__() self.dropout = dropout def forward(self, query, key, value, m...
2,355
37
104
py
MAMS-for-ABSA
MAMS-for-ABSA-master/src/module/attention/mlp_attention.py
import torch from torch import nn from torch.nn import init from src.module.attention.attention import Attention class MlpAttention(Attention): def __init__(self, query_size, key_size, out_size=100, dropout=0): super(MlpAttention, self).__init__(dropout) self.query_projection = nn.Linear(query_siz...
1,092
44.541667
112
py
MAMS-for-ABSA
MAMS-for-ABSA-master/src/module/attention/no_query_attention.py
import torch from torch import nn from torch.nn import init class NoQueryAttention(nn.Module): def __init__(self, query_size, attention): super(NoQueryAttention, self).__init__() self.query_size = query_size self.query = nn.Parameter(torch.Tensor(1, query_size)) init.xavier_uniform...
566
32.352941
62
py
MAMS-for-ABSA
MAMS-for-ABSA-master/src/module/utils/squash.py
import torch def squash(x, dim=-1): squared = torch.sum(x * x, dim=dim, keepdim=True) scale = torch.sqrt(squared) / (1.0 + squared) return scale * x
161
26
53
py
MAMS-for-ABSA
MAMS-for-ABSA-master/src/module/utils/constants.py
PAD = '<pad>' UNK = '<unk>' ASPECT = '<aspect>' PAD_INDEX = 0 UNK_INDEX = 1 ASPECT_INDEX = 2 INF = 1e9
104
10.666667
19
py
MAMS-for-ABSA
MAMS-for-ABSA-master/src/module/utils/loss.py
import torch from torch import nn import torch.nn.functional as F class CapsuleLoss(nn.Module): def __init__(self, smooth=0.1, lamda=0.6): super(CapsuleLoss, self).__init__() self.smooth = smooth self.lamda = lamda def forward(self, input, target): one_hot = torch.zeros_like(i...
2,309
38.152542
96
py
MAMS-for-ABSA
MAMS-for-ABSA-master/src/module/utils/sentence_clip.py
from src.module.utils.constants import PAD_INDEX def sentence_clip(sentence): mask = (sentence != PAD_INDEX) sentence_lens = mask.long().sum(dim=1, keepdim=False) max_len = sentence_lens.max().item() return sentence[:, :max_len]
245
34.142857
57
py
MAMS-for-ABSA
MAMS-for-ABSA-master/train/test.py
import torch import os from train import make_aspect_term_model, make_aspect_category_model from train.make_data import make_term_test_data, make_category_test_data from train.eval import eval def test(config): mode = config['mode'] if mode == 'term': model = make_aspect_term_model.make_model(config) ...
819
38.047619
118
py
MAMS-for-ABSA
MAMS-for-ABSA-master/train/make_aspect_term_model.py
import torch from torch import nn import numpy as np import os import yaml from pytorch_pretrained_bert import BertModel from src.aspect_term_model.recurrent_capsnet import RecurrentCapsuleNetwork from src.aspect_term_model.bert_capsnet import BertCapsuleNetwork def make_model(config): model_type = config['aspect_...
2,462
38.725806
83
py
MAMS-for-ABSA
MAMS-for-ABSA-master/train/make_data.py
import os from torch.utils.data import DataLoader from data_process.dataset import ABSADataset input_list = { 'recurrent_capsnet': ['context', 'aspect'], 'bert_capsnet': ['bert_token', 'bert_segment'] } def make_term_data(config): base_path = config['base_path'] train_path = os.path.join(base_path, 'p...
3,771
34.252336
93
py
MAMS-for-ABSA
MAMS-for-ABSA-master/train/make_optimizer.py
from torch import optim import adabound def make_optimizer(config, model): mode = config['mode'] config = config['aspect_' + mode + '_model'][config['aspect_' + mode + '_model']['type']] lr = config['learning_rate'] weight_decay = config['weight_decay'] opt = { 'sgd': optim.SGD, 'ad...
831
35.173913
127
py
MAMS-for-ABSA
MAMS-for-ABSA-master/train/eval.py
import torch def eval(model, data_loader, criterion=None): total_samples = 0 correct_samples = 0 total_loss = 0 model.eval() with torch.no_grad(): for data in data_loader: input0, input1, label = data input0, input1, label = input0.cuda(), input1.cuda(), label.cuda()...
829
35.086957
81
py
MAMS-for-ABSA
MAMS-for-ABSA-master/train/__init__.py
0
0
0
py
MAMS-for-ABSA
MAMS-for-ABSA-master/train/make_aspect_category_model.py
import torch from torch import nn import numpy as np import os import yaml from pytorch_pretrained_bert import BertModel from src.aspect_category_model.recurrent_capsnet import RecurrentCapsuleNetwork from src.aspect_category_model.bert_capsnet import BertCapsuleNetwork def make_model(config): model_type = config[...
2,631
40.125
89
py
MAMS-for-ABSA
MAMS-for-ABSA-master/train/train.py
import torch from torch import nn from torch import optim from train import make_aspect_term_model, make_aspect_category_model from train.make_data import make_term_data, make_category_data from train.make_optimizer import make_optimizer from train.eval import eval import os import time import pickle from src.module.ut...
3,271
42.052632
108
py
MAMS-for-ABSA
MAMS-for-ABSA-master/data_process/data_process.py
import os import numpy as np import pickle import yaml from data_process.utils import * def data_process(config): mode = config['mode'] assert mode in ('term', 'category') base_path = config['base_path'] raw_train_path = os.path.join(base_path, 'raw/train.xml') raw_val_path = os.path.join(base_path...
3,169
53.655172
122
py
MAMS-for-ABSA
MAMS-for-ABSA-master/data_process/utils.py
import os import numpy as np import random from xml.etree.ElementTree import parse from pytorch_pretrained_bert import BertModel, BertTokenizer from data_process.vocab import Vocab from src.module.utils.constants import UNK, PAD_INDEX, ASPECT_INDEX import spacy import re import json url = re.compile('(<url>.*</url>)')...
10,092
36.520446
132
py
MAMS-for-ABSA
MAMS-for-ABSA-master/data_process/dataset.py
import torch from torch.utils.data import Dataset import numpy as np class ABSADataset(Dataset): def __init__(self, path, input_list): super(ABSADataset, self).__init__() data = np.load(path) self.data = {} for key, value in data.items(): self.data[key] = torch.tensor(v...
702
28.291667
56
py
MAMS-for-ABSA
MAMS-for-ABSA-master/data_process/vocab.py
import operator from src.module.utils.constants import PAD, UNK, ASPECT class Vocab(object): def __init__(self): self._count_dict = dict() self._predefined_list = [PAD, UNK, ASPECT] def add(self, word): if word in self._count_dict: self._count_dict[word] += 1 else:...
1,296
32.25641
97
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
OpenFWI
OpenFWI-main/test.py
# © 2022. Triad National Security, LLC. All rights reserved. # This program was produced under U.S. Government contract 89233218CNA000001 for Los Alamos # National Laboratory (LANL), which is operated by Triad National Security, LLC for the U.S. # Department of Energy/National Nuclear Security Administration. All ri...
10,383
42.814346
156
py
OpenFWI
OpenFWI-main/gan_train.py
# © 2022. Triad National Security, LLC. All rights reserved. # This program was produced under U.S. Government contract 89233218CNA000001 for Los Alamos # National Laboratory (LANL), which is operated by Triad National Security, LLC for the U.S. # Department of Energy/National Nuclear Security Administration. All ri...
16,662
43.553476
128
py
OpenFWI
OpenFWI-main/network.py
# © 2022. Triad National Security, LLC. All rights reserved. # This program was produced under U.S. Government contract 89233218CNA000001 for Los Alamos # National Laboratory (LANL), which is operated by Triad National Security, LLC for the U.S. # Department of Energy/National Nuclear Security Administration. All ri...
14,861
45.15528
167
py
OpenFWI
OpenFWI-main/vis.py
import os import torch import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import numpy as np from matplotlib.colors import ListedColormap # Load colormap for velocity map visualization rainbow_cmap = ListedColormap(np.load('rainbow256.npy')) def plot_velocity(output, target, path, vmin=None, vmax...
4,324
38.318182
89
py
OpenFWI
OpenFWI-main/utils.py
# © 2022. Triad National Security, LLC. All rights reserved. # This program was produced under U.S. Government contract 89233218CNA000001 for Los Alamos # National Laboratory (LANL), which is operated by Triad National Security, LLC for the U.S. # Department of Energy/National Nuclear Security Administration. All ri...
17,006
34.804211
105
py
OpenFWI
OpenFWI-main/dataset.py
# © 2022. Triad National Security, LLC. All rights reserved. # This program was produced under U.S. Government contract 89233218CNA000001 for Los Alamos # National Laboratory (LANL), which is operated by Triad National Security, LLC for the U.S. # Department of Energy/National Nuclear Security Administration. All ri...
3,920
37.441176
129
py
OpenFWI
OpenFWI-main/scheduler.py
# © 2022. Triad National Security, LLC. All rights reserved. # This program was produced under U.S. Government contract 89233218CNA000001 for Los Alamos # National Laboratory (LANL), which is operated by Triad National Security, LLC for the U.S. # Department of Energy/National Nuclear Security Administration. All ri...
2,380
35.075758
105
py
OpenFWI
OpenFWI-main/train.py
# © 2022. Triad National Security, LLC. All rights reserved. # This program was produced under U.S. Government contract 89233218CNA000001 for Los Alamos # National Laboratory (LANL), which is operated by Triad National Security, LLC for the U.S. # Department of Energy/National Nuclear Security Administration. All ri...
14,469
41.558824
122
py
OpenFWI
OpenFWI-main/transforms.py
# © 2022. Triad National Security, LLC. All rights reserved. # This program was produced under U.S. Government contract 89233218CNA000001 for Los Alamos # National Laboratory (LANL), which is operated by Triad National Security, LLC for the U.S. # Department of Energy/National Nuclear Security Administration. All ri...
8,236
29.394834
105
py
Desbordante-web-app
Desbordante-web-app/python-consumer/consumer.py
import time import sys import json import logging import signal from enum import Enum import confluent_kafka import docker import config from error_handlers import update_internal_server_error from error_handlers import update_resource_limit_error docker_client = docker.from_env() docker_api_client = docker.APIClient...
5,672
30.516667
77
py
Desbordante-web-app
Desbordante-web-app/python-consumer/error_handlers.py
import config import psycopg def update_error_status(taskID, errorType, error): # errorType : INTERNAL SERVER ERROR | RESOURCE LIMIT IS REACHED with psycopg.connect(f"dbname={config.POSTGRES_DBNAME} \ user={config.POSTGRES_USER} password={config.POSTGRES_PASSWORD} \ host={config.POSTGRES_HOST} port={c...
958
35.884615
70
py
Desbordante-web-app
Desbordante-web-app/python-consumer/config.py
import os TIMELIMIT = int(os.getenv('TIMELIMIT')) MAX_RAM = int(os.getenv('MAX_RAM')) KAFKA_ADDR = os.getenv('KAFKA_HOST') + ':' + os.getenv('KAFKA_PORT') MAX_ACTIVE_TASKS = int(os.getenv('MAX_ACTIVE_TASKS')) DOCKER_NETWORK = os.getenv('DOCKER_NETWORK') POSTGRES_HOST = os.getenv('POSTGRES_HOST') POSTGRES_PORT = os.get...
537
37.428571
68
py
clFFT
clFFT-master/src/scripts/perf/plotPerformance.py
# ######################################################################## # Copyright 2013 Advanced Micro Devices, Inc. # # 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.apach...
12,413
36.504532
192
py
clFFT
clFFT-master/src/scripts/perf/errorHandler.py
# ######################################################################## # Copyright 2013 Advanced Micro Devices, Inc. # # 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.apach...
2,824
39.942029
100
py
clFFT
clFFT-master/src/scripts/perf/measurePerformance.py
# ######################################################################## # Copyright 2013 Advanced Micro Devices, Inc. # # 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.apach...
31,972
39.116688
435
py
clFFT
clFFT-master/src/scripts/perf/fftPerformanceTesting.py
# ######################################################################## # Copyright 2013 Advanced Micro Devices, Inc. # # 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.apach...
11,307
35.714286
339
py
clFFT
clFFT-master/src/scripts/perf/performanceUtility.py
# ######################################################################## # Copyright 2013 Advanced Micro Devices, Inc. # # 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.apach...
3,044
30.391753
89
py
snowboy
snowboy-master/setup.py
import os import sys from setuptools import setup, find_packages from distutils.command.build import build from distutils.dir_util import copy_tree from subprocess import call py_dir = 'Python' if sys.version_info[0] < 3 else 'Python3' class SnowboyBuild(build): def run(self): cmd = ['make'] sw...
1,814
28.274194
69
py
snowboy
snowboy-master/examples/REST_API/training_service.py
#! /usr/bin/evn python import sys import base64 import requests def get_wave(fname): with open(fname) as infile: return base64.b64encode(infile.read()) endpoint = "https://snowboy.kitt.ai/api/v1/train/" ############# MODIFY THE FOLLOWING ############# token = "" hotword_name = "???" language = "en" ag...
1,276
23.09434
87
py
snowboy
snowboy-master/examples/Python/snowboythreaded.py
import snowboydecoder import threading import Queue class ThreadedDetector(threading.Thread): """ Wrapper class around detectors to run them in a separate thread and provide methods to pause, resume, and modify detection """ def __init__(self, models, **kwargs): """ Initialize Det...
3,554
35.649485
110
py
snowboy
snowboy-master/examples/Python/demo4.py
import snowboydecoder import sys import signal import speech_recognition as sr import os """ This demo file shows you how to use the new_message_callback to interact with the recorded audio after a keyword is spoken. It uses the speech recognition library in order to convert the recorded audio into text. Information ...
2,066
25.844156
106
py
snowboy
snowboy-master/examples/Python/snowboydecoder_arecord.py
#!/usr/bin/env python import collections import snowboydetect import time import wave import os import logging import subprocess import threading logging.basicConfig() logger = logging.getLogger("snowboy") logger.setLevel(logging.INFO) TOP_DIR = os.path.dirname(os.path.abspath(__file__)) RESOURCE_FILE = os.path.join...
6,573
35.120879
82
py
snowboy
snowboy-master/examples/Python/demo.py
import snowboydecoder import sys import signal interrupted = False def signal_handler(signal, frame): global interrupted interrupted = True def interrupt_callback(): global interrupted return interrupted if len(sys.argv) == 1: print("Error: need to specify model name") print("Usage: python...
757
20.055556
65
py
snowboy
snowboy-master/examples/Python/demo_arecord.py
import snowboydecoder_arecord import sys import signal interrupted = False def signal_handler(signal, frame): global interrupted interrupted = True def interrupt_callback(): global interrupted return interrupted if len(sys.argv) == 1: print("Error: need to specify model name") print("Usage...
781
20.722222
73
py
snowboy
snowboy-master/examples/Python/snowboydetect.py
../../swig/Python/snowboydetect.py
34
34
34
py
snowboy
snowboy-master/examples/Python/__init__.py
0
0
0
py
snowboy
snowboy-master/examples/Python/snowboydecoder.py
#!/usr/bin/env python import collections import pyaudio import snowboydetect import time import wave import os import logging from ctypes import * from contextlib import contextmanager logging.basicConfig() logger = logging.getLogger("snowboy") logger.setLevel(logging.INFO) TOP_DIR = os.path.dirname(os.path.abspath(_...
10,392
37.069597
82
py
snowboy
snowboy-master/examples/Python/demo2.py
import snowboydecoder import sys import signal # Demo code for listening to two hotwords at the same time interrupted = False def signal_handler(signal, frame): global interrupted interrupted = True def interrupt_callback(): global interrupted return interrupted if len(sys.argv) != 3: print("...
1,075
24.619048
80
py
snowboy
snowboy-master/examples/Python/demo_threaded.py
import snowboythreaded import sys import signal import time stop_program = False # This a demo that shows running Snowboy in another thread def signal_handler(signal, frame): global stop_program stop_program = True if len(sys.argv) == 1: print("Error: need to specify model name") print("Usage: pyt...
1,203
24.083333
76
py
snowboy
snowboy-master/examples/Python/demo3.py
import snowboydecoder import sys import wave # Demo code for detecting hotword in a .wav file # Example Usage: # $ python demo3.py resources/snowboy.wav resources/models/snowboy.umdl # Should print: # Hotword Detected! # # $ python demo3.py resources/ding.wav resources/models/snowboy.umdl # Should print: # Hotword...
1,113
26.170732
98
py
snowboy
snowboy-master/examples/Python3/demo4.py
import snowboydecoder import sys import signal import speech_recognition as sr import os """ This demo file shows you how to use the new_message_callback to interact with the recorded audio after a keyword is spoken. It uses the speech recognition library in order to convert the recorded audio into text. Information ...
2,060
26.118421
106
py
snowboy
snowboy-master/examples/Python3/demo.py
import snowboydecoder import sys import signal interrupted = False def signal_handler(signal, frame): global interrupted interrupted = True def interrupt_callback(): global interrupted return interrupted if len(sys.argv) == 1: print("Error: need to specify model name") print("Usage: python...
757
20.055556
65
py
snowboy
snowboy-master/examples/Python3/snowboydetect.py
../../swig/Python3/snowboydetect.py
35
35
35
py
snowboy
snowboy-master/examples/Python3/snowboydecoder.py
#!/usr/bin/env python import collections import pyaudio from . import snowboydetect import time import wave import os import logging from ctypes import * from contextlib import contextmanager logging.basicConfig() logger = logging.getLogger("snowboy") logger.setLevel(logging.INFO) TOP_DIR = os.path.dirname(os.path.ab...
10,475
36.683453
82
py
snowboy
snowboy-master/examples/Python3/demo2.py
import snowboydecoder import sys import signal # Demo code for listening to two hotwords at the same time interrupted = False def signal_handler(signal, frame): global interrupted interrupted = True def interrupt_callback(): global interrupted return interrupted if len(sys.argv) != 3: print("...
1,075
24.619048
80
py
snowboy
snowboy-master/examples/Python3/demo3.py
import snowboydecoder import sys import wave # Demo code for detecting hotword in a .wav file # Example Usage: # $ python demo3.py resources/snowboy.wav resources/models/snowboy.umdl # Should print: # Hotword Detected! # # $ python demo3.py resources/ding.wav resources/models/snowboy.umdl # Should print: # Hotword...
1,113
26.170732
98
py
mlj19-iggp
mlj19-iggp-master/specialised_ilasp.py
import asp import config as cfg import subprocess import re import os import glob import common import prolog import json class SPECIALISED_ILASP: ilasp='./GGP_ILASP' name='specialised_ilasp' def __init__(self): pass def parse_train(self,datafile,outpath,game,target): for (bk,modes,e...
5,853
33.233918
119
py
mlj19-iggp
mlj19-iggp-master/asp.py
import re def fill_in_fns(arg_list, func_decs, type_decs): mds = [{"name": "", "body": ""}] for arg in arg_list: new_mds = [] if any(td["type"] == arg for td in type_decs): for md in mds: new_mds.append({"name": md["name"], "body": (md["body"] + ", +" + arg)}) ...
8,030
42.646739
166
py
mlj19-iggp
mlj19-iggp-master/aleph.py
import common import prolog import config as cfg from os.path import isfile class Aleph: name='aleph' aleph_path='aleph/aleph' aleph_runner='aleph/runner' def __init__(self): pass def parse_train(self,datafile,outpath,game,target): for (subtarget,bk,pos,neg) in common.parse_target...
1,761
36.489362
110
py
mlj19-iggp
mlj19-iggp-master/ilasp.py
import asp import config as cfg import subprocess import re class ILASP: ilasp='' xhail='xhail/xhail_mod.jar' name='ilasp' clasp='xhail/clasp-3.1.0-x86_64-linux' gringo='xhail/gringo3-linux' def __init__(self): pass def parse_train(self,datafile,outpath,game,target): for ...
7,805
43.605714
198
py
mlj19-iggp
mlj19-iggp-master/config.py
map_size=8 # learning_timeout=600 # 10 minutes # learning_timeout=60 learning_timeout=1800
91
17.4
35
py
mlj19-iggp
mlj19-iggp-master/runner.py
import aleph import metagol import specialised_ilasp import os import multiprocessing import signal import numpy as np from os import listdir from os.path import isfile, join from multiprocessing import Pool import config as cfg import sys def game_names(path): # return ['minimal_decay'] return sorted(set('_'.j...
4,476
29.664384
121
py
mlj19-iggp
mlj19-iggp-master/common.py
import subprocess def gen_atom(index,x): syms = ['succ','input','between','true','number','index'] x=x.replace(' ','')[:-1] (p,args)=x.split('(') args=list(filter(lambda x: x!='',args.split(','))) args=[str(index)]+args for sym in syms: if sym in p: p=p.replace(sym,'my_{}'.f...
1,851
31.491228
91
py
mlj19-iggp
mlj19-iggp-master/prolog.py
import subprocess def swipl(action,load_files,outfile=None,timeout=None): call('swipl',action,load_files,outfile,timeout) def yap(action,load_files,outfile=None,timeout=None): call('yap',action,load_files,outfile,timeout) def call(prolog_version,action,load_files,outfile=None,timeout=None): load_files = ...
972
31.433333
98
py
mlj19-iggp
mlj19-iggp-master/metagol.py
import common import subprocess import prolog import string import config as cfg class Metagol: name='metagol' metagol_runner='metagol/runner' def __init__(self): pass def parse_train(self,datafile,outpath,game,target): for (subtarget,bk,pos,neg) in common.parse_target(datafile): ...
1,607
37.285714
127
py
mmvae-public
mmvae-public/src/main.py
import argparse import datetime import sys import json from collections import defaultdict from pathlib import Path from tempfile import mkdtemp import numpy as np import torch from torch import optim import models import objectives from utils import Logger, Timer, save_model, save_vars, unpack_data parser = argpars...
6,968
40.482143
93
py
mmvae-public
mmvae-public/src/vis.py
# visualisation related functions import matplotlib.colors as colors import matplotlib.pyplot as plt import numpy as np import pandas as pd import seaborn as sns import torch from matplotlib.lines import Line2D from umap import UMAP def custom_cmap(n): """Create customised colormap for scattered latent plot of n...
2,938
39.260274
97
py
mmvae-public
mmvae-public/src/utils.py
import math import os import shutil import sys import time import torch import torch.distributions as dist import torch.nn.functional as F from datasets import CUBImageFt # Classes class Constants(object): eta = 1e-6 log2 = math.log(2) log2pi = math.log(2 * math.pi) logceilc = 88 # largest cuda v s...
6,857
32.950495
110
py
mmvae-public
mmvae-public/src/objectives.py
# objectives of choice import torch from numpy import prod from utils import log_mean_exp, is_multidata, kl_divergence # helper to vectorise computation def compute_microbatch_split(x, K): """ Checks if batch needs to be broken down further to fit in memory. """ B = x[0].size(0) if is_multidata(x) else x.siz...
9,267
40.375
95
py
mmvae-public
mmvae-public/src/datasets.py
import io import json import os import pickle from collections import Counter, OrderedDict from collections import defaultdict import numpy as np import torch import torch.nn as nn from nltk.tokenize import sent_tokenize, word_tokenize from torch.utils.data import Dataset from torchvision import transforms, models, da...
8,431
32.19685
101
py
mmvae-public
mmvae-public/src/report/analyse_cub.py
"""Calculate cross and joint coherence of language and image generation on CUB dataset using CCA.""" import argparse import os import sys import torch import torch.nn.functional as F # relative import hack (sorry) import inspect currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) pa...
5,427
36.694444
101
py