Skip to content

Instantly share code, notes, and snippets.

View sergeyf's full-sized avatar
💭
º¿º

Sergey Feldman sergeyf

💭
º¿º
View GitHub Profile
@ivan
ivan / gist:cf2d7e53718e8f3a4489f3e66213136d
Last active July 13, 2022 05:04
uBlock Origin rules to hide useless stuff on Google Search results pages
! This is the most annoying one that Google optimizes for accidental clicks.
!
! Hide the 'People also search for' slide-in box when going back on Google Search.
! We require the other attributes here to reduce the risk of false positives.
www.google.com#$#div[id^="eob_"][jscontroller][jsdata][jsaction][data-ved] { display: none !important; }
! Hide the 'People also ask' box
www.google.com#$#div[data-initq][data-it][jscontroller][jsaction]:nth-ancestor(1) { display: none !important; }
! Hide the 'Related searches' box
@pmineiro
pmineiro / CbDroDemo.ipynb
Last active October 19, 2024 14:50
--cb_dro demo for vowpal wabbit using covertype. To see the lift, note the "since last acc" column with and without --cb-dro.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@redknightlois
redknightlois / mish_init.py
Created July 15, 2020 14:54
Variance based initialization method for Mish activation
def init_weights(m, variance=1.0):
def _calculate_fan_in_and_fan_out(tensor):
dimensions = tensor.dim()
if dimensions < 2:
return 1, 1
if dimensions == 2: # Linear
fan_in = tensor.size(1)
fan_out = tensor.size(0)
@arsho
arsho / update_pypi_package.md
Last active August 21, 2024 18:47
Update existing Python package in Pypi

Update PyPI package (Tested on 12/31/2023)

I updated my package autolike today using the following steps:

Update the project locally

  • Changed the version number in setup.py and modify package as necessary.

Test in development

Assuming you’re in the root of your project directory, then run:

pip install -e .

Created a build

@johnlees
johnlees / firth_regression.py
Last active May 9, 2023 19:11
Firth regression in python
#!/usr/bin/env python
'''Python implementation of Firth regression by John Lees
See https://www.ncbi.nlm.nih.gov/pubmed/12758140'''
def firth_likelihood(beta, logit):
return -(logit.loglike(beta) + 0.5*np.log(np.linalg.det(-logit.hessian(beta))))
# Do firth regression
# Note information = -hessian, for some reason available but not implemented in statsmodels
def fit_firth(y, X, start_vec=None, step_limit=1000, convergence_limit=0.0001):
@chssch
chssch / spacy_srl.py
Last active March 1, 2023 18:01
Use AllenNLP Semantic Role Labeling (http://allennlp.org/) with SpaCy 2.0 (http://spacy.io) components and extensions
# This small script shows how to use AllenNLP Semantic Role Labeling (http://allennlp.org/) with SpaCy 2.0 (http://spacy.io) components and extensions
# Script installs allennlp default model
# Important: Install allennlp form source and replace the spacy requirement with spacy-nightly in the requirements.txt
# Developed for SpaCy 2.0.0a18
from allennlp.commands import DEFAULT_MODELS
from allennlp.common.file_utils import cached_path
from allennlp.service.predictors import SemanticRoleLabelerPredictor
from allennlp.models.archival import load_archive
@myurasov
myurasov / Keras_WACGAN.ipynb
Last active April 3, 2021 03:12
Wasserstein ACGAN in Keras
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cbaziotis
cbaziotis / AttentionWithContext.py
Last active April 25, 2022 14:37
Keras Layer that implements an Attention mechanism, with a context/query vector, for temporal data. Supports Masking. Follows the work of Yang et al. [https://www.cs.cmu.edu/~diyiy/docs/naacl16.pdf] "Hierarchical Attention Networks for Document Classification"
def dot_product(x, kernel):
"""
Wrapper for dot product operation, in order to be compatible with both
Theano and Tensorflow
Args:
x (): input
kernel (): weights
Returns:
"""
if K.backend() == 'tensorflow':
@cbaziotis
cbaziotis / Attention.py
Last active October 22, 2024 08:31
Keras Layer that implements an Attention mechanism for temporal data. Supports Masking. Follows the work of Raffel et al. [https://arxiv.org/abs/1512.08756]
from keras import backend as K, initializers, regularizers, constraints
from keras.engine.topology import Layer
def dot_product(x, kernel):
"""
Wrapper for dot product operation, in order to be compatible with both
Theano and Tensorflow
Args:
@erikbern
erikbern / install-tensorflow.sh
Last active June 26, 2023 00:40
Installing TensorFlow on EC2
# Note – this is not a bash script (some of the steps require reboot)
# I named it .sh just so Github does correct syntax highlighting.
#
# This is also available as an AMI in us-east-1 (virginia): ami-cf5028a5
#
# The CUDA part is mostly based on this excellent blog post:
# http://tleyden.github.io/blog/2014/10/25/cuda-6-dot-5-on-aws-gpu-instance-running-ubuntu-14-dot-04/
# Install various packages
sudo apt-get update