Skip to content

Instantly share code, notes, and snippets.

View VoVAllen's full-sized avatar

Jinjing Zhou VoVAllen

View GitHub Profile
@VoVAllen
VoVAllen / pgvector.py
Created September 6, 2023 14:26
transaction test
#!/usr/bin/python
import h5py
import psycopg2
import psycopg2.extras
from math import sqrt
import ipdb
import numpy as np
from tqdm import tqdm
@VoVAllen
VoVAllen / pg_embedding_hnsw_config.yml
Created August 22, 2023 18:34 — forked from jkatz/pg_embedding_hnsw_config.yml
ANN Benchmark (https://github.com/erikbern/ann-benchmarks) modules for HNSW implementations of pgvector and pg_embedding
float:
any:
- base_args: ['@metric']
constructor: PGEmbedding
disabled: false
docker_tag: ann-benchmarks-pg_embedding_hnsw
module: ann_benchmarks.algorithms.pg_embedding_hnsw
name: pg_embedding_hnsw
run_groups:
M-12:
@VoVAllen
VoVAllen / test.py
Created April 13, 2021 10:10 — forked from you74674/test.py
pytorch jit overload with inheritance
import torch
from torch.nn.utils.rnn import PackedSequence
from typing import overload, Optional
class Base(torch.nn.Module):
def __init__(self):
super().__init__()
@overload
@torch._jit_internal._overload_method
def forward(self, inputs, hx=None):
#!/bin/bash
set -x
if [ $# -ne 2 ]; then
REPO=dmlc
BRANCH=master
else
REPO=$1
BRANCH=$2
Rule:
- DOMAIN-SUFFIX,digicert.com,DIRECT
- DOMAIN-SUFFIX,mzstatic.com,Domestic
- DOMAIN-SUFFIX,akadns.net,Domestic
- DOMAIN-SUFFIX,aaplimg.com,Domestic
- DOMAIN-SUFFIX,cdn-apple.com,Domestic
- DOMAIN-SUFFIX,apple.com, Domestic
- DOMAIN-SUFFIX,icloud.com,Domestic
- DOMAIN-SUFFIX,icloud-content.com,Domestic
- DOMAIN,e.crashlytics.com,REJECT
@VoVAllen
VoVAllen / ani.py
Last active December 6, 2018 07:52
animation
def att_animation(maps_array, mode, src, tgt, head_id):
weights = [maps[mode2id[mode]][head_id] for maps in maps_array]
fig, axes = plt.subplots(1, 2)
axes[0].set_yticks(np.arange(len(src)))
axes[0].set_xticks(np.arange(len(tgt)))
axes[0].set_yticklabels(src)
axes[0].set_xticklabels(tgt)
plt.setp(axes[0].get_xticklabels(), rotation=45, ha="right",
rotation_mode="anchor")
@VoVAllen
VoVAllen / draw.py
Last active December 3, 2018 17:11
Draw att
# This part for jupyter notebook setting (if you wants to save, don't use this)
# %matplotlib inline
# %config InlineBackend.figure_format = 'svg'
# import numpy as np
# import matplotlib.pyplot as plt
# plt.rcParams["animation.html"] = "jshtml"
import networkx as nx
from networkx.algorithms import bipartite
@VoVAllen
VoVAllen / flatten.py
Created July 16, 2017 15:44
nn.Flatten implementation
class Flatten(nn.Module):
def __init__(self):
super(Flatten, self).__init__()
def forward(self, x):
return x.view(x.size(0), -1)
@VoVAllen
VoVAllen / dense.py
Last active July 16, 2017 15:46
nn.Linear infer shape implementation
def is_cuda(operation):
if isinstance(operation, th.nn.Module):
return 'cuda' in str(type(operation.parameters().next()))
elif isinstance(operation, th._TensorBase):
return 'cuda' in str(type(operation))
elif isinstance(operation, Variable):
return 'cuda' in str(type(operation.data))
else:
raise Exception("Operation is not nn.Module or Variable or Tensor")