Skip to content

Instantly share code, notes, and snippets.

🍣
⊂(´・◡・⊂ )∘˚˳°

Jason Tam JasonTam

🍣
⊂(´・◡・⊂ )∘˚˳°
Block or report user

Report or block JasonTam

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@JasonTam
JasonTam / tf_inspect_checkpoint_example.py
Created May 30, 2018
exmaple of how to inspect the contents of a tensorflow V2 checkpoint
View tf_inspect_checkpoint_example.py
from tensorflow.python.tools.inspect_checkpoint import print_tensors_in_checkpoint_file
print_tensors_in_checkpoint_file(
file_name='/tmp/tensorboard-logs/tophat-movielens/20180530T140423/model.ckpt',
tensor_name=None, all_tensors=False,
all_tensor_names=True,
)
View neg_samp_experiments.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@JasonTam
JasonTam / neg_samp.py
Last active Feb 28, 2018
vectorized negative sampling for sparse positive interactions
View neg_samp.py
"""
Pretty efficient way to sample negatives using binary search.
Imagine `pos_inds` are items a user has interacted with,
and we want a vectorized approach to uniformly sample many negative items.
This is better than (in the case where `n_samp` is large)
sampling from the entire catalog and then checking if it's a positive item.
Ahem... negative sampling for sparse interaction matrices.
"""
@JasonTam
JasonTam / binary_search_membership.py
Last active Feb 28, 2018
Most of the time `in` is good enough (even for lists)
View binary_search_membership.py
from bisect import bisect_left
def in_bs(a, x):
i = bisect_left(a, x)
return (i != len(a)) and (a[i] == x)
@JasonTam
JasonTam / lightfm_freeze-emb_example.ipynb
Last active Nov 7, 2017
example of how to freeze embeddings in lightfm by exploiting the accumulated gradient in adagrad
View lightfm_freeze-emb_example.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@JasonTam
JasonTam / approx_auc_dist.ipynb
Created Nov 1, 2017
Calculating AUC can take a long-ass time for large number of samples
View approx_auc_dist.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@JasonTam
JasonTam / parq_vs_avro_msg.ipynb
Last active Oct 24, 2017
Comparison of avro, msgpack, parquet
View parq_vs_avro_msg.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@JasonTam
JasonTam / samson_co1u_linux.md
Last active Apr 6, 2018
Samson C01U microphone remap hack
View samson_co1u_linux.md

The SAMSON CO1U microphone uses a stereo chip where the left channel should be the final output. However, on linux, we see the post-proc(left) and raw(right) signals separately. To fix this, we can map the left channel to both channels reducing to a proper mono channel. (Compare to setting a mono signal on pavucontrol which gives a screwed up noisy signal).

Add the following line to /etc/pulse/default.pa

# SAMSON CO1U HACK
load-module module-remap-source source_name=samson-co1u-hack master=alsa_input.usb-Samson_Technologies_Samson_C01U-00.analog-stereo master_channel_map=left,left channel_map=left,right remix=false

There is a chance your mic name is different than mine. You can confirm with pacmd list-sources | grep 'Samson' | grep 'name' and use the correct name for the master.

View avg_embs.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@JasonTam
JasonTam / benchmark_sparse_pos_check.ipynb
Last active Jun 7, 2017
sparse neg sampling benchmark
View benchmark_sparse_pos_check.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
You can’t perform that action at this time.